Commit b5c9e707 authored by Gabriele Musco's avatar Gabriele Musco
Browse files

added support for swaylock

parent b76c1d05
Pipeline #114916 passed with stage
in 21 seconds
......@@ -22,7 +22,7 @@ def _apply_wallpapers_worker(monitors, lockscreen=False):
if desktop_environment == 'mate':
set_wallpaper = set_wallpaper_mate
elif desktop_environment == 'sway':
set_wallpaper_sway(monitors)
set_wallpaper_sway(monitors, lockscreen)
# add other DE cases as `elif` here
if len(monitors) == 1:
set_wallpaper(monitors[0].wallpaper, 'zoom', lockscreen)
......
......@@ -7,6 +7,7 @@ import re
TMP_DIR = '/tmp/HydraPaper/'
SWAY_CONF_PATH = f'{Env.get("HOME")}/.config/sway/config'
SWAYLOCK_CONF_PATH = f'{Env.get("HOME")}/.swaylock/config'
def multi_setup_pillow(monitors, save_path, wp_setter_func=None):
......@@ -59,17 +60,21 @@ def set_wallpaper_mate(path, wp_mode='spanned', lockscreen=False):
def set_wallpaper_sway(monitors, lockscreen=False):
if lockscreen:
print('Lock screen wallpaper on sway unsupported')
return
with open(SWAY_CONF_PATH) as fd:
conf_path = SWAYLOCK_CONF_PATH if lockscreen else SWAY_CONF_PATH
with open(conf_path) as fd:
conf = fd.read()
fd.close()
if lockscreen:
n_conf = re.sub(r'image=.*', '', conf).strip()
n_conf += '\n' + '\n'.join([
f'image={m.name}:{m.wallpaper.replace(":", "::")}' for m in monitors
])
else:
n_conf = re.sub(r'output .* bg .*', '', conf).strip()
n_conf += '\n' + '\n'.join([
f'output {m.name} bg {m.wallpaper} fill' for m in monitors
])
with open(SWAY_CONF_PATH, 'w') as fd:
with open(conf_path, 'w') as fd:
fd.write(n_conf)
fd.close()
run('sway reload'.split(' '))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment