#!/bin/sh
# Copyright (c) 2019-2021 Sebastian LaVine <mail@smlavine.com>
# Licensed under the MIT license. See MIT.txt for details.
#
# File: quitdwm
# Description: Quits dwm, but first prompts the user with a dmenu prompt asking
# if they are sure.
if [ "$(printf "Y\nN" | dmenu -i -sb 'dark red' -p "Are you sure?")" = "Y" ]
then
ps --sort -etime a o pid,etime,tty,comm |
grep ' dwm$' |
dmenu -n -l 6 -sb 'dark green' -p "Which one?" |
sed 's/^ *//' | cut -d' ' -f1 | # ps(1) outputs leading spaces
xargs kill
fi