From 59ac129a85076a7f92e1bddcb8825b0e9ec168f2 Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Wed, 28 Nov 2018 20:01:50 -0800 Subject: [PATCH] i3: improve automatic/timeout/suspend locking --- .config/i3/config | 5 +++-- .config/i3/powermenu.sh | 2 +- .config/systemd/user/sleep-i3lock@.service | 10 ---------- .config/systemd/user/sleep-lock-lightdm.service | 12 ++++++++++++ .../sleep.target.wants/sleep-lock-lightdm.service | 1 + .profile | 3 ++- 6 files changed, 19 insertions(+), 14 deletions(-) delete mode 100644 .config/systemd/user/sleep-i3lock@.service create mode 100644 .config/systemd/user/sleep-lock-lightdm.service create mode 120000 .config/systemd/user/sleep.target.wants/sleep-lock-lightdm.service diff --git a/.config/i3/config b/.config/i3/config index 6e4b6d3..3077c4d 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -137,7 +137,7 @@ bindsym $mod+Return exec i3-sensible-terminal bindsym $mod+Ctrl+Return exec i3-sensible-terminal -r floating-term bindsym $mod+Shift+Return exec i3-sensible-terminal -d "`xcwd`" bindsym $mod+Ctrl+Shift+Return exec i3-sensible-terminal -r floating-term -d "`xcwd`" -bindsym $mod+l exec ~/.config/i3/lock.sh +bindsym $mod+l exec dm-tool switch-to-greeter bindsym $mod+space exec "pkill rofi; rofi -show run -sidebar-mode -terminal i3-sensible-terminal -normal-window" bindsym $mod+Shift+p exec rofi-pass bindsym $mod+Shift+e exec rofi-emoji @@ -164,7 +164,8 @@ bindsym XF86MonBrightnessDown exec xbacklight -dec 5 && pkill -RTMIN+12 i3bloc # app launch shortcuts exec --no-startup-id ~/.config/i3/disable-standby-fs.py exec --no-startup-id feh --no-fehbg --no-xinerama --bg-fill ~/pictures/lakesidesunrise.jpg -exec --no-startup-id xautolock -time 5 -locker 'dm-tool lock' -nocloseout -nocloseerr +exec --no-startup-id xautolock -time 5 -locker 'dm-tool switch-to-greeter' -nocloseout -nocloseerr +exec --no-startup-id xss-lock dm-tool switch-to-greeter # startup programs exec --no-startup-id nextcloud diff --git a/.config/i3/powermenu.sh b/.config/i3/powermenu.sh index 19f73a1..2334622 100755 --- a/.config/i3/powermenu.sh +++ b/.config/i3/powermenu.sh @@ -3,7 +3,7 @@ option=$(echo "lock|logout|sleep|hibernate|power off|reboot|windows" | rofi -sep "|" -dmenu -i -p "" -auto-select -hide-scrollbar -monitor 0 -width 8 -lines 7 -location 3 -tokenize false -matching normal | xargs) case $option in - lock) ./lock.sh;; + lock) dm-tool switch-to-greeter;; logout) i3-msg exit;; sleep) systemctl suspend;; hibernate) systemctl hibernate;; diff --git a/.config/systemd/user/sleep-i3lock@.service b/.config/systemd/user/sleep-i3lock@.service deleted file mode 100644 index 66dffaf..0000000 --- a/.config/systemd/user/sleep-i3lock@.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Lock X session using i3lock - -[Service] -User=%i -Environment=DISPLAY=:0 -ExecStart=sh -c '~/.config/i3/lock.sh' - -[Install] -WantedBy=sleep.target diff --git a/.config/systemd/user/sleep-lock-lightdm.service b/.config/systemd/user/sleep-lock-lightdm.service new file mode 100644 index 0000000..4221972 --- /dev/null +++ b/.config/systemd/user/sleep-lock-lightdm.service @@ -0,0 +1,12 @@ +[Unit] +Description=Lock X LightDM session before sleeping +Before=sleep.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/dm-tool switch-to-greeter +# Ensure enough time for the session to lock before sleeping +ExecStartPost=/usr/bin/sleep 1 + +[Install] +WantedBy=sleep.target diff --git a/.config/systemd/user/sleep.target.wants/sleep-lock-lightdm.service b/.config/systemd/user/sleep.target.wants/sleep-lock-lightdm.service new file mode 120000 index 0000000..3da9b2a --- /dev/null +++ b/.config/systemd/user/sleep.target.wants/sleep-lock-lightdm.service @@ -0,0 +1 @@ +../sleep-lock-lightdm.service \ No newline at end of file diff --git a/.profile b/.profile index 91166a1..26bda43 100644 --- a/.profile +++ b/.profile @@ -76,6 +76,7 @@ fi if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && exists dbus-launch; then eval $(dbus-launch --sh-syntax --exit-with-session) dbus-update-activation-environment --systemd \ - DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY + DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY \ + XDG_SEAT_PATH fi