This repository has been archived on 2024-09-01. You can view files and clone it, but cannot push or open issues or pull requests.
al-skel/home/bin/session-logout

37 lines
839 B
Bash
Executable File

#!/usr/bin/env bash
# check which wm were using, case insensitive
WMS=(bspwm i3 openbox)
for i in ${WMS[@]}; do
if [[ "$(wmctrl -m | grep -i name | awk '{print tolower($2)}')" == "$i" ]]; then
WM=$i && break
elif [[ "$(xprop -root -notype | grep "WM_NAME =" | tr -d '"' | awk '{print tolower($3)}')" == "$i" ]]; then
WM=$i && break
elif [[ "$(awk '{print tolower($0)}' <<< $XDG_CURRENT_DESKTOP)" == "$i" ]]; then
WM=$i && break
fi
done
# do the logout
case $WM in
i3)
i3-msg exit
;;
bspwm)
for window_id in $(bspc query -W); do
bspc window $window_id -c
done
killall sxhkd
bspc quit
;;
openbox)
openbox --exit
;;
*)
echo "WM not yet supported.. Exiting"
exit 0
;;
esac