Added dwm helpers for laptop computers

This commit is contained in:
Mahesh Asolkar 2019-05-04 20:18:08 -07:00
parent b3c4b69d29
commit f2602d913b
2 changed files with 52 additions and 0 deletions

11
dwm_status.laptop Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
# vim: filetype=sh
VOL=$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')
LOCALTIME=$(date +"%Y %h %d %I:%M%p %Z")
IP=$(for i in `ip r`; do echo $i; done | grep -A 1 src | tail -n1)
WEATHER=$(weather fips4105192520 | grep Tempera | awk '{print $2}')
BAT=$(acpi -b | awk '{ print $4 " " $5 }' | tr -d ',')
xsetroot -name " 🔊 $VOL | $IP | 🔋 $BAT | ${WEATHER}°F | $LOCALTIME"

41
leave_session.laptop.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
#
# For this to work, something along the following lines needs to be
# in a file in /etc/sudoers.d/. The file must have 0440 permissions
#
# username ALL=(ALL:ALL) NOPASSWD:/usr/sbin/pm-suspend,/usr/sbin/pm-hibernate,/sbin/reboot,/sbin/shutdown
#
confirm() {
ans=$(echo -e "Yes\nNo" | dmenu -p "Leave session - Confirm?")
echo $ans
if [ "$ans" = "Yes" ]; then
echo "Leaving..."
else
echo "Abort!"
exit 1
fi
}
cmd=$(echo -e "hibernate\nsuspend\nreboot\nshutdown" | dmenu -p "Leave session:")
echo $cmd
case "$cmd" in
suspend)
confirm "Suspend"
sudo /usr/sbin/pm-suspend
;;
hibernate)
confirm "Hibernate"
sudo /usr/sbin/pm-hibernate
;;
reboot)
confirm "Reboot"
sudo /sbin/reboot
;;
shutdown)
confirm "Shutdown"
sudo /sbin/shutdown
;;
esac