mirror of
https://github.com/morgant/mlvwmrc.git
synced 2024-12-26 16:29:15 +00:00
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:
parent
4b089a72f5
commit
f4078e6820
@ -48,9 +48,10 @@ Menu Default-Label, Label "Label"
|
|||||||
"Project 2" NonSelect, Gray
|
"Project 2" NonSelect, Gray
|
||||||
END
|
END
|
||||||
|
|
||||||
Menu Default-Restart
|
Menu Default-WindowManager
|
||||||
"Start twm" Action Restart twm
|
"Start twm" Action Restart twm
|
||||||
"Start fvwm" Action Restart fvwm
|
"Start fvwm" Action Restart fvwm
|
||||||
|
"Restart mlvwm" Action Restart mlvwm
|
||||||
END
|
END
|
||||||
|
|
||||||
Menu Default-Special, Label "Special"
|
Menu Default-Special, Label "Special"
|
||||||
@ -60,10 +61,12 @@ Menu Default-Special, Label "Special"
|
|||||||
"Eject Disk" NonSelect, Gray
|
"Eject Disk" NonSelect, Gray
|
||||||
"Erase Disk..." NonSelect, Gray
|
"Erase Disk..." NonSelect, Gray
|
||||||
"" NonSelect
|
"" NonSelect
|
||||||
"Start" SubMenu Default-Restart
|
"Window Manager" SubMenu Default-WindowManager
|
||||||
|
"" NonSelect
|
||||||
"Log Out" Action Exit
|
"Log Out" Action Exit
|
||||||
"Restart" Action Restart mlvwm
|
"Sleep" Action Exec mlvwm-powerdown exec mlvwm-powerdown -s
|
||||||
"Shut down" Action Exit
|
"Restart" Action Exec mlvwm-powerdown exec mlvwm-powerdown -r
|
||||||
|
"Shut Down" Action Exec mlvwm-powerdown exec mlvwm-powerdown -p
|
||||||
END
|
END
|
||||||
|
|
||||||
Menu Default-Window
|
Menu Default-Window
|
||||||
|
7
Makefile
7
Makefile
@ -1,5 +1,6 @@
|
|||||||
TEMP=tmp
|
TEMP=tmp
|
||||||
CONF=.mlvwm
|
CONF=.mlvwm
|
||||||
|
BIN=bin
|
||||||
PIXMAP=$(CONF)/pixmap
|
PIXMAP=$(CONF)/pixmap
|
||||||
PATTERNS=$(CONF)/patterns
|
PATTERNS=$(CONF)/patterns
|
||||||
|
|
||||||
@ -51,11 +52,15 @@ patterns:
|
|||||||
curl -# -L https://imgur.com/a/9jYy0/zip -o "$(TEMP)/Mac OS Solid Color Backgrounds.zip"
|
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"
|
unzip -d $(PATTERNS) "$(TEMP)/Mac OS Solid Color Backgrounds.zip"
|
||||||
|
|
||||||
install:
|
install: install-bin
|
||||||
cp -R $(CONF) $(HOME)/
|
cp -R $(CONF) $(HOME)/
|
||||||
ln -fs $(HOME)/$(CONF)/.mlvwmrc $(HOME)/.mlvwmrc
|
ln -fs $(HOME)/$(CONF)/.mlvwmrc $(HOME)/.mlvwmrc
|
||||||
sed -i 's@/home2/tak/bin/pixmap@$(HOME)/$(PIXMAP)@g' $(HOME)/$(CONF)/.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
|
clean: clean-pixmap
|
||||||
rm -r $(TEMP)
|
rm -r $(TEMP)
|
||||||
rm -rf $(PATTERNS)
|
rm -rf $(PATTERNS)
|
||||||
|
70
bin/mlvwm-powerdown
Executable file
70
bin/mlvwm-powerdown
Executable 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
|
Loading…
Reference in New Issue
Block a user