Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@p7cq
Last active April 26, 2020 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p7cq/9312571ebba717dc529ff47e315a178d to your computer and use it in GitHub Desktop.
Save p7cq/9312571ebba717dc529ff47e315a178d to your computer and use it in GitHub Desktop.
A logout script for dwm

A logout script for dwm

Configuration

Add lrfs in PATH and make it executable.

Modify config.h:

  • define a new function:
    static const char *lrfs[] = { "lrfs", NULL };
    
  • and replace the existing quit behavior by modifying its key binding with:
    { MODKEY|ShiftMask,             XK_q,      spawn,          {.v = lrfs } },
    

To eliminate the compile time warning, comment out the function void quit(const Arg *arg) in dwm.c.

#!/bin/sh
# lrfs: used in dwm to replace quit key binding behaviour.
title="[l]ogout [r]eboot [f]irmware [s]hutdown"
options="l\nr\nf\ns"
dwm=$( ps -o pid,cmd ax | awk '/dwm/{ if ($2 == "dwm") print $1 }' )
action() {
answer="$( echo -e $1 | dmenu -i -p "$2" -fn "System-ui Regular:size=12" -nb "#1d2021" -nf "#d79921" -sb "#d79921" -sf "#1d2021" )"
}
action "$options" "$title"
case $answer in
"l")
[[ ! -z "$dwm" ]] && kill -s TERM $dwm
;;
"r")
systemctl reboot
;;
"f")
systemctl reboot --firmware-setup
;;
"s")
systemctl poweroff
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment