diff --git a/defaults/main.yaml b/defaults/main.yaml index 74c486c..2f6fe18 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -45,10 +45,12 @@ system_suspend_command: systemctl suspend system_reboot_command: systemctl reboot system_poweroff_command: systemctl poweroff -session_lock_enabled: "{{ (home_profile != 'presentation') and (home_profile != 'vdesk') }}" -session_lock_command: xset s activate -session_enable_screensaver_command: /usr/local/bin/screensaver-enable -session_disable_screensaver_command: /usr/local/bin/screensaver-disable +lockscreen_enabled: "{{ (home_profile != 'presentation') and (home_profile != 'vdesk') }}" +lockscreen_lock_command: xset s activate +lockscreen_timeout: 300 +lockscreen_locktime: 30 + +display_sleeptime: 300 file_browser_command: thunar calculator_command: "{{default_browser}} --new-window https://www.geogebra.org/calculator" diff --git a/files/bin/screensaver b/files/bin/screensaver new file mode 100755 index 0000000..2b3cadc --- /dev/null +++ b/files/bin/screensaver @@ -0,0 +1,2 @@ +#!/bin/sh +exec /usr/libexec/xscreensaver/glmatrix -density 50 -no-rotate $@ diff --git a/tasks/apt.yaml b/tasks/apt.yaml index 2905e59..0257037 100644 --- a/tasks/apt.yaml +++ b/tasks/apt.yaml @@ -5,3 +5,5 @@ pkg: - socat - fish + - xsecurelock + - xss-lock diff --git a/tasks/clean.yaml b/tasks/clean.yaml index 981ea56..6344576 100644 --- a/tasks/clean.yaml +++ b/tasks/clean.yaml @@ -62,3 +62,10 @@ path: ~/.config/systemd/user/autostart-desktop-app@.service state: absent notify: systemd daemon-reload + +- name: screensaver graphical-session service disabled + systemd: + name: screensaver.service + enabled: false + state: stopped + scope: user diff --git a/tasks/lockscreen.yaml b/tasks/lockscreen.yaml new file mode 100644 index 0000000..32e76e5 --- /dev/null +++ b/tasks/lockscreen.yaml @@ -0,0 +1,24 @@ +--- + +- name: lockscreen environment + template: + src: lockscreen/lockscreen.env.j2 + dest: ~/.lockscreen.env + +- name: lockscreen graphical-session service + 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: + name: lockscreen.service + enabled: "{{ lockscreen_enabled }}" + scope: user diff --git a/tasks/main.yaml b/tasks/main.yaml index f7a266e..0eb9bef 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -6,7 +6,6 @@ - import_tasks: ssh.yaml - import_tasks: tmux.yaml - import_tasks: pulseaudio.yaml -- import_tasks: screensaver.yaml - import_tasks: git.yaml - import_tasks: timer.yaml @@ -18,6 +17,9 @@ - import_tasks: i3.yaml tags: - i3 + - import_tasks: lockscreen.yaml + tags: + - lockscreen - import_tasks: workspaces.yaml - import_tasks: icons.yaml - import_tasks: background.yaml diff --git a/tasks/screensaver.yaml b/tasks/screensaver.yaml deleted file mode 100644 index afb3463..0000000 --- a/tasks/screensaver.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- - -- name: screensaver graphical-session service enabled - systemd: - name: screensaver.service - enabled: "{{ session_lock_enabled }}" - scope: user diff --git a/templates/i3/i3.config.j2 b/templates/i3/i3.config.j2 index 7ec94a9..8131adc 100644 --- a/templates/i3/i3.config.j2 +++ b/templates/i3/i3.config.j2 @@ -22,7 +22,7 @@ floating_modifier $mod ### default/local mode ## special keys -bindsym XF86Sleep exec {{i3_exec_command_prefix}} {{session_lock_command}} +bindsym XF86Sleep exec {{i3_exec_command_prefix}} {{lockscreen_lock_command}} bindsym XF86Mail exec {{i3_exec_command_prefix}} {{mail_command}} bindsym XF86HomePage exec {{i3_exec_command_prefix}} {{default_browser}} bindsym XF86Calculator exec {{i3_exec_command_prefix}} {{calculator_command}} @@ -172,7 +172,7 @@ bindsym $mod+KP_Add exec {{points_up_command}} mode "remote" { bindcode $mod+9 mode "default" - bindsym XF86Sleep exec {{session_lock_command}} + bindsym XF86Sleep exec {{lockscreen_lock_command}} # The middle button over a titlebar kills the window bindsym --release button2 kill @@ -199,11 +199,11 @@ mode "session" { bindsym r reload; exec --no-startup-id ~/.xsession.reload.fish; mode "default"; {{on_focus_workspace}} bindsym R reload; exec --no-startup-id ~/.xsession.reload.fish; mode "default"; {{on_focus_workspace}} bindsym s exec --no-startup-id {{system_suspend_command}}; mode "default"; {{on_focus_workspace}} - bindsym l exec --no-startup-id {{session_lock_command}}; mode "default"; {{on_focus_workspace}} - bindcode 49 exec --no-startup-id {{session_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 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 b exec --no-startup-id xsetroot -solid black; 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 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 new file mode 100644 index 0000000..d0ccad1 --- /dev/null +++ b/templates/lockscreen/lockscreen.env.j2 @@ -0,0 +1,5 @@ +{{ ansible_managed | comment }} + +#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 new file mode 100644 index 0000000..b288491 --- /dev/null +++ b/templates/lockscreen/lockscreen.service.j2 @@ -0,0 +1,14 @@ +{{ ansible_managed | comment }} + +[Unit] +Description=Screensaver +PartOf=graphical-session.target + +[Service] +Type=notify +ExecStart=xsecurelock -- systemd-notify --ready +NotifyAccess=all +EnvironmentFile=%h/.lockscreen.env + +[Install] +WantedBy=graphical-session.target diff --git a/templates/x11/xsession.reload.fish.j2 b/templates/x11/xsession.reload.fish.j2 index 2d9a466..eff6f6c 100644 --- a/templates/x11/xsession.reload.fish.j2 +++ b/templates/x11/xsession.reload.fish.j2 @@ -20,7 +20,12 @@ xrdb -merge ~/.Xresources rofi -theme ~/.config/rofi/theme -dump-xresources > ~/.config/rofi/config # screensaver settings -/usr/local/bin/screensaver-settings +xset s on +xset +dpms +xset s {{ lockscreen_timeout | int }} {{ lockscreen_locktime | int }} + +# DPMS options +xset dpms {{ display_sleeptime | int }} {{ display_sleeptime | int }} {{ display_sleeptime | int }} # allow hosts {% for xhost in home_xhosts_allow %}