From 0fd8476a446e3a1c940f13f87bc050af272b221e Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Wed, 5 Jan 2022 10:07:52 +0100 Subject: [PATCH] lockscreen --- tasks/clean.yaml | 1 + tasks/lockscreen.yaml | 7 +++++++ templates/i3/i3.config.j2 | 4 ++-- templates/lockscreen/lockscreen-auto.service.j2 | 13 +++++++++++++ templates/lockscreen/lockscreen.env.j2 | 2 +- templates/lockscreen/lockscreen.service.j2 | 6 +++--- 6 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 templates/lockscreen/lockscreen-auto.service.j2 diff --git a/tasks/clean.yaml b/tasks/clean.yaml index b8eae7b..6344576 100644 --- a/tasks/clean.yaml +++ b/tasks/clean.yaml @@ -67,4 +67,5 @@ systemd: name: screensaver.service enabled: false + state: stopped scope: user diff --git a/tasks/lockscreen.yaml b/tasks/lockscreen.yaml index eed364a..32e76e5 100644 --- a/tasks/lockscreen.yaml +++ b/tasks/lockscreen.yaml @@ -9,6 +9,13 @@ template: src: lockscreen/lockscreen.service.j2 dest: ~/.config/systemd/user/lockscreen.service + notify: systemd daemon-reload + +- name: lockscreen-auto graphical-session service + template: + src: lockscreen/lockscreen-auto.service.j2 + dest: ~/.config/systemd/user/lockscreen-auto.service + notify: systemd daemon-reload - name: lockscreen graphical-session service enabled systemd: diff --git a/templates/i3/i3.config.j2 b/templates/i3/i3.config.j2 index e971fc0..c8b1b5a 100644 --- a/templates/i3/i3.config.j2 +++ b/templates/i3/i3.config.j2 @@ -201,8 +201,8 @@ mode "session" { bindsym s exec --no-startup-id {{system_suspend_command}}; mode "default"; {{on_focus_workspace}} bindsym l exec --no-startup-id {{lockscreen_lock_command}}; mode "default"; {{on_focus_workspace}} bindcode 49 exec --no-startup-id {{lockscreen_lock_command}}; mode "default"; {{on_focus_workspace}} - bindsym e exec --no-startup-id {{session_enable_screensaver_command}}; mode "default"; {{on_focus_workspace}} - bindsym d exec --no-startup-id {{session_disable_screensaver_command}}; mode "default"; {{on_focus_workspace}} + bindsym e exec --no-startup-id systemctl --user start lockscreen.service; mode "default"; {{on_focus_workspace}} + bindsym d exec --no-startup-id systemctl --user stop lockscreen.service; mode "default"; {{on_focus_workspace}} bindsym b exec --no-startup-id xsetroot -solid black; mode "default"; {{on_focus_workspace}} bindsym Shift+R exec --no-startup-id {{system_reboot_command}}; mode "default"; {{on_focus_workspace}} bindsym Shift+P exec --no-startup-id {{system_poweroff_command}}; mode "default"; {{on_focus_workspace}} diff --git a/templates/lockscreen/lockscreen-auto.service.j2 b/templates/lockscreen/lockscreen-auto.service.j2 new file mode 100644 index 0000000..aded42e --- /dev/null +++ b/templates/lockscreen/lockscreen-auto.service.j2 @@ -0,0 +1,13 @@ +{{ ansible_managed | comment }} + +[Unit] +Description=Screensaver +PartOf=graphical-session.target + +[Service] +Type=simple +ExecStart=/usr/bin/xss-lock -l -- systemctl --user start lockscreen.service +Restart=always + +[Install] +WantedBy=graphical-session.target diff --git a/templates/lockscreen/lockscreen.env.j2 b/templates/lockscreen/lockscreen.env.j2 index c64a2a3..d0ccad1 100644 --- a/templates/lockscreen/lockscreen.env.j2 +++ b/templates/lockscreen/lockscreen.env.j2 @@ -1,5 +1,5 @@ {{ ansible_managed | comment }} -XSECURELOCK_SAVER=%h/bin/screensaver +#XSECURELOCK_SAVER=$HOME/bin/screensaver XSECURELOCK_AUTH_BACKGROUND_COLOR={{home_base_color_hue|hsv2rgb(66,47)}} XSECURELOCK_SWITCH_USER_COMMAND=dm-tool switch-to-greeter diff --git a/templates/lockscreen/lockscreen.service.j2 b/templates/lockscreen/lockscreen.service.j2 index 771535e..b288491 100644 --- a/templates/lockscreen/lockscreen.service.j2 +++ b/templates/lockscreen/lockscreen.service.j2 @@ -5,9 +5,9 @@ Description=Screensaver PartOf=graphical-session.target [Service] -Type=simple -ExecStart=/usr/bin/xss-lock -l -- xsecurelock -Restart=always +Type=notify +ExecStart=xsecurelock -- systemd-notify --ready +NotifyAccess=all EnvironmentFile=%h/.lockscreen.env [Install]