167 lines
5 KiB
Bash
Executable file
167 lines
5 KiB
Bash
Executable file
#!/bin/sh
|
|
# speedwm_run
|
|
# External script which starts speedwm!
|
|
# https://speedie.gq/speedwm for instructions and usage!
|
|
|
|
ARGS=$1
|
|
|
|
# No second argument is supported
|
|
if [ "$2" != "" ]; then
|
|
echo "Unknown argument: $2" ; exit 1
|
|
fi
|
|
|
|
HAVE_GRID="true"
|
|
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
|
|
. $HOME/.config/speedwm/globalrc
|
|
else
|
|
mkdir -p $HOME/.config/speedwm
|
|
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
|
|
|
|
# Don't make config if asked not to.
|
|
if [ -e "$HOME/.local/share/speedwm/do-not-mkconfig" ]; then
|
|
DONOTMKCONFIG=true
|
|
else
|
|
DONOTMKCONFIG=false
|
|
fi
|
|
|
|
# Load .Xresources if available
|
|
XRESOURCES() {
|
|
if [ -e "$HOME/.Xresources" ]; then
|
|
if command -v xrdb > /dev/null; then
|
|
xrdb $HOME/.Xresources
|
|
fi
|
|
elif [ -e "$HOME/.config/.Xresources" ]; then
|
|
if command -v xrdb > /dev/null; then
|
|
xrdb $HOME/.config/.Xresources
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Load speedwm config, create if it does not exist.
|
|
LOADCONFIG() {
|
|
mkdir -p $HOME/.config/speedwm
|
|
if command -v xrdb > /dev/null; then
|
|
if [ "$DONOTMKCONFIG" = "false" ]; then
|
|
if [ -e "$HOME/.config/speedwm/speedwmrc" ]; then
|
|
xrdb -merge -quiet $HOME/.config/speedwm/speedwmrc
|
|
else
|
|
test /usr/share/speedwm/example.Xresources && sed "s| - ||g; s|!@||g" /usr/share/speedwm/example.Xresources > $HOME/.config/speedwm/speedwmrc && echo "Wrote example configuration file"
|
|
fi
|
|
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Load wallpaper config
|
|
LOADSWAL() {
|
|
if [ "$DONOTLOADCONFIG" = "true" ]; then
|
|
DONOTLOADCONFIG=true
|
|
else
|
|
if [ -e "$HOME/.config/speedwm/swal/swal_wm" ]; then
|
|
$HOME/.config/speedwm/swal/swal_wm > /dev/null
|
|
echo "Loaded wallpaper and pywal colors"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Load colors
|
|
LOADCOLS() {
|
|
if [ "$DONOTLOADCONFIG" = "true" ]; then
|
|
DONOTLOADCONFIG=true
|
|
else
|
|
speedwm -s "#cmd:65" # reload colors
|
|
speedwm -s "Loading" # hide ugly signal
|
|
echo "Loaded colors"
|
|
fi
|
|
}
|
|
|
|
# Autostart
|
|
AUTOSTART() {
|
|
if [ -e "$HOME/.config/speedwm/autostart_once.sh" ]; then
|
|
$HOME/.config/speedwm/autostart_once.sh
|
|
fi
|
|
}
|
|
|
|
# Reset speedwm
|
|
RESET() {
|
|
if [ "$DONOTRELOAD" = "true" ]; then
|
|
DONOTRELOAD=true
|
|
else
|
|
speedwm -s "Loading" # To hide the ugly fsignal status
|
|
speedwm -s "#cmd:27" # Send fsignal to restart speedwm
|
|
speedwm -s "" # To hide the ugly fsignal status
|
|
fi
|
|
}
|
|
|
|
# Start speedwm itself
|
|
START_SPEEDWM() {
|
|
if [ "$ISSFLAG" = "" ]; then
|
|
while true; do
|
|
speedwm > /tmp/speedwm-log || exit
|
|
done
|
|
fi
|
|
}
|
|
|
|
# List of arguments
|
|
HELP() {
|
|
printf "speedwm\nNo arguments | Start speedwm using default options\n\
|
|
-s | Start speedwm using either sx or startx. This does not require you to use a .xinitrc file. Simply install xinit/sx and run speedwm -s\n\
|
|
-f | Start speedwm bypassing all checks (such as whether or not a window manager is running)\n\
|
|
-noxrdb | Start speedwm without loading colors.\n\
|
|
-nomkconfig | Start speedwm without creating a config file (or loading it)\n\
|
|
-h | View this list of arguments\n\
|
|
-r | Restart speedwm and reload colors\n\
|
|
-loadconfig | Load and create config if it does not exist\n\
|
|
-unloadconfig | Unload the speedwm configuration\n\
|
|
-deleteconfig | Delete the speedwm configuration\n\
|
|
-rnoload | Restart speedwm without reloading colors\n\
|
|
-configure | Bring up a list of speedwm dotfiles in $RUNLAUNCHER and ask the user which one to open in \$EDITOR inside \$TERMINAL\n"
|
|
}
|
|
|
|
# Unload speedwm configuration
|
|
UNLOADCONFIG() {
|
|
if command -v xrdb > /dev/null; then
|
|
xrdb -remove speedwm* && echo "Unloaded configuration"
|
|
else
|
|
echo "Unable to unload configuration" ; exit 1
|
|
fi
|
|
}
|
|
|
|
# Delete speedwm configuration
|
|
DELETECONFIG() {
|
|
if [ -e "$HOME/.config/speedwm/speedwmrc" ]; then
|
|
rm -f $HOME/.config/speedwm/speedwmrc && echo "Deleted $HOME/.config/speedwm/speedwmrc."
|
|
else
|
|
echo "Failed to delete configuration file." ; exit 1
|
|
fi
|
|
}
|
|
|
|
case "$ARGS" in
|
|
"") XRESOURCES ; AUTOSTART ; LOADSWAL ; LOADCONFIG ; RESET ; START_SPEEDWM ; exit 0 ;;
|
|
"-s") ISSFLAG=true ; XRESOURCES ; AUTOSTART ; LOADSWAL ; LOADCONFIG ; RESET ; START_SPEEDWM ; exit 0 ;;
|
|
"-r") XRESOURCES ; LOADSWAL ; LOADCONFIG ; RESET ; echo "Restarted speedwm." ; exit 0 ;;
|
|
"-rcolors") XRESOURCES ; LOADSWAL ; LOADCONFIG ; LOADCOLS ; echo "Restarted speedwm." ; exit 0 ;;
|
|
"-rnoloadcolors") LOADCONFIG ; LOADCOLS ; echo "Restarted speedwm." ; exit 0 ;;
|
|
"-rnoload") RESET ; echo "Restarted speedwm." ; exit 0 ;;
|
|
"-h") HELP ; exit 0 ;;
|
|
"-f") CARG="force" ; XRESOURCES ; AUTOSTART ; LOADSWAL ; LOADCONFIG ; RESET ; START_SPEEDWM ; exit 0 ;;
|
|
"-loadconfig") LOADCONFIG ; exit 0 ;;
|
|
"-unloadconfig") UNLOADCONFIG ; RESET ; exit 0 ;;
|
|
"-deleteconfig") DELETECONFIG ; RESET ; exit 0 ;;
|
|
"-noxrdb") START_SPEEDWM ; exit 0 ;;
|
|
"-stop") pgrep -x speedwm && pkill -x speedwm && echo "speedwm has been stopped." ; exit
|
|
echo "speedwm is not running, cannot stop it." ; exit 1 ;;
|
|
"-nomkconfig") XRESOURCES ; AUTOSTART ; LOADSWAL ; RESET ; START_SPEEDWM ; exit 0 ;;
|
|
esac
|
|
|
|
exit 0
|