add sxp script

This commit is contained in:
speedie 2023-02-04 12:33:13 +01:00
parent c9dec7cd27
commit 0cab0629dc
3 changed files with 26 additions and 2 deletions

View file

@ -224,7 +224,7 @@ speedwm.layout.monocle.count: 0 ! Enable focused client and number of t
speedwm.layout.monocle.format: [%d/%d] speedwm.layout.monocle.format: [%d/%d]
!! Custom layout !! Custom layout
speedwm.layout.custom.cmd: printf '' | spmenu -i -l 10 -p 'Enter S expression:' speedwm.layout.custom.cmd: speedwm-sxp
!! mfact options !! mfact options
speedwm.mfact: 0.50 ! Default mfact (0-1) speedwm.mfact: 0.50 ! Default mfact (0-1)

View file

@ -153,7 +153,7 @@ static int deckcount = 0; /* Display deck count in the deck layout */
static char deckformat[] = "[%d]"; /* Format of the deck count. deckcount must be set to 1 for this to be used. */ static char deckformat[] = "[%d]"; /* Format of the deck count. deckcount must be set to 1 for this to be used. */
/* Custom layout */ /* Custom layout */
static char *custom_cmd = "printf '' | spmenu -i -l 10 -p 'Enter S expression:'"; /* Command to run when setting S expression */ static char *custom_cmd = "speedwm-sxp"; /* Command to run when setting S expression */
/* Resetting */ /* Resetting */
static int resetlayout = 0; /* Reset layout when there is only one client visible */ static int resetlayout = 0; /* Reset layout when there is only one client visible */

24
scripts/speedwm-sxp Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh
# speedwm-sxp
# function which returns history
MENU_DATA() { cat "$CUSTOM_HISTFILE"; printf "%s\nClear\nExit\n" "------"; }
# basic variables
[ -z "$CUSTOM_HISTFILE" ] && CUSTOM_HISTFILE="$HOME/.config/speedwm/.custom_history"
[ -z "$RUNLAUNCHER" ] && RUNLAUNCHER="spmenu"
# make sure $CUSTOM_HISTFILE exists
mkdir -p "$(dirname "$CUSTOM_HISTFILE")"; touch "$CUSTOM_HISTFILE"
# prompt the user
OP="$(MENU_DATA | "$RUNLAUNCHER" -g 1 -l 40 -p 'Enter an S expression:')"
# parse current expression
[ "$OP" = "Clear" ] && printf "" > "$CUSTOM_HISTFILE" && exit
[ "$OP" = "Exit" ] && exit 0
[ "$OP" = "------" ] && exit 0
[ -z "$OP" ] && exit 0
# write expression
printf "%s\n" "$OP" >> "$CUSTOM_HISTFILE"