structure
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
# 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]`).
|
||||
@@ -1,45 +0,0 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user