diff options
| author | jdlugosz963 <jdlugosz963@gmail.com> | 2024-03-15 17:47:12 +0100 |
|---|---|---|
| committer | jdlugosz963 <jdlugosz963@gmail.com> | 2024-03-15 17:52:24 +0100 |
| commit | 9ca1ae3ceca5944765af94514e75a96195de5716 (patch) | |
| tree | 7bf23d941af63b33b825f6a8facbaeb1f9600723 | |
| parent | 51445ea1df553dabf0471750e914c53cc8d9329c (diff) | |
| download | dotfiles-9ca1ae3ceca5944765af94514e75a96195de5716.tar.gz dotfiles-9ca1ae3ceca5944765af94514e75a96195de5716.zip | |
Add stumpish.
| -rwxr-xr-x | .bin/stumpish | 196 | ||||
| -rw-r--r-- | .config/guix/.gitignore | 2 | ||||
| -rw-r--r-- | .config/guix/manifests/desktop.scm | 2 | ||||
| -rw-r--r-- | .stumpwm.d/.gitignore | 1 |
4 files changed, 200 insertions, 1 deletions
diff --git a/.bin/stumpish b/.bin/stumpish new file mode 100755 index 0000000..9e95c0c --- /dev/null +++ b/.bin/stumpish | |||
| @@ -0,0 +1,196 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Copyright (C) 2007 Jonathan Moore Liles | ||
| 4 | # | ||
| 5 | # Maintainer: Jonathan Moore Liles | ||
| 6 | # | ||
| 7 | # stumpish is free software; you can redistribute it and/or modify | ||
| 8 | # it under the terms of the GNU General Public License as published by | ||
| 9 | # the Free Software Foundation; either version 2, or (at your option) | ||
| 10 | # any later version. | ||
| 11 | # | ||
| 12 | # stumpish is distributed in the hope that it will be useful, | ||
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | # GNU General Public License for more details. | ||
| 16 | # | ||
| 17 | # You should have received a copy of the GNU General Public License | ||
| 18 | # along with this software; see the file COPYING. If not, see | ||
| 19 | # <http://www.gnu.org/licenses/>. | ||
| 20 | |||
| 21 | ### STUMPwm Interactive SHell. | ||
| 22 | |||
| 23 | DELAY=0.01 | ||
| 24 | |||
| 25 | if ! sleep $DELAY 2>/dev/null >&2 | ||
| 26 | then | ||
| 27 | DELAY=1 | ||
| 28 | fi | ||
| 29 | |||
| 30 | # replace -E with -r option for old versions of GNU sed | ||
| 31 | if ! sed -E 1p /dev/null 2>/dev/null; then | ||
| 32 | sed() { shift; command sed -r "$@"; } | ||
| 33 | fi | ||
| 34 | |||
| 35 | # parse C-style backslash sequences by default | ||
| 36 | if [ "$(echo -e foo)" = foo ]; then | ||
| 37 | echo() { builtin echo -e "$@"; } | ||
| 38 | fi | ||
| 39 | |||
| 40 | wait_result () | ||
| 41 | { | ||
| 42 | while true | ||
| 43 | do | ||
| 44 | RESULT=$(xprop -root -f STUMPWM_COMMAND_RESULT 8s \ | ||
| 45 | STUMPWM_COMMAND_RESULT 2>/dev/null | | ||
| 46 | sed -E 's/\\([[:digit:]]+)/\\0\1/g') | ||
| 47 | if echo "$RESULT" | grep -v -q 'not found.$' | ||
| 48 | then | ||
| 49 | break | ||
| 50 | fi | ||
| 51 | |||
| 52 | sleep $DELAY | ||
| 53 | done | ||
| 54 | |||
| 55 | xprop -root -remove STUMPWM_COMMAND_RESULT | ||
| 56 | |||
| 57 | if echo "$RESULT" | grep -q '= $' | ||
| 58 | then | ||
| 59 | return 0 | ||
| 60 | fi | ||
| 61 | |||
| 62 | echo "$RESULT" | | ||
| 63 | sed -E 's/[^"\\n]+"// | ||
| 64 | /^"[[:space:]]*$/d | ||
| 65 | s/(^|[^\\])\\n/\1\ | ||
| 66 | /g | ||
| 67 | s/\\(["\\n])/\1/g | ||
| 68 | s/\^([*[:digit:]]+|[Bbn])//g' | ||
| 69 | } | ||
| 70 | |||
| 71 | send_cmd () | ||
| 72 | { | ||
| 73 | local cmd="$1" | ||
| 74 | |||
| 75 | if [ "$cmd" = "stumpwm-quit" ] | ||
| 76 | then | ||
| 77 | cmd=quit | ||
| 78 | elif [ "$cmd" = "quit" ] | ||
| 79 | then | ||
| 80 | exit | ||
| 81 | fi | ||
| 82 | |||
| 83 | xprop -root -f STUMPWM_COMMAND 8s -set STUMPWM_COMMAND "$cmd" | ||
| 84 | |||
| 85 | wait_result | ||
| 86 | } | ||
| 87 | |||
| 88 | usage () | ||
| 89 | { | ||
| 90 | cat <<EOF | ||
| 91 | Usage: ${0##*/} [[-e|-r] command [args...]] | ||
| 92 | |||
| 93 | StumpIsh is the StumpWM shell. Use it to interact a running StumpWM | ||
| 94 | instance. When run from a terminal with no arguments, stumpish | ||
| 95 | accepts commands interactively and prints each result. If standard | ||
| 96 | input is a pipe, stumpish executes any number of commands and prints | ||
| 97 | the concatenated results. If the '-e' option and one argument are | ||
| 98 | given on the command line, stumpish reads any number of lines from | ||
| 99 | standard input and uses them as the argument to the named command. | ||
| 100 | Otherwise, if one or more arguments are provided on the command line, | ||
| 101 | the first is considered the name of the command to execute and the | ||
| 102 | remainder is concatenated to form the argument. | ||
| 103 | |||
| 104 | Example: | ||
| 105 | echo '(group-windows (current-group))' | ${0##*/} -e eval | ||
| 106 | EOF | ||
| 107 | exit 0; | ||
| 108 | } | ||
| 109 | |||
| 110 | warn () | ||
| 111 | { | ||
| 112 | { | ||
| 113 | tput md bold | ||
| 114 | tput AF setaf 1 | ||
| 115 | echo 'WARN:\c' | ||
| 116 | tput me sgr0 | ||
| 117 | echo " $*" | ||
| 118 | } >&2 | ||
| 119 | } | ||
| 120 | |||
| 121 | tput () | ||
| 122 | { | ||
| 123 | local cap1=$1 cap2=$2 | ||
| 124 | shift 2 | ||
| 125 | |||
| 126 | command tput $cap1 $@ 2>/dev/null || | ||
| 127 | command tput $cap2 $@ 2>/dev/null | ||
| 128 | } | ||
| 129 | |||
| 130 | READLINE=yes | ||
| 131 | |||
| 132 | if [ "x$1" = "x-r" ] | ||
| 133 | then | ||
| 134 | READLINE=no | ||
| 135 | shift 1 | ||
| 136 | fi | ||
| 137 | |||
| 138 | if [ $# -gt 0 ] | ||
| 139 | then | ||
| 140 | [ "$1" = "--help" ] && usage | ||
| 141 | if [ "$1" = "-e" ] | ||
| 142 | then | ||
| 143 | if [ $# -ne 2 ] | ||
| 144 | then | ||
| 145 | echo "'-e' requires exactly one argument!" | ||
| 146 | exit | ||
| 147 | fi | ||
| 148 | shift 1 | ||
| 149 | IFS='' | ||
| 150 | ARGS=$(cat /dev/stdin) | ||
| 151 | send_cmd "$1 $ARGS" | ||
| 152 | else | ||
| 153 | IFS=' ' | ||
| 154 | send_cmd "$*" | ||
| 155 | fi | ||
| 156 | else | ||
| 157 | if [ -t 0 ] | ||
| 158 | then | ||
| 159 | if ! type rlwrap 2>/dev/null >&2 | ||
| 160 | then | ||
| 161 | warn rlwrap not found, command completion won\'t work | ||
| 162 | elif [ $READLINE = yes ] | ||
| 163 | then | ||
| 164 | COMMANDS="${TMPDIR:-/tmp}/stumpish.commands.$$" | ||
| 165 | echo $(send_cmd "commands") | | ||
| 166 | sed -E 's/[[:space:]]+/\ | ||
| 167 | /g' | | ||
| 168 | sort > "$COMMANDS" | ||
| 169 | trap 'rm -f "$COMMANDS"' exit int term | ||
| 170 | rlwrap -b '' -f "$COMMANDS" "$0" -r | ||
| 171 | exit | ||
| 172 | fi | ||
| 173 | |||
| 174 | tput AF setaf 5 | ||
| 175 | echo Welcome to the STUMPwm Interactive SHell. | ||
| 176 | tput me sgr0 | ||
| 177 | echo 'Type \c' | ||
| 178 | tput AF setaf 2 | ||
| 179 | echo 'commands\c' | ||
| 180 | tput me sgr0 | ||
| 181 | echo \ for a list of commands. | ||
| 182 | |||
| 183 | while read -p '> ' REPLY | ||
| 184 | do | ||
| 185 | tput md bold | ||
| 186 | tput AF setaf 2 | ||
| 187 | send_cmd "$REPLY" | ||
| 188 | tput me sgr0 | ||
| 189 | done | ||
| 190 | else | ||
| 191 | while read REPLY | ||
| 192 | do | ||
| 193 | send_cmd "$REPLY" | ||
| 194 | done | ||
| 195 | fi | ||
| 196 | fi | ||
diff --git a/.config/guix/.gitignore b/.config/guix/.gitignore index 46db10f..1f4ddec 100644 --- a/.config/guix/.gitignore +++ b/.config/guix/.gitignore | |||
| @@ -1 +1 @@ | |||
| current/ \ No newline at end of file | current \ No newline at end of file | ||
diff --git a/.config/guix/manifests/desktop.scm b/.config/guix/manifests/desktop.scm index 8b8ca1f..f238951 100644 --- a/.config/guix/manifests/desktop.scm +++ b/.config/guix/manifests/desktop.scm | |||
| @@ -65,6 +65,8 @@ | |||
| 65 | "xss-lock" | 65 | "xss-lock" |
| 66 | "libinput" | 66 | "libinput" |
| 67 | "xinput" | 67 | "xinput" |
| 68 | "xprop" | ||
| 69 | "rlwrap" | ||
| 68 | 70 | ||
| 69 | "nheko" | 71 | "nheko" |
| 70 | "quassel" | 72 | "quassel" |
diff --git a/.stumpwm.d/.gitignore b/.stumpwm.d/.gitignore new file mode 100644 index 0000000..4c478cf --- /dev/null +++ b/.stumpwm.d/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| stumpwm.log* \ No newline at end of file | |||
