1
0
This commit is contained in:
dtb 2022-05-14 20:42:46 -04:00
commit 9760f41d4f
3 changed files with 128 additions and 0 deletions

24
displaym/LICENSE Normal file
View File

@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>

59
displaym/README.md Normal file
View File

@ -0,0 +1,59 @@
# displaym
A dirt-simple window manager manager using shellscript.
## Dependencies
### POSIX
- mkdir(1)
- printf(1)
- sh(1)
- test(1)
### Non-POSIX
- bak(1)
## Design
It's encouraged to read the `displaym` source *rather than* this documentation, as the script is quite simple.
Usage: `displaym [WM] [action]`
`[WM]` refers to the folder in which `[action].sh` is stored.
`[action].sh` is sourced within `displaym`, which is a script executed by `sh(1)`.
On systems where Bash acts as the system's POSIX-compatible shell you may be able to use Bashisms within displaym actions but this isn't recommended.
The environment variable `$DISPLAYM_CONFIG` refers to the location of the displaym configuration directory; this is the directory that contains `[WM]/[action].sh`.
If `$DISPLAYM_CONFIG` is already set, it's not overriden.
The default location, if `$XDG_CONFIG_HOME` is set, is `$XDG_CONFIG_HOME/displaym`.
Otherwise, the default location is `$HOME/.displaym`.
If `$HOME` isn't set this will make the default displaym configuration directory location `/.displaym`.
Typically a `[WM]` folder will contain a `start.sh` and `stop.sh`, so (for example) the user may execute `displaym i3 start` to "start" the exemplary window manager i3.
Both the window manager name and action name are arbitrary, and use is not limited to the realm of window manager management, it just happens to be well suited to the application.
`displaym` could be renamed to `remotem` and the user could run `remotem [CITY] [COMPUTER]` to remote into a known computer in a known city.
Here's an example `bspwm/start.sh`:
```sh
#!/bin/sh
# start bspwm
# combine base sxhkd (keyboard daemon) config and bspwm-specifc config, output
# to the proper place
[ -n "$SXHKD_CONFIG ] || SXHKD_CONFIG="$HOME/.config/sxhkd/sxhkdrc"
cat "$DISPLAYM_CONFIG/sxhkdrc" "$DISPLAYM_CONFIG/$WM/sxhkdrc" >"$SXHKD_CONFIG"
# combine base .xinitrc (X initialization run-commands) and bspwm-specific
# .xinitrc, output to the proper place
cat "$DISPLAYM_CONFIG/.xinitrc" "$DISPLAYM_CONFIG/$WM/.xinitrc" >"$HOME/.xinitrc"
# start X
startx
```
Because the `[action].sh` is sourced from `displaym`, a number of useful environment variables are already set:
`$DISPLAYM_CONFIG`, `$WM`, and `$SCRIPT` (which refers to the `[action]`).

45
displaym/displaym Executable file
View File

@ -0,0 +1,45 @@
#!/bin/sh
set -e
argv0="$0"
error(){
printf "%s: %s\n" "$argv0" "$1" 1>&2
exit $2
}
usage(){
set +x
printf "\
Usage:
%s [window manager] [action]\n" "$argv0" 1>&2
exit 64 # sysexits(3) EX_USAGE
}
[ -n "$2" ] \
|| usage
# sysexits(3) EX_OSERR
[ -n "$HOME" ] \
|| error "No \$HOME environment variable set. This is very bad." 71
if [ -z "$DISPLAYM_CONFIG" ]; then
[ -z "$XDG_CONFIG_HOME" ] \
&& DISPLAYM_CONFIG="$HOME/.displaym" \
|| DISPLAYM_CONFIG="$XDG_CONFIG_HOME/displaym"
fi
export DISPLAYM_CONFIG
[ -e "$DISPLAYM_CONFIG" ] && ! [ -d "$DISPLAYM_CONFIG" ] \
&& bak "$DISPLAYM_CONFIG" \
|| true
[ -d "$DISPLAYM_CONFIG" ] \
|| mkdir -p "$DISPLAYM_CONFIG"
WM="$1"; export WM
SCRIPT="$2"
# with exported DISPLAYM_CONFIG and WM
sh <"$DISPLAYM_CONFIG/$WM/$SCRIPT.sh"