Added new mlvwm-powerdown script implementing OS-specific sleep/reboot/shutdown functionality, updated Makefile to install mlvwm-* scripts in ~/bin, and updated Special menu items to use mlvwm-powerdown for sleep/restart/shutdown functionality. Issue #10

This commit is contained in:
Morgan Aldridge 2023-09-20 12:46:35 -04:00
parent 4b089a72f5
commit f4078e6820
3 changed files with 83 additions and 5 deletions

View File

@ -48,9 +48,10 @@ Menu Default-Label, Label "Label"
"Project 2" NonSelect, Gray
END
Menu Default-Restart
Menu Default-WindowManager
"Start twm" Action Restart twm
"Start fvwm" Action Restart fvwm
"Restart mlvwm" Action Restart mlvwm
END
Menu Default-Special, Label "Special"
@ -60,10 +61,12 @@ Menu Default-Special, Label "Special"
"Eject Disk" NonSelect, Gray
"Erase Disk..." NonSelect, Gray
"" NonSelect
"Start" SubMenu Default-Restart
"Window Manager" SubMenu Default-WindowManager
"" NonSelect
"Log Out" Action Exit
"Restart" Action Restart mlvwm
"Shut down" Action Exit
"Sleep" Action Exec mlvwm-powerdown exec mlvwm-powerdown -s
"Restart" Action Exec mlvwm-powerdown exec mlvwm-powerdown -r
"Shut Down" Action Exec mlvwm-powerdown exec mlvwm-powerdown -p
END
Menu Default-Window

View File

@ -1,5 +1,6 @@
TEMP=tmp
CONF=.mlvwm
BIN=bin
PIXMAP=$(CONF)/pixmap
PATTERNS=$(CONF)/patterns
@ -51,11 +52,15 @@ patterns:
curl -# -L https://imgur.com/a/9jYy0/zip -o "$(TEMP)/Mac OS Solid Color Backgrounds.zip"
unzip -d $(PATTERNS) "$(TEMP)/Mac OS Solid Color Backgrounds.zip"
install:
install: install-bin
cp -R $(CONF) $(HOME)/
ln -fs $(HOME)/$(CONF)/.mlvwmrc $(HOME)/.mlvwmrc
sed -i 's@/home2/tak/bin/pixmap@$(HOME)/$(PIXMAP)@g' $(HOME)/$(CONF)/.mlvwmrc
install-bin:
mkdir -p $(HOME)/$(BIN)
install -b -B .`date +%Y%m%d-%H%M%S` -m 700 -o $(USER) $(BIN)/mlvwm-* $(HOME)/$(BIN)
clean: clean-pixmap
rm -r $(TEMP)
rm -rf $(PATTERNS)

70
bin/mlvwm-powerdown Executable file
View File

@ -0,0 +1,70 @@
#!/bin/sh
# mlvwm-powerdown - Wrapper OS-specific implementations of sleep, reboot, and/or
# power off of the system
#
# There may be OS-specific configuration required
tool="$(basename "$0")"
os="$(uname -s)"
_usage() {
echo "Usage: ${tool} [-s | -r | -p]"
exit 1
}
_unsupported() {
echo "${tool}: ${1} is not supported under ${os}."
exit 1
}
_sleep_now() {
case "$os" in
"OpenBSD")
pgrep -q apmd && zzz
;;
*)
_unsupported "sleep"
;;
esac
}
_reboot_now() {
case "$os" in
"OpenBSD"|"FreeBSD"|"Linux")
shutdown -r now
;;
*)
_unsupported "reboot"
;;
esac
}
_poweroff_now() {
case "$os" in
"OpenBSD"|"FreeBSD")
shutdown -p now
;;
"Linux")
shutdown -P now
;;
*)
_unsupported "power off"
;;
esac
}
case "$1" in
"-s")
_sleep_now
;;
"-r")
_reboot_now
;;
"-p")
_poweroff_now
;;
*)
_usage
;;
esac