From e1100c500b1bdc3c01e717652c3fc52f4e361943 Mon Sep 17 00:00:00 2001 From: Morgan Aldridge Date: Wed, 4 Oct 2023 21:37:45 -0400 Subject: [PATCH] Added new mlvwm-message script (wrapper around gxmessage & xmessage), new mlvwm-alert & mlvwm-confirm scripts (utilize mlvwm-message to implement alert- & confirmation-style dialogs), updated mlvwm-powerdown script to use mlvwm-confirm. Also updated Xmessage styles to remove window decorations, plus added comparable Gxmessage styles. Finally, documented the various mlvwm-* scripts in the README. --- .mlvwm/apps/.AppsManifest | 1 + .mlvwm/apps/gxmessage | 4 ++ .mlvwm/apps/xmessage | 2 +- README.md | 110 +++++++++++++++++++++++++++++++++++++- bin/mlvwm-alert | 10 ++++ bin/mlvwm-confirm | 10 ++++ bin/mlvwm-message | 6 +++ bin/mlvwm-powerdown | 10 ++-- 8 files changed, 148 insertions(+), 5 deletions(-) create mode 100644 .mlvwm/apps/gxmessage create mode 100755 bin/mlvwm-alert create mode 100755 bin/mlvwm-confirm create mode 100755 bin/mlvwm-message diff --git a/.mlvwm/apps/.AppsManifest b/.mlvwm/apps/.AppsManifest index 87310d0..3dda383 100644 --- a/.mlvwm/apps/.AppsManifest +++ b/.mlvwm/apps/.AppsManifest @@ -5,6 +5,7 @@ Read .mlvwm/apps/chrome Read .mlvwm/apps/clementine Read .mlvwm/apps/cool-retro-term Read .mlvwm/apps/firefox +Read .mlvwm/apps/gxmessage Read .mlvwm/apps/HandBrake Read .mlvwm/apps/krita Read .mlvwm/apps/meld diff --git a/.mlvwm/apps/gxmessage b/.mlvwm/apps/gxmessage new file mode 100644 index 0000000..069af71 --- /dev/null +++ b/.mlvwm/apps/gxmessage @@ -0,0 +1,4 @@ +Style +"gxmessage" NoSBarH, NoSBarV, NoCloseR, NoResizeR, NoMinMaxR, NoWinList, StayOnTop +"gxmessage" MiniIcon mini-x.xpm +END diff --git a/.mlvwm/apps/xmessage b/.mlvwm/apps/xmessage index 7794bb5..92bda62 100644 --- a/.mlvwm/apps/xmessage +++ b/.mlvwm/apps/xmessage @@ -1,4 +1,4 @@ Style -"xmessage" NoSBarH, NoSBarV +"xmessage" NoSBarH, NoSBarV, NoCloseR, NoResizeR, NoMinMaxR, NoWinList, StayOnTop "xmessage" MiniIcon mini-x.xpm END diff --git a/README.md b/README.md index 10dc6a4..f0a3cfd 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,12 @@ MLVWM includes a very rudimentary set of rc ([run command](https://en.wikipedia. * `curl` * ImageMagick * `xdotool` (for `mlvwm-restart`) +* `gxmessage` * [`maim`](https://github.com/naelstrof/maim) & [`slop`](https://github.com/naelstrof/slop) (for `mlvwm-screenshot`) ## USAGE -Run `make && make install` to install `.mlvwmrc` and `.mlvwm/` in your home directory, including downloading and/or converting appropriate icons. +Run `make && make install` to install `.mlvwm/`, `.mlvwmrc`, and `bin/mlvwm-*` in your home directory, including downloading and/or converting appropriate icons. ## TESTING @@ -62,6 +63,7 @@ Configurations for the following X11 applications are included: * [Clementine](https://www.clementine-player.org/) * [cool-retro-term](https://github.com/Swordfish90/cool-retro-term) * [Firefox](https://www.getfirefox.com/) +* [Gxmessage](https://trmusson.dreamhosters.com/programs.html#gxmessage) * [HandBrake](https://handbrake.fr/) * [Krita](https://krita.org/) * [Meld](http://meldmerge.org/) @@ -100,6 +102,105 @@ Configurations for additional applications and utilities are also available from * [Xosview2 mini graphs](https://github.com/morgant/mlvwmrc-xosview2) * [x11vnc Menu Extra](https://github.com/morgant/mlvwmrc-x11vnc) + +## MLVWM-SPECIFIC SCRIPTS + +A few `mlvwm`-specific scripts are included and installed in `~/bin/`. You should ensure that this directory is in your user's `PATH` environment variable. + +### mlvwm-message + +`mlvwm-message` is a wrapper around `gxmessage` and `xmessage` (both of which accept the same options), so that other `mlvwm`-specific scripts can use the former, if available, or fall back to the latter. + +Usage: + +``` +mlvwm-message [ -buttons label1[:value1],label2[:value2], ... ] [ options ] message ... +``` + +Example: + +``` +mlvwm-message -title "Yo" -buttons "Goodbye:1,Hello:2" -default "Hello" "Hello, world!" +``` + +### mlvwm-alert + +`mlvwm-alert` is a wrapper around `mlvwm-message` which displays an alert-style dialog with the provided title, message, and with a single "OK" button to dismiss it. + +Usage: + +``` +mlvwm-alert title message +``` + +Example: + +``` +mlvwm-alert "WARNING!" "This message will self destruct..." +``` + +### mlvwm-confirm + +`mlvwm-confirm` is a wrapper around `mlvwm-message` which displays a confirmation-style dialog with the provided title, message, and with two buttons to dismiss it: "OK" to confirm (exit status `0`) and "Cancel" to deny (exit status `1`). + +Usage: + +``` +mlvwm-confirm title message +``` + +Example: + +``` +mlvwm-confirm "Shut Down" "Are you sure you want to shut down your computer now?" +``` + +### mlvwm-powerdown + +`mlvwm-powerdown` is a wrapper around OS-specific commands to suspend/sleep, reboot/restart, or shut/power down the computer. It accepts a single option, either `-s` for suspend/sleep, `-r` for reboot/restart, or `-p` for power/shut down. For the `-r` & `-p` options, it utilizes `mlvwm-confirm` to prompt for confirmation before restarting or shutting down the computer. + +This is primarily used to implement "Sleep", "Restart", and "Shutdown" menu items in the default "Special" menu. + +Usage: + +``` +mlvwm-powerdown [ -s | -r | -p ] +``` + +Example: + +``` +mlvwm-powerdown -p +``` + +### mlvwm-restart + +`mlvwm-restart`, unlike `mlvwm-powerdown`, is unrelated to the power state of the computer and is instead used to relaunch `mlvwm`, reloading configurations. It requires `xdotool` to trigger a special keyboard shortcut which is specified in the default configuration. + +Usage: + +``` +mlvwm-restart +``` + +### mlvwm-screenshot + +`mlvwm-screenshot` is a wrapper around `maim` which saves a date & time stamped PNG screenshot of the screen in the user's `~/Pictures/` directory. Optionally, by specifying the `-s` option, it will allow the user to select an area of the screen to be captured instead of the entire screen. + +This is primarily used to implement the screenshots via keyboard shortcuts in the default configuration. + +Usage: + +``` +mlvwm-screenshot [ -s ] +``` + +Example: + +``` +mlvwm-screenshot -s +``` + ## DATA STRUCTURE MLVWM loads its configuration from `~/.mlvwmrc`, but to break configuration up into more logical and manageable chunks within a `~/.mlvwm/` directory. That directory contains its own `.mlvwmrc` file which `~/.mlvwmrc` gets symlinked to, and it takes advantage of the `Read` command (see [mlvwm/CONFIGURATION](https://github.com/morgant/mlvwm/blob/master/CONFIGURATION)) to import the remaining configuration files. @@ -128,6 +229,13 @@ The current structure is: … pixmap/ *.xpm + bin/ + mlvwm-alert + mlvwm-confirm + mlvwm-message + mlvwm-powerdown + mlvwm-restart + mlvwm-screenshot ### .mlvwmrc diff --git a/bin/mlvwm-alert b/bin/mlvwm-alert new file mode 100755 index 0000000..2a74dee --- /dev/null +++ b/bin/mlvwm-alert @@ -0,0 +1,10 @@ +#!/bin/sh + +# mlvwm-alert - Display an alert-style dialog with a message + +mlvwm-message \ + -center \ + -buttons "OK:0" \ + -default "OK" \ + -title "$1" \ + "$2" diff --git a/bin/mlvwm-confirm b/bin/mlvwm-confirm new file mode 100755 index 0000000..32fb8d4 --- /dev/null +++ b/bin/mlvwm-confirm @@ -0,0 +1,10 @@ +#!/bin/sh + +# mlvwm-confirm Display a confirmation-style dialog with a message + +mlvwm-message \ + -center \ + -buttons "Cancel:1,OK:0" \ + -default "OK" \ + -title "$1" \ + "$2" diff --git a/bin/mlvwm-message b/bin/mlvwm-message new file mode 100755 index 0000000..a62f2da --- /dev/null +++ b/bin/mlvwm-message @@ -0,0 +1,6 @@ +#!/bin/sh + +# mlvwm-message - Wrapper for gxmessage & xmessage + +_xmessage="$(which gxmessage >/dev/null 2>&1 && echo gxmessage || echo xmessage)" +$_xmessage "$@" diff --git a/bin/mlvwm-powerdown b/bin/mlvwm-powerdown index 21dd0bc..287824e 100755 --- a/bin/mlvwm-powerdown +++ b/bin/mlvwm-powerdown @@ -18,6 +18,10 @@ _unsupported() { exit 1 } +_confirm() { + mlvwm-confirm "${1}" "Are you sure you want to $(echo "${1}" | tr "[:upper:]" "[:lower:]") your computer?" +} + _sleep_now() { case "$os" in "OpenBSD") @@ -32,7 +36,7 @@ _sleep_now() { _reboot_now() { case "$os" in "OpenBSD"|"FreeBSD"|"Linux") - shutdown -r now + _confirm "Restart" && shutdown -r now ;; *) _unsupported "reboot" @@ -43,10 +47,10 @@ _reboot_now() { _poweroff_now() { case "$os" in "OpenBSD"|"FreeBSD") - shutdown -p now + _confirm "Shut Down" && shutdown -p now ;; "Linux") - shutdown -P now + _confirm "Shut Down" && shutdown -P now ;; *) _unsupported "power off"