some cleanup, there's still lots to do but its an improvement
This commit is contained in:
parent
88c258c472
commit
f7227d6d06
|
@ -8,46 +8,26 @@ case "$RUNLAUNCHER" in
|
|||
"") RUNLAUNCHER=dmenu ;;
|
||||
esac
|
||||
|
||||
# assume we have grid as default
|
||||
HAVE_GRID="true"
|
||||
|
||||
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
|
||||
. $HOME/.config/speedwm/globalrc
|
||||
echo "Loaded configuration!"
|
||||
else
|
||||
printf "HAVE_GRID=$HAVE_GRID # Whether or not to use the Grid argument. If you do not have the dmenu grid patch, set this to false. Doing so will disable grid." > $HOME/.config/speedwm/globalrc
|
||||
fi
|
||||
|
||||
# grid number is one
|
||||
if [ "$HAVE_GRID" = "true" ]; then
|
||||
GRIDNUM="1"
|
||||
fi
|
||||
|
||||
# grid argument
|
||||
if [ "$HAVE_GRID" = "true" ]; then
|
||||
GRIDARG="-g"
|
||||
fi
|
||||
|
||||
# create applist
|
||||
MK_APPLIST() {
|
||||
if [ -e "$HOME/.local/share/speedwm/applist" ]; then
|
||||
USER_CMD="$(printf "$(cat $HOME/.local/share/speedwm/applist)\n------\nAdd command\nRemove command\nClear\n" | $RUNLAUNCHER -l 20 -p 'Run:' $GRIDARG $GRIDNUM)"
|
||||
USER_CMD="$(printf "%s\n------\nAdd command\nRemove command\nClear\n" "$(cat "$HOME/.local/share/speedwm/applist")" | $RUNLAUNCHER -l 20 -p 'Run:' -g 0)"
|
||||
else
|
||||
mkdir -p $HOME/.local/share/speedwm
|
||||
echo "No commands added." > $HOME/.local/share/speedwm/applist
|
||||
mkdir -p "$HOME/.local/share/speedwm"
|
||||
echo "No commands added." > "$HOME/.local/share/speedwm/applist"
|
||||
$0 && exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# remove commands
|
||||
REMOVE_CMD() {
|
||||
USER_CMD="$(printf "$(cat $HOME/.local/share/speedwm/applist)\n------\nAdd command\nRemove command\nClear\n" | $RUNLAUNCHER -l 20 -p 'Remove: ' $GRIDARG $GRIDNUM)"
|
||||
USER_CMD="$(printf "%s\n------\nAdd command\nRemove command\nClear\n" "$(cat "$HOME/.local/share/speedwm/applist")" | $RUNLAUNCHER -l 20 -p 'Remove: ' -g 0)"
|
||||
|
||||
if [ "$(cat $HOME/.local/share/speedwm/applist | wc -l)" -lt "2" ]; then
|
||||
rm -f $HOME/.local/share/speedwm/applist
|
||||
if [ "$(wc -l < "$HOME/.local/share/speedwm/applist")" -lt "2" ]; then
|
||||
rm -f "$HOME/.local/share/speedwm/applist"
|
||||
else
|
||||
grep -v "$USER_CMD" $HOME/.local/share/speedwm/applist | sed ':a;N;$!ba;s/\n//g' > /tmp/applist
|
||||
mv /tmp/applist $HOME/.local/share/speedwm/applist
|
||||
grep -v "$USER_CMD" "$HOME/.local/share/speedwm/applist" | sed ':a;N;$!ba;s/\n//g' > "/tmp/applist"
|
||||
mv "/tmp/applist" "$HOME/.local/share/speedwm/applist"
|
||||
fi
|
||||
|
||||
$0 && exit 0
|
||||
|
@ -57,7 +37,7 @@ REMOVE_CMD() {
|
|||
# clear commands
|
||||
CLEAR_CMD() {
|
||||
case "$(printf "Yes\nNo\n" | $RUNLAUNCHER -l 2 -p 'Are you sure?')" in
|
||||
"Yes") rm -f $HOME/.local/share/speedwm/applist ;;
|
||||
"Yes") rm -f "$HOME/.local/share/speedwm/applist" ;;
|
||||
esac
|
||||
|
||||
$0 && exit 0
|
||||
|
@ -66,9 +46,9 @@ CLEAR_CMD() {
|
|||
|
||||
# add command
|
||||
ADD_CMD() {
|
||||
grep -q "No commands added" $HOME/.local/share/speedwm/applist && rm -f $HOME/.local/share/speedwm/applist
|
||||
USER_I_ARG="$(printf "" | $RUNLAUNCHER -l 0 -p 'Enter a command:' $GRIDARG $GRIDNUM)"
|
||||
printf "$USER_I_ARG\n" >> $HOME/.local/share/speedwm/applist
|
||||
grep -q "No commands added" "$HOME/.local/share/speedwm/applist" && rm -f "$HOME/.local/share/speedwm/applist"
|
||||
USER_I_ARG="$(printf "" | $RUNLAUNCHER -l 0 -p 'Enter a command:' -g 0)"
|
||||
printf "%s\n" "$USER_I_ARG" >> "$HOME/.local/share/speedwm/applist"
|
||||
$0 && exit 0
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# Requires pactl for pulseaudio/pipewire or amixer for alsa
|
||||
# Additionally requires pulsemixer for pulseaudio/pipewire or alsamixer for alsa if the mixer functionality is used
|
||||
|
||||
BINDIR="$(dirname $(command -v speedwm-core))/"
|
||||
BINDIR="$(dirname $(command -v speedwm-audioctrl))/"
|
||||
|
||||
MUTE() {
|
||||
# Mute for pulseaudio/pipewire
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/bin/sh
|
||||
# speedwm-core
|
||||
# this script is used to run stuff
|
||||
|
||||
BINDIR="$(dirname $(command -v speedwm-core))/"
|
||||
# basically useless, only here for compatibility reasons
|
||||
|
||||
case "$1" in
|
||||
"-curl-weather") clear ; curl -s wttr.in | head -n 38 | tail -n 37 && read a ;;
|
||||
|
|
|
@ -7,28 +7,6 @@ case "$RUNLAUNCHER" in
|
|||
"") RUNLAUNCHER=dmenu # Run launcher to use (dmenu, rofi, etc.) ;;
|
||||
esac
|
||||
|
||||
HAVE_GRID="true"
|
||||
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
|
||||
. $HOME/.config/speedwm/globalrc
|
||||
else
|
||||
|
||||
printf "HAVE_GRID=$HAVE_GRID # Whether or not to use the Grid argument. If you do not have the dmenu grid patch, set this to false. Doing so will disable grid." > $HOME/.config/speedwm/globalrc
|
||||
fi
|
||||
|
||||
if [ "$HAVE_GRID" = "true" ]; then
|
||||
GRIDNUM="1"
|
||||
fi
|
||||
|
||||
if [ "$HAVE_GRID" = "true" ]; then
|
||||
GRIDARG="-g"
|
||||
fi
|
||||
|
||||
VARS() {
|
||||
BINDIR="$(dirname $(command -v speedwm-core))/"
|
||||
}
|
||||
|
||||
VARS
|
||||
|
||||
GENERAL() {
|
||||
case "$(printf "mfact +\nmfact -\nToggle Sticky\nToggle Bar\nToggle Fullscreen\nReset Layout/mfact\nReorganize Tags" | $RUNLAUNCHER -l 20 -p 'What do you want to do?')" in
|
||||
"mfact +") libspeedwm --perform tiling_mfact_inc ;;
|
||||
|
@ -42,12 +20,12 @@ GENERAL() {
|
|||
}
|
||||
|
||||
OPT() {
|
||||
MENUOPTS=$(printf "Layout\nReload .Xresources\nGeneral\nExit" | $RUNLAUNCHER -l 20 -p 'What do you want to do?')
|
||||
MENUOPTS=$(printf "Layout\nReload .Xresources\nGeneral\nExit" | ${RUNLAUNCHER} -l 20 -p 'What do you want to do?')
|
||||
|
||||
case "$MENUOPTS" in
|
||||
"Layout") ${0} layout $2 && exit 0 ;;
|
||||
"Layout") ${0} layout "${2}" && exit 0 ;;
|
||||
"Reload .Xresources") ${0} reloadcolors && exit 0 ;;
|
||||
"General") ${0} general $2 && exit 0 ;;
|
||||
"General") ${0} general "${2}" && exit 0 ;;
|
||||
"Exit") exit 0 ;;
|
||||
esac
|
||||
}
|
||||
|
@ -76,41 +54,51 @@ L12="$(printf "L12: Grid (Horizontal)\n")"
|
|||
L13="$(printf "L13: Dynamic Grid\n")"
|
||||
L14="$(printf "L14: Custom\n")"
|
||||
L15="$(printf "L15: Empty\n")"
|
||||
EXIT="Exit"
|
||||
SEPARATOR="------"
|
||||
LNEXT="Next Layout"
|
||||
LPREV="Previous Layout"
|
||||
SEXP="Enter S expression"
|
||||
|
||||
case "$1" in
|
||||
"layout") SEL_LAYOUT=$(printf "${L1}\n${L2}\n${L3}\n${L4}\n${L5}\n${L6}\n${L7}\n${L8}\n${L9}\n${L10}\n${L11}\n${L12}\n${L13}\n${L14}\n${L15}\nPrevious Layout\nNext Layout\nEnter S expression" | $RUNLAUNCHER -l 21 -p "Pick a layout: ") ;;
|
||||
"layout") SEL_LAYOUT=$(printf "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s" \
|
||||
"${L1}" "${L2}" "${L3}" "${L4}" "${L5}" "${L6}" "${L7}" "${L8}" "${L9}" "${L10}" "${L11}" "${L12}" "${L13}" "${L14}" "${L15}" "${LNEXT}" "${LPREV}" "${SEXP}" "${SEPARATOR}" "${EXIT}" | $RUNLAUNCHER -l 21 -p "Pick a layout: ") ;;
|
||||
"reloadcolors") libspeedwm --perform core_wm_reload ;;
|
||||
"list") head -n "$(expr "$(cat /usr/share/speedwm/example.signal | wc -l)" - 1)" /usr/share/speedwm/example.signal ;;
|
||||
"list") head -n -1 /usr/share/speedwm/example.signal ;;
|
||||
"help") HELP ;;
|
||||
"exec")
|
||||
if [ "$2" = "" ]; then
|
||||
exit 0
|
||||
else
|
||||
libspeedwm --rsig $2
|
||||
libspeedwm --rsig "$2"
|
||||
fi ;;
|
||||
"h") HELP ;;
|
||||
"general") GENERAL ;;
|
||||
"") OPT ;;
|
||||
"") OPT "$@" ;;
|
||||
esac
|
||||
|
||||
case "$SEL_LAYOUT" in
|
||||
"Exit") exit 0 ;;
|
||||
"Previous Layout") libspeedwm --perform layout_cycle_down;;
|
||||
"Next Layout") libspeedwm --perform layout_cycle_up ;;
|
||||
"L1: Tiling") libspeedwm --perform layout_setlayout_tile ;;
|
||||
"L2: Floating") libspeedwm --perform layout_setlayout_float ;;
|
||||
"L3: Monocle") libspeedwm --perform layout_setlayout_monocle ;;
|
||||
"L4: Grid") libspeedwm --perform layout_setlayout_grid ;;
|
||||
"L5: Deck") libspeedwm --perform layout_setlayout_deck ;;
|
||||
"L6: Centered Master") libspeedwm --perform layout_setlayout_cm ;;
|
||||
"L7: Tatami") libspeedwm --perform layout_setlayout_tatami ;;
|
||||
"L8: Dwindle") libspeedwm --perform layout_setlayout_dwindle ;;
|
||||
"L9: Spiral") libspeedwm --perform layout_setlayout_spiral ;;
|
||||
"L10: Bottom Stack (Vertical)") libspeedwm --perform layout_setlayout_bs ;;
|
||||
"L11: Bottom Stack (Horizontal)") libspeedwm --perform layout_setlayout_hbs ;;
|
||||
"L12: Grid (Horizontal)") libspeedwm --perform layout_setlayout_hgrid ;;
|
||||
"L13: Dynamic Grid") libspeedwm --perform layout_setlayout_dgrid ;;
|
||||
"L14: Custom") libspeedwm --perform layout_setlayout_custom ;;
|
||||
"L15: Empty") libspeedwm --perform layout_setlayout_empty ;;
|
||||
"Enter S expression") libspeedwm --perform layout_custom_express ;;
|
||||
"${EXIT}") exit 0 ;;
|
||||
"${LPREV}") libspeedwm --perform layout_cycle_down; exit ;;
|
||||
"${LNEXT}") libspeedwm --perform layout_cycle_up; exit ;;
|
||||
"${L1}") libspeedwm --perform layout_setlayout_tile; CURLT="${L1}" ;;
|
||||
"${L2}") libspeedwm --perform layout_setlayout_float; CURLT="${L2}" ;;
|
||||
"${L3}") libspeedwm --perform layout_setlayout_monocle; CURLT="${L3}" ;;
|
||||
"${L4}") libspeedwm --perform layout_setlayout_grid; CURLT="${L4}" ;;
|
||||
"${L5}") libspeedwm --perform layout_setlayout_deck; CURLT="${L5}" ;;
|
||||
"${L6}") libspeedwm --perform layout_setlayout_cm; CURLT="${L6}" ;;
|
||||
"${L7}") libspeedwm --perform layout_setlayout_tatami; CURLT="${L7}" ;;
|
||||
"${L8}") libspeedwm --perform layout_setlayout_dwindle; CURLT="${L8}" ;;
|
||||
"${L9}") libspeedwm --perform layout_setlayout_spiral; CURLT="${L9}" ;;
|
||||
"${L10}") libspeedwm --perform layout_setlayout_bs; CURLT="${L10}" ;;
|
||||
"${L11}") libspeedwm --perform layout_setlayout_hbs; CURLT="${L11}" ;;
|
||||
"${L12}") libspeedwm --perform layout_setlayout_hgrid; CURLT="${L12}" ;;
|
||||
"${L13}") libspeedwm --perform layout_setlayout_dgrid; CURLT="${L13}" ;;
|
||||
"${L14}") libspeedwm --perform layout_setlayout_custom; CURLT="${L14}" ;;
|
||||
"${L15}") libspeedwm --perform layout_setlayout_empty; CURLT="${L15}" ;;
|
||||
"Enter S expression") libspeedwm --perform layout_custom_express; exit ;;
|
||||
esac
|
||||
|
||||
[ -n "${CURLT}" ] && command -v notify-send > /dev/null && notify-send "Layout" "${CURLT}"
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue