diff --git a/.config/wlogout/layout b/.config/wlogout/layout index 1b89340..eeac71c 100644 --- a/.config/wlogout/layout +++ b/.config/wlogout/layout @@ -6,7 +6,7 @@ } { "label" : "logout", - "action" : "hyprctl dispatch exit", + "action" : "~/.config/zsh/.zlogout", "text" : "Logout", "keybind" : "e" } diff --git a/.config/zsh/.zlogout b/.config/zsh/.zlogout old mode 100644 new mode 100755 index 3d09ec2..9d4073e --- a/.config/zsh/.zlogout +++ b/.config/zsh/.zlogout @@ -1,6 +1,21 @@ -wl-copy -c -cliphist wipe -pkill -u "$USER" -9 ssh-agent -pkill -u "$USER" -9 pipewire -pkill -u "$USER" -9 dbus-daemon -killall -u "$USER" -9 kill-wine-explorer.sh +#!/bin/zsh + +# Clear clipboard +if [[ -n $WAYLAND_DISPLAY ]]; then + wl-copy -c + cliphist wipe +fi + +# Kill ssh-agent if it's the only opened session for this user +if [[ $(who | grep "$USER" | wc -l) -le 1 ]]; then + ssh-add -D + pkill -u "$USER" -9 ssh-agent +fi + +if [[ -n $HYPRLAND_INSTANCE_SIGNATURE ]]; then + HYPRCMDS=$(hyprctl -j clients | jq -j '.[] | "dispatch closewindow address:\(.address); "') + hyprctl -q --batch "$HYPRCMDS" + hyprctl dispatch exit +fi + +loginctl terminate-session $XDG_SESSION_ID