Merge pull request #137 from LazoCoder/feh

Add proper feh support
This commit is contained in:
Samuel Henrique 2018-01-06 20:39:09 -02:00 committed by GitHub
commit 3312d54809
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 18 deletions

View file

@ -0,0 +1,19 @@
from . import WallpaperProvider as _WProv
from os import system
from pathlib import Path
from shutil import which
import subprocess
class FehProvider(_WProv):
def change_wallpaper(path: str):
system(f'feh --no-fehbg --bg-fill "{path}"')
def is_compatible() -> bool:
root_window_prop = str(subprocess.check_output('xprop -root -notype', shell=True))
return which("feh") is not None and \
(Path.home() / '.fehbg').is_file() and \
any(wm_signature in root_window_prop for wm_signature in ('I3_PID', '_OPENBOX_PID'))
def __str__():
return "feh wallpaper tool"

View file

@ -1,18 +0,0 @@
from . import WallpaperProvider as _WProv
from os import environ as _environ, system as _system
from shutil import which as _which
from sys import exit as _exit
class I3wmAdapter(_WProv):
def change_wallpaper(path: str):
file = _which("feh")
if file is None:
# I did the checking here not to seem we don't support i3
print("feh not found, you need it to set the background in i3.")
_exit(0)
_system(f'feh --bg-fill "{path}"')
def is_compatible() -> bool:
return 'i3' in _environ.get('XDG_CURRENT_DESKTOP', '') and \
'i3' in _environ.get('XDG_SESSION_DESKTOP', '')