Add everything

This commit is contained in:
speedie 2022-10-27 18:11:02 +02:00
parent b79028210a
commit ba1ab8fdf7
14 changed files with 3929 additions and 0 deletions

35
Makefile Normal file
View file

@ -0,0 +1,35 @@
# speedwm-extras // extra content for speedwm
# See LICENSE file for copyright and license details.
PREFIX = /usr
VERSION = 1.2
dist:
mkdir -p speedwm-extras-${VERSION}
cp -R Makefile LICENSE src speedwm-extras-${VERSION}
tar -cf speedwm-extras-${VERSION}.tar speedwm-extras-${VERSION}
gzip speedwm-extras-${VERSION}.tar
rm -rf speedwm-extras-${VERSION}
rm -rf speedwm-extras-${VERSION}
install:
mkdir -p ${DESTDIR}${PREFIX}/bin
mkdir -p ${DESTDIR}${PREFIX}/share/speedwm
cp -f src/speedwm* ${DESTDIR}${PREFIX}/bin ; chmod +x ${DESTDIR}${PREFIX}/bin/speedwm*
echo ${VERSION} > ${DESTDIR}${PREFIX}/share/speedwm/speedwm-version
uninstall:
rm -f ${DESTDIR}${PREFIX}/bin/speedwm
rm -rf ${DESTDIR}${PREFIX}/share/speedwm
help:
@echo -- speedwm-extras Makefile help --
@echo
@echo - Installation -
@echo install: Installs speedwm-extras. You may need to run this as root.
@echo uninstall: Uninstalls speedwm-extras. You may need to run this as root.
@echo
@echo - Releasing -
@echo dist to create a tarball.
.PHONY: dist install uninstall help

94
src/speedwm-applist Executable file
View file

@ -0,0 +1,94 @@
#!/bin/sh
# speedwm-applist
# list extra applications
# rl
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
mkdir -p $HOME/.config/speedwm/global
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)"
else
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)"
if [ "$(cat $HOME/.local/share/speedwm/applist | wc -l)" -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
fi
$0 && exit 0
}
# 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 ;;
esac
$0 && exit 0
}
# 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
$0 && exit 0
}
MK_APPLIST
# check user cmd
if [ "$USER_CMD" = "" ]; then
exit 0
else
if [ "$USER_CMD" = "Add command" ]; then
ADD_CMD
else
if [ "$USER_CMD" = "Clear" ]; then
CLEAR_CMD
else
if [ "$USER_CMD" = "Remove command" ]; then
REMOVE_CMD
else
$USER_CMD
fi
fi
fi
fi

142
src/speedwm-audioctrl Executable file
View file

@ -0,0 +1,142 @@
#!/bin/sh
# speedwm-audioctrl
# This simple shell script handles audio controls for speedwm.
# Run speedwm-audioctrl -help for more information!
# License: GPLv3.
BINDIR="$(dirname $(command -v speedwm-core))/"
MUTE() {
# Mute for pulseaudio/pipewire
if [ "$AUDIO" = "pulse" ]; then
if [ -e "${BINDIR}pactl" ]; then
pactl set-sink-mute 0 toggle
if [ -e "${BINDIR}notify-send" ]; then
if [ "$remute" = "" ]; then
notify-send " Toggled mute"
fi
fi
else
amixer set Master toggle
if [ -e "${BINDIR}notify-send" ]; then
if [ "$remute" = "" ]; then
notify-send " Toggled mute"
fi
fi
fi
fi
}
RAISE() {
if [ "$AUDIO" = "pulse" ]; then
if [ -e "${BINDIR}pactl" ]; then
if [ "$(pactl get-sink-volume 0 | awk '{ print $5;exit }' | sed 's/%//g')" -gt "100" ]; then
pactl set-sink-volume 0 100%
else
pactl set-sink-volume 0 +10%
test ${BINDIR}notify-send && notify-send " $(pactl get-sink-volume 0 | awk '{ print $5;exit }')"
fi
fi
else
if [ "$(amixer -c 0 get Master | tail -n 1 | sed -r "s/.*\[(.*)%\].*/\1/")" = "100" ]; then
a=$a
else
amixer -c 0 set Master 7%+
ls ${BINDIR}notify-send && notify-send " $(amixer -c 0 get Master | tail -n 1 | sed -r "s/.*\[(.*)%\].*/\1/")%"
fi
fi
}
LOWER() {
if [ "$AUDIO" = "pulse" ]; then
if [ -e "${BINDIR}pactl" ]; then
if [ "$(pactl get-sink-volume 0 | awk '{ print $5;exit }' | sed 's/%//g')" != "0" ]; then
pactl set-sink-volume 0 -10%
test ${BINDIR}notify-send && notify-send " $(pactl get-sink-volume 0 | awk '{ print $5;exit }')"
fi
fi
else
if [ "$(amixer -c 0 get Master | tail -n 1 | sed -r "s/.*\[(.*)%\].*/\1/")" = "0" ]; then
a=$a
else
amixer -c 0 set Master 7%-
test ${BINDIR}notify-send && notify-send " $(amixer -c 0 get Master | tail -n 1 | sed -r "s/.*\[(.*)%\].*/\1/")%"
fi
fi
}
GETVOL() {
if [ "$AUDIO" = "pulse" ]; then
if [ -e "${BINDIR}pactl" ]; then
pactl get-sink-volume 0 | awk '{ print $5;exit }'
fi
else
echo "$(amixer -c 0 get Master | tail -n 1 | sed -r "s/.*\[(.*)%\].*/\1/")%"
fi
}
GETMUTE() {
if [ "$AUDIO" = "pulse" ]; then
if [ -e "${BINDIR}pactl" ]; then
pactl get-sink-mute 0 | sed "s/Mute: //; s/no/Not muted/; s/yes/Muted/g"
fi
fi
}
SWITCH() {
ls $HOME/.local/share/audioctrl-status || echo "0" > $HOME/.local/share/audioctrl-status
if [ "$(cat $HOME/.local/share/audioctrl-status)" = "0" ]; then
amixer -c 0 sset 'Auto-Mute Mode' Enabled ; echo "1" > $HOME/.local/share/audioctrl-status
if [ -e "${BINDIR}notify-send" ]; then
notify-send " Switched to headphones."
fi
else
amixer -c 0 sset 'Auto-Mute Mode' Disabled ; echo "0" > $HOME/.local/share/audioctrl-status
if [ -e "${BINDIR}notify-send" ]; then
notify-send " Switched to speakers."
fi
fi
}
RUNMIXER() {
if [ "$AUDIO" = "pulse" ]; then
if [ -e "${BINDIR}pulsemixer" ]; then
pulsemixer
elif [ -e "${BINDIR}alsamixer" ]; then
alsamixer
fi
fi
}
AUDIO=$2
case "$2" in
"") AUDIO=alsa
if [ -e "${BINDIR}pulsemixer" ]; then
AUDIO=pulse
else
if [ -e "${BINDIR}pactl" ]; then
AUDIO=pulse
fi
fi
;;
esac
# Update status
UPDATESTATUS() {
pkill -x status && status &
}
case "$1" in
"-mute") MUTE && GETMUTE > /tmp/speedwm-audioctrl-mutestatus ;;
"-remute") remute=true ; MUTE && GETMUTE > /tmp/speedwm-audioctrl-mutestatus ; MUTE && GETMUTE > /tmp/speedwm-audioctrl-mutestatus ; remute="" ; exit 0 ;;
"-raise") RAISE ;;
"-lower") LOWER ;;
"-switch") SWITCH && exit 0 ;;
"-getvol") GETVOL && exit 0 ;;
"-getmute") GETMUTE > /tmp/speedwm-audioctrl-mutestatus && exit 0 ;;
"-getbackend") printf "$AUDIO\n" && exit 0 ;;
"-runmixer") RUNMIXER && exit 0 ;;
"-help") printf "speedwm-audioctrl\n-mute | Toggle mute\n-raise | Raise the volume by 7\n-lower | Lower the volume by 7\n-switch | Toggle output\n-getvol | Get current volume in percentage\n-getmute | Get mute status\n-getbackend | Get audio backend (ALSA, PulseAudio, etc.)\n-runmixer | Run the audio mixer detected on the system\n-remute | Mute and unmute.\n-help | Display this help screen\nNo arguments | Display this help screen\n"; exit 0 ;;
"") $0 -help && exit 0 ;;
esac

145
src/speedwm-btctrl Executable file
View file

@ -0,0 +1,145 @@
#!/bin/sh
# speedwm-btctrl
# Basic dmenu/other run launcher Bluetooth manager written for speedwm.
# Licensed under GNU GPLv3.
# Check stuff
CHECK() {
case "$RUNLAUNCHER" in
"") RUNLAUNCHER=dmenu ;;
esac
BINDIR="$(dirname $(command -v speedwm-core))/"
}
HAVE_GRID="true"
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
. $HOME/.config/speedwm/globalrc
else
mkdir -p $HOME/.config/speedwm/global
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
CHECK
# Help
HELP() {
printf "\n1. Turn on your device\n2. Make sure the bluetooth service is running. If it is not, start it.\n3. Press the pair button on your device\n4. Select your device in the list of devices. If it does not show up, select 'Refresh'.\n5. Select 'Pair' and then optionally 'Trust' to save it in the list of devices.\n6. And finally, select 'Connect' to connect the device." | $RUNLAUNCHER -l 12 $GRIDARG $GRIDNUM -p 'How to use'
$0 && exit 0
}
# Enable bluetooth and scan for devices
ENABLE_BT() {
bluetoothctl power on > /dev/null && echo "Power: On"
bluetoothctl scan on & # Start scanning for devices
bluetoothctl devices | grep -q "No default controller" && printf "No Bluetooth controller was found.\n" && exit 1
USEROPT_1="$(printf "$(bluetoothctl devices | cut -d\ -f3-)\n------\nRefresh\nHelp\nExit" | $RUNLAUNCHER -l 12 $GRIDARG $GRIDNUM -p "Select a device")"
# Check what to do
case "$USEROPT_1" in
"") exit 0 ;;
"Refresh") ENABLE_BT ;;
"Exit") exit 0 ;;
"Help") HELP && $0 && exit 0 ;;
esac
SELDEVICE_MAC="$(bluetoothctl devices | grep "$USEROPT_1$" | awk '{ print $2 }')"
echo "$SELDEVICE_MAC"
# Check if a MAC was grabbed
case "$SELDEVICE_MAC" in
"") echo "Could not get MAC" && exit 1 ;;
esac
}
ENABLE_BT
# List options for the device
LIST_OPTIONS() {
USEROPT_2="$(echo -e "-- Options --\nConnect\nDisconnect\n-- Toggle --\nPair\nRemove\nTrust\nUntrust\n--\nExit\nHelp" | sed "s/-e //g" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 20 -p "What do you want to do with this device?" | awk '{ print $1 }')"
}
LIST_OPTIONS
# Trust device
TRUST() {
bluetoothctl trust $SELDEVICE_MAC
}
# Pair device
PAIR() {
bluetoothctl pair $SELDEVICE_MAC
}
# Remove device
REMOVE() {
bluetoothctl remove $SELDEVICE_MAC
}
UNTRUST() {
bluetoothctl untrust $SELDEVICE_MAC
}
# Connect
CONNECT() {
if [ -e "$/tmp/isconnected" ]; then
NOTIFY_ALREADY_CONNECTED && exit 0
fi
bluetoothctl connect $SELDEVICE_MAC
touch /tmp/isconnected
}
# Disconnect
DISCONNECT() {
rm -f /tmp/isconnected
bluetoothctl disconnect $SELDEVICE_MAC
}
# Notification when connecting
NOTIFY_CONNECT() {
notify-send " Connected to ${USEROPT_1}!"
}
# Notification when disconnecting
NOTIFY_DISCONNECT() {
notify-send " Disconnected from ${USEROPT_1}!"
}
# Notification when removing
NOTIFY_REMOVE() {
notify-send " Removed ${USEROPT_1}!"
}
# Notification when already connected
NOTIFY_ALREADY_CONNECTED() {
notify-send " Device $USEROPT_1 is already connected!"
}
# Perform actions as per user choice
PERFORM() {
case "$USEROPT_2" in
"Trust") TRUST && LIST_OPTIONS ;;
"Pair") PAIR && LIST_OPTIONS ;;
"Connect") CONNECT && NOTIFY_CONNECT && LIST_OPTIONS ;;
"Disconnect") DISCONNECT && NOTIFY_DISCONNECT && LIST_OPTIONS ;;
"Untrust") UNTRUST && LIST_OPTIONS ;;
"Remove") REMOVE && NOTIFY_REMOVE && LIST_OPTIONS ;;
"Exit") exit 0 ;;
"Help") HELP ;;
"") exit 0 ;;
esac
}
PERFORM
$0 && exit 0

10
src/speedwm-core Executable file
View file

@ -0,0 +1,10 @@
#!/bin/sh
# speedwm-core
# This script handles the updating and other things necessary for keybinds.
BINDIR="$(dirname $(command -v speedwm-core))/"
OPT=$1
case "$OPT" in
"-curl-weather") clear ; curl -s wttr.in | head -n 38 | tail -n 37 && sleep 60 ;;
esac

17
src/speedwm-debug Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
install_xephyr() {
echo "Xephyr not installed, please install it."
exit 1
}
command -v Xephyr > /dev/null || install_xephyr
Xephyr -screen 1024x768 :80 &
sleep 1
export DISPLAY=:80
speedwm_run -f
~/.config/speedwm/swal/swal_wm
killall Xephyr

197
src/speedwm-dfmpeg Executable file
View file

@ -0,0 +1,197 @@
#!/bin/sh
# speedwm-dfmpeg
# dmenu/other run launcher GUI for recording your screen with ffmpeg
#
# Licensed under MIT, written by speedie
# Modified version for speedwm (available https://speedie.gq/speedwm)
# https://speedie.gq/dmenu-scripts
# speedwm specfic dotfile directory, probably don't change
DOTDIR=$HOME/.config/speedwm/dfmpeg
NOMKCONFIG=false # Do not create a config file if this is set to true
# Set runlauncher
case "$RUNLAUNCHER" in
"") RUNLAUNCHER=dmenu
esac
# -s flag stops recording
case "$1" in
"-s") pkill -x ffmpeg ; rm /tmp/dfmpeg-recording ; STATUS=idle ; exit ;;
esac
HAVE_GRID="true"
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
. $HOME/.config/speedwm/globalrc
else
mkdir -p $HOME/.config/speedwm/global
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
# Write default configuration
defaultConfig() {
RESOLUTION="1920x1080" # The resolution to record in
AUDIO_DEVICE="alsa" # How to capture audio (alsa/pulseaudio)
FRAME_RATE="60" # Frame rate to capture in.
RECORD_DEVICE="x11grab" # Probably do not change.
OUTPUT_PATH="$HOME/Recordings" # Path where videos will be saved.
OUTPUT_FORMAT="mp4" # What format to use
OUTPUT_FILENAME="dfmpeg-output" # File name of the output. Probably don't need to change.
ENCODE=true # Encode or not (true/false)
ENCODE_CODEC=libx264 # Codec to encode in
ENCODE_PRESET=ultrafast # ffmpeg preset. Available options: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow
WH=":0.0" # Width and height, no need to change, defaults should work.
TERM="$TERMINAL" # Terminal to use when editing the configuration file.
EDITOR="vim" # Editor to edit the config file with
MEDIA_PLAYER="mpv" # Media player to play videos in
}
defaultConfig
USECONFIG() {
echo "Using $DOTDIR/config for configuration!" && . $DOTDIR/config
}
MKCONFIG() {
if [ -e "$DOTDIR/config" ]; then
USECONFIG
else
if [ "$NOMKCONFIG" = "false" ]; then
mkdir -p $DOTDIR
printf "RESOLUTION=$RESOLUTION # The resolution to capture in" > $DOTDIR/config
printf "\nAUDIO_DEVICE=$AUDIO_DEVICE # How to capture audio (alsa/pulseaudio)" >> $DOTDIR/config
printf "\nFRAME_RATE=$FRAME_RATE # Frame rate to capture in." >> $DOTDIR/config
printf "\nOUTPUT_PATH=$OUTPUT_PATH # Directory where captures will be saved." >> $DOTDIR/config
printf "\nOUTPUT_FORMAT=$OUTPUT_FORMAT # What format to use" >> $DOTDIR/config
printf "\n#OUTPUT_FILENAME='filename'" >> $DOTDIR/config
printf "\n\nRECORD_DEVICE=$RECORD_DEVICE" >> $DOTDIR/config
printf "\nWH=$WH" >> $DOTDIR/config
printf "\nTERM=$TERMINAL # Terminal to use when editing the config file" >> $DOTDIR/config
printf "\nEDITOR=$EDITOR # Editor to edit the config file" >> $DOTDIR/config
printf "\nMEDIA_PLAYER=$MEDIA_PLAYER # Media player to play videos in" >> $DOTDIR/config
printf "\nENCODE=$ENCODE # Encode or not on 'Stop' (true/false)" >> $DOTDIR/config
printf "\nENCODE_CODEC=$ENCODE_CODEC # Codec to encode in (libx264 is default)" >> $DOTDIR/config
printf "\nENCODE_PRESET=$ENCODE_PRESET # ffmpeg preset. Available options: ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow" >> $DOTDIR/config
fi
fi
}
MKCONFIG
OUTPUT_FILENAME="$OUTPUT_PATH/$OUTPUT_FILENAME.$OUTPUT_FORMAT"
# Create the output path if it does not exist
if [ -e "$OUTPUT_PATH" ]; then
a=$a
else
mkdir -p $OUTPUT_PATH
fi
# Check if we should encode the video or not.
if [ "$ENCODE" = "false" ]; then
startrec="ffmpeg -f $RECORD_DEVICE -s $RESOLUTION -i $WH -f $AUDIO_DEVICE -r $FRAME_RATE -i default $OUTPUT_FILENAME"
startrec_no_audio="ffmpeg -y -f $RECORD_DEVICE -s $RESOLUTION -r $FRAME_RATE -i $WH $OUTPUT_FILENAME"
else
startrec="ffmpeg -y -f x11grab -framerate $FRAME_RATE -s $RESOLUTION -i $WH -f $AUDIO_DEVICE -i default -r 30 -c:v $ENCODE_CODEC -crf 0 -preset ultrafast -c:a aac $OUTPUT_FILENAME"
startrec_no_audio="ffmpeg -y -f x11grab -framerate $FRAME_RATE -s $RESOLUTION -i $WH -r 30 -c:v $ENCODE_CODEC -crf 0 -preset ultrafast -c:a aac $OUTPUT_FILENAME"
touch /tmp/isencoding
echo $ENCODE_CODEC > /tmp/encoding-codec
fi
# Call this function to encode a video manually.
# /tmp/rec.$OUTPUT_FORMAT must be the file. Consider copying it there and then copying it back.
encode() {
if [ "$ENCODE" = "true" ]; then
cp $(cat /tmp/outputfilename) /tmp/rec.$OUTPUT_FORMAT
ffmpeg -i /tmp/rec.$OUTPUT_FORMAT -c:v $ENCODE_CODEC -preset $ENCODE_PRESET -threads 0 -b:v -pass 1 -f $OUTPUT_FORMAT -qp 0
cp /tmp/rec.$OUTPUT_FORMAT $(cat /tmp/outputfilename)
rm -f "/tmp/rec.$OUTPUT_FORMAT"
fi
}
# Hardcoded version number
dfmpeg_ver="2022-08-06-r1"
about_screen="dfmpeg $dfmpeg_ver."
# About screen text
about_screen_2="Licensed under MIT, written by speedie.gq and jornmann."
about_screen_3="Modified for https://speedie.gq/speedwm"
about_screen_4="https://speedie.gq/dmenu-scripts"
# Conversion function
convert() {
# Convert mp4 to mp3
mp42mp3() {
COPT=$(printf 'Enter a path\n------\nExit' | $RUNLAUNCHER -l 3 -p 'Convert which file?')
case "$COPT" in
"Enter a path") exit 0 ;;
"------") exit 0 ;;
"Exit") exit 0 ;;
"") exit 0 ;;
esac
echo $COPT | grep ".mp4" && ffmpeg -i $COPT -vn $(echo $COPT | sed "s/.mp4/.mp3/g")
}
case "$(printf '.mp4 to .mp3\n------\n..\nExit' | $RUNLAUNCHER -l 40 -p 'Convertion options')" in
".mp4 to .mp3") mp42mp3 ;;
"Exit") exit 0 ;;
"------") exit 0 ;;
"..") $0 && exit 0 ;;
esac
}
encodeopts() {
case "$(printf 'Encode last recording\nEncode video\n------\n..\nExit' | $RUNLAUNCHER -l 40 -p 'Encoding options')" in
"Encode last recording") encode ; exit 0 ;;
"Encode video") echo "$(echo "" | $RUNLAUNCHER -l 1 $GRIDARG $GRIDNUM -p "What file do you want to encode?")" > /tmp/outputfilename && encode ; exit 0 ;;
"------") exit 0 ;;
"Exit") exit 0 ;;
"..") $0 && exit 0 ;;
"") exit 0 ;;
esac
}
# More options
MORE_OPTIONS() {
case "$(printf 'Encode\nConvert\nConfigure\n------\n..\nExit' | $RUNLAUNCHER -l 40 -p 'More options')" in
"Encode last recording") encode ; exit 0 ;;
"Encode video") echo "$(echo "" | $RUNLAUNCHER -l 1 $GRIDARG $GRIDNUM -p "What file do you want to encode?")" > /tmp/outputfilename && encode ; exit 0 ;;
"Encode") encodeopts ; exit 0 ;;
"Configure") $TERM $EDITOR $DOTDIR/config ; exit 0 ;;
"Convert") convert ; exit 0 ;;
"") exit 0 ;;
"..") $0 && exit 0 ;;
"------") exit 0 ;;
esac
}
case "$(printf 'Start\nStop\nStart without audio\nPlay last\n------\nMore options\nAbout\nExit' | $RUNLAUNCHER -l 40 -p 'Record your screen:')" in
"Exit") STATUS=idle && exit 0 ;;
"Start") touch /tmp/isaudio ; echo "$OUTPUT_FILENAME" > /tmp/outputfilename && STATUS=recording && touch /tmp/dfmpeg-recording
$startrec && exit 0 ;;
"Stop") pkill -x ffmpeg ; rm /tmp/dfmpeg-recording ; STATUS=idle ;;
"Start without audio") echo "$OUTPUT_FILENAME" > /tmp/outputfilename && STATUS=recording && touch /tmp/dfmpeg-recording
$startrec_no_audio && exit 0 ;;
"Play last") DFMPEG_STATUS=idle && $MEDIA_PLAYER $(cat /tmp/outputfilename) && exit 0 ;;
"More options") MORE_OPTIONS && exit 0 ;;
"") exit 0 ;;
"About")
echo $about_screen > /tmp/dfmpeg_about
echo $about_screen_2 >> /tmp/dfmpeg_about
echo $about_screen_3 >> /tmp/dfmpeg_about
echo $about_screen_4 >> /tmp/dfmpeg_about
cat /tmp/dfmpeg_about | $RUNLAUNCHER -l 40 $GRIDARG $GRIDNUM
;;
esac
exit 0 # This fixes a small bug.

129
src/speedwm-netctrl Executable file
View file

@ -0,0 +1,129 @@
#!/bin/sh
# speedwm-netctrl
# dmenu/other run launcher GUI for iwd
# Licensed under the GNU GPLv3 free software license.
case "$RUNLAUNCHER" in
"") RUNLAUNCHER=dmenu ;;
esac
BINDIR="$(dirname $(command -v speedwm-core))/"
command -v iwctl > /dev/null || exit 1
HAVE_GRID="true"
HAVE_PASSWORD="false"
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
. $HOME/.config/speedwm/globalrc
grep -q HAVE_PASSWORD $HOME/.config/speedwm/globalrc || printf "\nHAVE_PASSWORD=$HAVE_PASSWORD # Whether or not to use the Password argument if a script requests it. If you do not have the dmenu password patch, set this to false. Doing so will disable password prompts." >> $HOME/.config/speedwm/globalrc
else
mkdir -p $HOME/.config/speedwm/global
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
printf "\nHAVE_PASSWORD=$HAVE_PASSWORD # Whether or not to use the Password argument if a script requests it. If you do not have the dmenu password patch, set this to false. Doing so will disable password prompts." >> $HOME/.config/speedwm/globalrc
fi
if [ "$HAVE_GRID" = "true" ]; then
GRIDNUM="1"
fi
if [ "$HAVE_GRID" = "true" ]; then
GRIDARG="-g"
fi
SHOW_PASSWORD="true"
test ${BINDIR}iwctl || exit 0
if [ -e "$HOME/.config/speedwm/netctrl/config" ]; then
. $HOME/.config/speedwm/netctrl/config
else
mkdir -p $HOME/.config/speedwm/netctrl
printf "SHOW_PASSWORD=$SHOW_PASSWORD # Show password when entering it or not? Requires the 'password' dmenu patch. If you do not have it, you can get my build. You also need to enable it in $HOME/.config/speedwm/globalrc. (true/false)" > $HOME/.config/speedwm/netctrl/config
fi
if [ "$SHOW_PASSWORD" = "false" ]; then
if [ "$HAVE_PASSWORD" = "true" ]; then
PASS_ARG="-P"
fi
fi
# Get the device used to connect.
getdevice() {
seldevice=$1
if [ -e "$HOME/.local/share/seldevice" ]; then
seldevice=$(cat $HOME/.local/share/seldevice)
else
case "$1" in
"") devices="$(printf "\n$(ip link)" | awk '{ print $2 }' | awk 'NR%2==0' | sed "s/://g")"
seldevice=$(echo $devices | sed 's/ /\n/g' | $RUNLAUNCHER -p "What device do you want to connect with?" -l 10 $GRIDARG $GRIDNUM) && echo $seldevice > $HOME/.local/share/seldevice ;;
esac
fi
case "$seldevice" in
"") exit 0 ;;
esac
}
# connect to wifi
connectwifi() {
# if args aren't disconnect, scan for networks
# if it is disconnect, disconnect
if [ "$INARGS" != "disconnect" ]; then
iwctl station $seldevice scan
network="$(printf "$(iwctl station $seldevice get-networks | sed -n 6,20p | sed "s|>||g" | awk '{ print $1 }')\nDisconnect\n------\nExit" | sed "s| |No networks found|g" | $RUNLAUNCHER -l 10 $GRIDARG $GRIDNUM -p "Select a network to connect to" | sed "s|------||g" | sed "s|No networks found| |g")"
case "$network" in
"") exit 0 ;;
"Disconnect") disconnect=true ;;
"Exit") exit 0 ;;
esac
else
disconnect=true
fi
if [ "$disconnect" != "true" ]; then
iwctl station $seldevice get-networks | grep "$network" > /dev/null || exit 1
connect_pass() {
PASSPHRASE=$(printf "\n" | $RUNLAUNCHER -p "This network is protected. Enter the passphrase." -l 1 $GRIDARG $GRIDNUM $PASS_ARG)
case "$PASSPHRASE" in
"") exit 0 ;;
esac
printf "$network\n" >> $HOME/.local/share/networks
iwctl station $seldevice connect $network -P $PASSPHRASE || connect_pass
if [ -e "${BINDIR}notify-send" ]; then
notify-send " Connected to $network!"
fi
exit 0
}
connect_no_pass() {
iwctl station $seldevice connect $network || exit 0
if [ -e "${BINDIR}notify-send" ]; then
notify-send " Connected to $network!"
fi
exit 0
}
fi
disconnect() {
iwctl station $seldevice disconnect
if [ -e "${BINDIR}notify-send" ]; then
notify-send " Disconnected from the network!"
fi
exit 0
}
if [ "$disconnect" != "true" ]; then
grep $network $HOME/.local/share/networks && connect_no_pass && exit 0
iwctl station $seldevice get-networks | grep psk && connect_pass && exit 0
else
disconnect
fi
}
export INARGS="$1"
getdevice && connectwifi
pgrep -x status > /dev/null && pkill status && status &

145
src/speedwm-screenshotutil Executable file
View file

@ -0,0 +1,145 @@
#!/bin/sh
# speedwm-screenshotutil
# Built in screenshot utility for my build of speedwm
# Requires curl, maim and xclip.
#
# curl snippet by nezbednik, thank you!
rm -f /tmp/screenshot*
case "$RUNLAUNCHER" in
"") RUNLAUNCHER=dmenu ;;
esac
BINDIR="$(dirname $(command -v speedwm-core))/"
HAVE_GRID="true"
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
. $HOME/.config/speedwm/globalrc
else
mkdir -p $HOME/.config/speedwm/global
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
EXPORTDIR=$HOME/.config/speedwm/screenshotutil
mkdir -p $EXPORTDIR
# Config
SHOWCURSOR="true" # Show cursor or not (true/false)
DEFAULTSCREENSHOTPATH=$HOME/Screenshots # Default screenshot path
FORMAT="+%T_%D" # Screenshot format
if [ -e "$EXPORTDIR/config" ]; then
. $EXPORTDIR/config
else
printf "SHOWCURSOR=$SHOWCURSOR # Show cursor or not (true/false)" > $EXPORTDIR/config
printf "\nDEFAULTSCREENSHOTPATH=$DEFAULTSCREENSHOTPATH # Where screenshots are saved\n" >> $EXPORTDIR/config
echo "FORMAT='$FORMAT' # Where screenshots are saved. : and / will be replaced with _ and nothing respectively." >> $EXPORTDIR/config
fi
case "$SHOWCURSOR" in
"true") ARG2="" ;;
"false") ARG2=u ;;
esac
# Help argument action
HELP() {
printf "speedwm-screenshotutil\n-t | Wait <second argument> seconds and then take the screenshot."
printf "\n-f | Take a full screen screenshot instead of selecting manually."
printf "\n-s | Take a screenshot, allowing the user to select a section manually."
printf "\n-o | Select a file and allow the user to perform actions with it."
printf "\n-tf | Wait <second argument> seconds and then take a full screen screenshot."
printf "\n-h | View this help screen"
printf "\nNo arguments will print this screen.\n"
}
# Sleep argument (-t)
if [ "$1" = "-t" ]; then
sleep $2 && maim -s${ARG2}B > /tmp/screenshot-$DATE || exit 0
fi
# Open argument (-o)
if [ "$1" = "-o" ]; then
cat $2 > /tmp/screenshot-$DATE
fi
# Sleep and full argument (-tf)
if [ "$1" = "-tf" ]; then
sleep $2 && maim -${ARG2}B > /tmp/screenshot-$DATE || exit 0
elif [ "$1" = "-ft" ]; then
sleep $2 && maim -${ARG2}B > /tmp/screenshot-$DATE || exit 0
fi
# Full argument (-f)
if [ "$1" = "" ]; then
HELP ; exit 0
else
if [ "$1" = "-f" ]; then
if [ -e "/tmp/screenshot-$DATE" ]; then
exists=true
else
maim -${ARG2}B > /tmp/screenshot-$DATE || exit 0
fi
fi
if [ "$1" = "-s" ]; then
if [ -e "/tmp/screenshot-$DATE" ]; then
exists=true
else
maim -s${ARG2}B > /tmp/screenshot-$DATE || exit 0
fi
fi
fi
# Help argument (-h)
if [ "$1" = "-h" ]; then
HELP ; exit 0
fi
# User action
if [ -e "/tmp/screenshot-$DATE" ]; then
U_INPUT="$(printf "Image\nURL\nSave" | $RUNLAUNCHER -l 3 -p "Copy to clipboard as an: ")"
else
exit 0
fi
# Send notification for URL
SENDNOTIF_URL() {
if [ -e "${BINDIR}notify-send" ]; then
notify-send "Screenshot copied to clipboard."
fi
}
# Send notifcation for local image save
SENDNOTIF_SAVE() {
if [ -e "${BINDIR}notify-send" ]; then
notify-send "Screenshot saved to $SAVEDIR."
fi
}
# Send notification for image copied to clipboard
SENDNOTIF_IMG() {
if [ -e "${BINDIR}notify-send" ]; then
notify-send "Screenshot copied to clipboard."
fi
}
mkdir -p $DEFAULTSCREENSHOTPATH
# Perform actions based on user input
case "$U_INPUT" in
"Image") cat /tmp/screenshot-$DATE | xclip -selection clipboard -t image/png && SENDNOTIF_IMG ;;
"URL") printf "\n" | xclip -selection clipboard && curl -s -F source=@"/tmp/screenshot-$DATE" -F "type=file" -F "action=upload" "https://imgbb.com/json" | sed "s/\\\\//g; s/\"/\\n/g" | grep -m 1 -A 2 url | tail -n 1 | xclip -selection clipboard && SENDNOTIF_URL ;;
"Save") SAVEDIR=$(printf "$DEFAULTSCREENSHOTPATH/screenshot-$(date "$FORMAT" | sed "s|:|-|g" | sed "s|/||g").png" | $RUNLAUNCHER -l 1 $GRIDARG $GRIDNUM -p "Where do you want to save it? (Including filename)") && cat /tmp/screenshot-$DATE > $SAVEDIR && SENDNOTIF_SAVE ;;
esac
rm -f /tmp/screenshot* # Remove the screenshots

172
src/speedwm-shutdown Executable file
View file

@ -0,0 +1,172 @@
#!/bin/sh
# speedwm-shutdwon
# This simple script uses $RUNLAUNCHER to ask the user what action they want to perform.
#
# NOTE: You must either permit nopass for poweroff and reboot commands for your user or simply enable nopass entirely!!
case "$RUNLAUNCHER" in
"") RUNLAUNCHER=dmenu ;;
esac
case "$TERMINAL" in
"") TERMINAL=st ;;
esac
HAVE_GRID="true"
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
. $HOME/.config/speedwm/globalrc
else
mkdir -p $HOME/.config/speedwm/global
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
BINDIR="$(dirname $(command -v speedwm-core))/"
EXPORTDIR=$HOME/.config/speedwm/powermenu
mkdir -p $EXPORTDIR
command -v sudo > /dev/null && PERM=sudo
command -v doas > /dev/null && PERM=doas
command -v rootdo > /dev/null && PERM=rootdo
case "$PERM" in
"") PERM=su ;;
esac
COL_NORMAL_TEXT_NORMAL="#ffffff"
COL_NORMAL_TEXT_SELECTED="#ffffff"
COL_NORMAL_BACKGROUND_NORMAL="#333333"
COL_NORMAL_BACKGROUND_SELECTED="#222222"
COL_WARNING_TEXT_NORMAL="#ffffff"
COL_WARNING_TEXT_SELECTED="#000000"
COL_WARNING_BACKGROUND_NORMAL="#DC143C"
COL_WARNING_BACKGROUND_SELECTED="#8b0000"
USEDEFAULTCOLORS=true
LOCK_TEXT=""
# Load config if available and override settings
if [ -e "$EXPORTDIR/config" ]; then
. $EXPORTDIR/config
else
printf "# Colors for the prompt. Replace the color values with 'dmenu' for regular default colors." > $EXPORTDIR/config
printf "\nCOL_NORMAL_TEXT_NORMAL=$COL_NORMAL_TEXT_NORMAL # Text color for not selected options (Regular prompt)" >> $EXPORTDIR/config
printf "\nCOL_NORMAL_TEXT_SELECTED=$COL_NORMAL_TEXT_SELECTED # Text color for selected option (Regular prompt)" >> $EXPORTDIR/config
printf "\nCOL_NORMAL_BACKGROUND_NORMAL=$COL_NORMAL_BACKGROUND_NORMAL # Background color for not selected options (Regular prompt)" >> $EXPORTDIR/config
printf "\nCOL_NORMAL_BACKGROUND_SELECTED=$COL_NORMAL_BACKGROUND_SELECTED # Background color for selected option (Regular prompt)" >> $EXPORTDIR/config
printf "\nCOL_WARNING_TEXT_NORMAL=$COL_WARNING_TEXT_NORMAL # Text color for not selected options (Warning prompt)" >> $EXPORTDIR/config
printf "\nCOL_WARNING_TEXT_SELECTED=$COL_WARNING_TEXT_SELECTED # Text color for selected option (Warning prompt)" >> $EXPORTDIR/config
printf "\nCOL_WARNING_BACKGROUND_NORMAL=$COL_WARNING_BACKGROUND_NORMAL # Background color for not selected options (Warning prompt)" >> $EXPORTDIR/config
printf "\nCOL_WARNING_BACKGROUND_SELECTED=$COL_WARNING_BACKGROUND_SELECTED # Background color for selected option (Warning prompt)" >> $EXPORTDIR/config
printf "\nPERM=$PERM # Root access tool (sudo, doas, etc.). Must support nopass for poweroff and reboot commands." >> $EXPORTDIR/config
printf "\nUSEDEFAULTCOLORS=$USEDEFAULTCOLORS # Use $RUNLAUNCHER colors instead of custom ones (true/false)" >> $EXPORTDIR/config
printf "\nLOCK_TEXT=$LOCK_TEXT # Text to display on the lock screen. Only works with slock and requires the message patch." >> $EXPORTDIR/config
fi
case "$LOCK_TEXT" in
"") MESSAGEFLAG="" ;;
esac
SBFLAG="-sb"
SFFLAG="-sf"
NBFLAG="-nb"
NFFLAG="-nf"
if [ "$USEDEFAULTCOLORS" = "true" ]; then
SBFLAG=""
NBFLAG=""
SFFLAG=""
NFFLAG=""
COL_NORMAL_BACKGROUND_SELECTED=""
COL_NORMAL_BACKGROUND_NORMAL=""
COL_NORMAL_TEXT_SELECTED=""
COL_NORMAL_TEXT_NORMAL=""
COL_WARNING_BACKGROUND_NORMAL=""
COL_WARNING_TEXT_SELECTED=""
COL_WARNING_TEXT_NORMAL=""
COL_WARNING_BACKGROUND_SELECTED=""
fi
# Standard Background
if [ "$COL_NORMAL_BACKGROUND_SELECTED" = "dmenu" ]; then
SBFLAG=""
COL_NORMAL_BACKGROUND_SELECTED=""
fi
# Normal Background
if [ "$COL_NORMAL_BACKGROUND_NORMAL" = "dmenu" ]; then
NBFLAG=""
COL_NORMAL_BACKGROUND_NORMAL=""
fi
# Standard Background
if [ "$COL_NORMAL_TEXT_SELECTED" = "dmenu" ]; then
SFFLAG=""
COL_NORMAL_TEXT_SELECTED=""
fi
# Normal Text
if [ "$COL_NORMAL_TEXT_NORMAL" = "dmenu" ]; then
NFFLAG=""
COL_NORMAL_TEXT_NORMAL=""
fi
# Standard Background
if [ "$COL_WARNING_BACKGROUND_SELECTED" = "dmenu" ]; then
SBFLAG=""
COL_WARNING_BACKGROUND_SELECTED=""
fi
# Normal Background
if [ "$COL_WARNING_BACKGROUND_NORMAL" = "dmenu" ]; then
NBFLAG=""
COL_WARNING_BACKGROUND_NORMAL=""
fi
# Standard Background
if [ "$COL_WARNING_TEXT_SELECTED" = "dmenu" ]; then
SFFLAG=""
COL_WARNING_TEXT_SELECTED=""
fi
# Normal Text
if [ "$COL_WARNING_TEXT_NORMAL" = "dmenu" ]; then
NFFLAG=""
COL_WARNING_TEXT_NORMAL=""
fi
MOREOPTS() {
USER_OPT3=$(printf "Restart speedwm\nEnd task\nspeedwm command\n.." | $RUNLAUNCHER -l 4 $GRIDARG $GRIDNUM -p "What do you want to do?" $NBFLAG $COL_NORMAL_BACKGROUND_NORMAL $SBFLAG $COL_NORMAL_BACKGROUND_SELECTED $NFFLAG $COL_NORMAL_TEXT_NORMAL $SFFLAG $COL_NORMAL_TEXT_SELECTED)
case "$USER_OPT3" in
"") exit 0 ;;
"Restart speedwm") speedwm_run -r && exit 0 ;;
"End task") ENDTASK=$(printf "\n" | $RUNLAUNCHER -l 1 -p "What task to end?" $NBFLAG $COL_NORMAL_BACKGROUND_NORMAL $SBFLAG $COL_NORMAL_BACKGROUND_SELECTED $NFFLAG $COL_NORMAL_TEXT_NORMAL $SFFLAG $COL_NORMAL_TEXT_SELECTED) && pkill $ENDTASK && exit 0 ;;
"speedwm command") speedwm-utils && exit 0 ;;
"..") $0 && exit 0 ;;
esac
}
USER_OPT1=$(printf "Shutdown\nReboot\nExit\nLock\nMore" | $RUNLAUNCHER -l 5 -p "What do you want to do?" $NBFLAG $COL_NORMAL_BACKGROUND_NORMAL $SBFLAG $COL_NORMAL_BACKGROUND_SELECTED $NFFLAG $COL_NORMAL_TEXT_NORMAL $SFFLAG $COL_NORMAL_TEXT_SELECTED)
case "$USER_OPT1" in
"Shutdown") CMD="$PERM poweroff" ;;
"Reboot") CMD="$PERM reboot" ;;
"Exit") exit 0 ;;
"Lock") CMD="slock $MESSAGEFLAG '$LOCK_TEXT'" ;;
"More") MOREOPTS ;;
"") exit 0 ;;
esac
USER_OPT2=$(printf "Yes\nNo" | $RUNLAUNCHER -l 2 -p "Are you sure?" $NBFLAG "$COL_WARNING_BACKGROUND_NORMAL" $SBFLAG "$COL_WARNING_BACKGROUND_SELECTED" $NFFLAG "$COL_WARNING_TEXT_NORMAL" $SFFLAG "$COL_WARNING_TEXT_SELECTED")
case "$USER_OPT2" in
"Yes") $CMD ;;
"No") exit 0 ;;
"") exit 0 ;;
esac

357
src/speedwm-swal Executable file
View file

@ -0,0 +1,357 @@
#!/bin/sh
# speedwm-swal
# wallpaper utility written for speedwm.
# Licensed under the GNU GPLv3 free software license.
ARGS="$@"
ARG1="$1"
# Default configuration, should be fine for most users.
SWAL_DEFAULT_CONFIG()
{
SWAL_WALLPAPERDIR=$HOME/Wallpapers
SWAL_OLDWALLPAPERDIR=$SWAL_WALLPAPERDIR
case "$RUNLAUNCHER" in
"") RUNLAUNCHER=dmenu ;;
esac
SWAL_OPT=xwallpaper
SWAL_EXPORTDIR=$HOME/.config/speedwm/swal # Config directory
SWAL_IMAGE_VIEWER="sxiv -to" # Image viewer to use (<char>)
SWAL_ASK_WAL=false # Ask whether or not to use Pywal if possible (true/false)
SWAL_RANDOMIZE=false # Select a random wallpaper on login
}
# By default, assume we have grid.
HAVE_GRID="true"
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
. $HOME/.config/speedwm/globalrc
echo "Loaded configuration!"
else
mkdir -p $HOME/.config/speedwm/global
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 the configuration
SWAL_MKCONFIG() {
mkdir -p $SWAL_EXPORTDIR
touch $SWAL_EXPORTDIR/config
SWAL_ASK_WAL_NEW=$SWAL_ASK_WAL
SWAL_WALLPAPERDIR_NEW=$SWAL_WALLPAPERDIR
SWAL_CHANGE_WALLPAPERDIR() {
SWAL_WALLPAPERDIR_NEW=$(printf "Your wallpaper directory" | $RUNLAUNCHER $GRIDARG $GRIDNUM -p "Where are all your wallpapers stored?" -l 1)
}
SWAL_CHANGE_ASK_WAL() {
command -v wal > /dev/null && SWAL_ASK_WAL_NEW=$(printf "Yes\nNo" | $RUNLAUNCHER $GRIDARG $GRIDNUM -p "Ask whether or not to use Pywal?" -l 2 | sed "s|No|false|g" | sed "s|Yes|true|g")
}
SWAL_CHANGE_IMAGE_VIEWER() {
SWAL_IMAGE_VIEWER=$(printf "" | $RUNLAUNCHER $GRIDARG $GRIDNUM -p "What image viewer do you want to use for previews?" -l 1)
}
SWAL_CHANGE_RANDOMIZE() {
SWAL_RANDOMIZE=$(printf "Yes\nNo" | $RUNLAUNCHER $GRIDARG $GRIDNUM -p "Pick a random wallpaper on login?" -l 2 | sed "s|No|false|g" | sed "s|Yes|true|g")
}
USER_OPT_ACTION=$(printf "Wallpaper directory\nPywal\nImage Viewer\nRandomize\n------\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 10 -p "What setting do you want to change?")
case "$USER_OPT_ACTION" in
"") $0 && exit 0 ;;
"Wallpaper directory") SWAL_CHANGE_WALLPAPERDIR && CHANGED=true ;;
"Pywal") SWAL_CHANGE_ASK_WAL && CHANGED=true ;;
"Image Viewer") SWAL_CHANGE_IMAGE_VIEWER && CHANGED=true ;;
"Randomize") SWAL_CHANGE_RANDOMIZE && CHANGED=true ;;
"Exit") exit 0 ;;
"------") $0 && exit 0 ;;
esac
case "$CHANGED" in
"") $0 && exit 0 ;;
esac
case "$SWAL_ASK_WAL_NEW" in
"true") ASKED=true ;;
"false") ASKED=true ;;
esac
if [ "$ASKED" = "" ]; then
$0 && exit 0
fi
printf "SWAL_WALLPAPERDIR=$SWAL_WALLPAPERDIR_NEW" > $SWAL_EXPORTDIR/config
printf "\nRUNLAUNCHER=$RUNLAUNCHER" >> $SWAL_EXPORTDIR/config
printf "\nSWAL_OPT=$SWAL_OPT" >> $SWAL_EXPORTDIR/config
printf "\nSWAL_EXPORTDIR=$SWAL_EXPORTDIR" >> $SWAL_EXPORTDIR/config
printf "\nSWAL_IMAGE_VIEWER='$SWAL_IMAGE_VIEWER'" >> $SWAL_EXPORTDIR/config
printf "\nSWAL_ASK_WAL=$SWAL_ASK_WAL_NEW" >> $SWAL_EXPORTDIR/config
printf "\nSWAL_RANDOMIZE=$SWAL_RANDOMIZE" >> $SWAL_EXPORTDIR/config
}
# Binary directory
SWAL_OLDWALLPAPERDIR=$SWAL_WALLPAPERDIR
# Source things
SWAL_SOURCE()
{
ls "$SWAL_EXPORTDIR/config" || SWAL_MKCONFIG
. "$SWAL_EXPORTDIR/config" || rm -f "$SWAL_EXPORTDIR/config"
}
# Set image viewer if none is specified.
SWAL_CHECK()
{
if [ "$SWAL_IMAGE_VIEWER" = "" ]; then
if command -v feh > /dev/null; then
SWAL_IMAGE_VIEWER=feh
if command -v sxiv > /dev/null; then
SWAL_IMAGE_VIEWER=sxiv
if command -v nsxiv > /dev/null; then
SWAL_IMAGE_VIEWER=nsxiv
fi
fi
command -v xwallpaper > /dev/null || SWAL_DIE
}
# Die
SWAL_DIE()
{
SWAL_EXIT=1 && exit 1
}
# Print usage.
SWAL_USAGE() {
echo "To set a wallpaper, you must create a configuration. To do this, select 'Options' in the menu and set all the options to your liking."
echo "The image viewer must be set to an image viewer that supports printing the filename to stdout. If you use sxiv, set the image viewer to 'sxiv -o'."
echo "In the case of sxiv, This means you can press 'm' when previewing an image to select it and then set it."
echo "Once you've selected your image using the method you prefer, select how you want to set it."
echo "Then your pywal colors will reload, and the wallpaper will be set."
echo "For more information, see speedwm-help -a."
}
# Select wallpaper
SWAL_SELWALLPAPER()
{
if [ "$ARG1" = "" ]; then
SWAL_SELWALLPAPER="$(printf "$(ls "$SWAL_WALLPAPERDIR")\n------\n..\nPreview\nPrevious\nRandom\nFavorites\nAdd used wallpaper to favorites\nOptions\nHelp\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 100 -p "What wallpaper would you like to set?")"
fi
}
# Set the type/check what was selected.
SWAL_SETTYPE()
{
case "$ARG1" in
"--randomize") SWAL_SELWALLPAPER="Random" ;;
"--previous") SWAL_SELWALLPAPER="Previous" ;;
esac
case "$SWAL_SELWALLPAPER" in
"Options") SWAL_MKCONFIG && $0 $@ && exit 0 ;;
"") $0 && exit 0 ;;
"Favorites") SWAL_SELWALLPAPER="$(printf "$(cat $SWAL_EXPORTDIR/favorites.filename)\n------\n..\nClear\n\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 100 -p "What wallpaper would you like to set?")" ; FAVORITES=true ;;
"Add used wallpaper to favorites") echo "$(readlink "$SWAL_EXPORTDIR/CurrentWallpaper")" >> $SWAL_EXPORTDIR/favorites ; echo "$(basename "$(readlink "$SWAL_EXPORTDIR/CurrentWallpaper")")" >> $SWAL_EXPORTDIR/favorites.filename && $0 && exit 0 ;;
"Preview") SWAL_PREVIEWIMG="$($SWAL_IMAGE_VIEWER "$SWAL_WALLPAPERDIR"/*)" ;;
"..") cd "$SWAL_WALLPAPERDIR/.." && SWAL_WALLPAPERDIR="$(pwd)" && SWAL_SELWALLPAPER && SET && exit 0 ;;
"Random") SWAL_FULL="$(find $SWAL_WALLPAPERDIR/* -type f | shuf -n 1)" ; SWAL_WALLPAPERDIR="$(dirname "$SWAL_FULL")" ; SWAL_SELWALLPAPER="$(basename "$SWAL_FULL")" ; SWAL_SELWAL=$SWAL_SELWALLPAPER ;;
"Previous") SWAL_PREVWAL=$(readlink $SWAL_EXPORTDIR/CurrentWallpaper_prev) ; SWAL_WALLPAPERDIR="$(dirname "$SWAL_PREVWAL")" ; SWAL_SELWALLPAPER="$(basename "$SWAL_PREVWAL")" ;;
"Exit") exit 0 ;;
"Help") SWAL_USAGE | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 50 -p "How to use" && $0 && exit 0 ;;
"------") $0 && exit 0 ;;
esac
# Favorites feature
if [ "$FAVORITES" = "true" ]; then
case "$SWAL_SELWALLPAPER" in
"") $0 && exit 0 ;;
"Clear") rm -f $SWAL_EXPORTDIR/favorites* ; $0 && exit 0 ;;
"Exit") exit 0 ;;
"..") $0 && exit 0 ;;
"------") $0 && exit 0 ;;
esac
SWAL_WALLPAPERDIR="$(dirname "$(cat "$SWAL_EXPORTDIR/favorites" | grep "$SWAL_SELWALLPAPER")")"
fi
# If it's an actual image, use it as wallpaper
if [ "$SWAL_SELWALLPAPER" = "Preview" ]; then
if [ "$SWAL_PREVIEWIMG" = "" ]; then
$0 && exit 0
else
SWAL_SELWALLPAPER="$SWAL_PREVIEWIMG"
SWAL_WALLPAPERDIR=""
fi
fi
# Check if it's a directory
if [ -d "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" ]; then
cd "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" && SWAL_WALLPAPERDIR="$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" && SWAL_SELWALLPAPER && SET && exit 0
fi
# Fail if the wallpaper is not a proper wallpaper.
FAIL_NOT_REAL() {
command -v notify-send > /dev/null && notify-send "The selected wallpaper is not valid/does not exist."
$0 ; exit 1
}
ls "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" || FAIL_NOT_REAL
# don't set type if using argument
if [ "$SWAL_ASK_TYPE" != "false" ]; then
if [ "$ARG1" = "" ]; then
SWAL_TYPE=$(printf "Center\nTile\nZoom\nStretch\n------\nExit" | $RUNLAUNCHER -p "How do you want to set the wallpaper?" $GRIDARG $GRIDNUM -l 7)
else
SWAL_TYPE="Stretch"
fi
fi
case "$SWAL_TYPE" in
"Center") SWAL_TYPE=center ;;
"Tile") SWAL_TYPE=tile ;;
"Zoom") SWAL_TYPE=zoom ;;
"Stretch") SWAL_TYPE=stretch ;;
"Exit") exit 0 ;;
"------") $0 && exit 0 ;;
"") $0 && exit 0 ;;
esac
# Set type to stretch, shouldn't matter as xwallpaper can determine if it makes sense.
if [ "$SWAL_ASK_TYPE" = "false" ]; then
SWAL_TYPE=stretch
fi
# Set variables so that we can use them with xwallpaper directly.
SWAL_TYPE="--$SWAL_TYPE"
SWAL_WAL_STATUS="0"
# Check whether or not to ask based on configuration file.
if [ "$ARG1" = "" ]; then
case "$SWAL_ASK_WAL" in
"true") command -v wal > /dev/null && SWAL_USE_WAL=$(printf "Yes\nNo" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 90 -p "Do you want to use Pywal?" -l 2) && SWAL_WAL_STATUS="1" ;;
"false") command -v wal > /dev/null && SWAL_USE_WAL="Yes" && SWAL_WAL_STATUS="1" ;;
esac
else
command -v wal > /dev/null && SWAL_USE_WAL="Yes" && SWAL_WAL_STATUS="1"
fi
# Don't perform pywal actions if not installed/used
if [ "$SWAL_WAL_STATUS" = "0" ]; then
SWAL_USE_WAL="No"
fi
}
# Set the wallpaper.
SWAL_SETWALLPAPER()
{
$SWAL_OPT $SWAL_TYPE "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" || FAIL_NOT_REAL
}
# Export script to autostart on login
SWAL_EXPORT_SCRIPT()
{
if [ "$SWAL_RANDOMIZE" = "false" ]; then
printf "#!/bin/sh\n$SWAL_OPT $SWAL_TYPE ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'""" > $SWAL_EXPORTDIR/swal_wm
if [ -e "$SWAL_EXPORTDIR/CurrentWallpaper" ]; then
rm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev ; ln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" $SWAL_EXPORTDIR/CurrentWallpaper_prev
fi
rm -f $SWAL_EXPORTDIR/CurrentWallpaper ; ln -s "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" $SWAL_EXPORTDIR/CurrentWallpaper
else
printf "#!/bin/sh" > $SWAL_EXPORTDIR/swal_wm
printf "\nSWAL_WALLPAPERDIR=""'$SWAL_OLDWALLPAPERDIR'""" >> $SWAL_EXPORTDIR/swal_wm
printf "\nSWAL_EXPORTDIR=""'$SWAL_EXPORTDIR'""" >> $SWAL_EXPORTDIR/swal_wm
printf '\nSWAL_SELWALLPAPER="$(find "$SWAL_WALLPAPERDIR"/* -type f | shuf -n 1)"' >> $SWAL_EXPORTDIR/swal_wm
printf "\n$SWAL_OPT $SWAL_TYPE " >> $SWAL_EXPORTDIR/swal_wm
printf '"$SWAL_SELWALLPAPER"' >> $SWAL_EXPORTDIR/swal_wm
printf "\nrm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev" >> $SWAL_EXPORTDIR/swal_wm
printf '\nln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" ' >> $SWAL_EXPORTDIR/swal_wm
printf "$SWAL_EXPORTDIR/CurrentWallpaper_prev" >> $SWAL_EXPORTDIR/swal_wm
printf "\nrm -f $SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
printf '\nln -s "$SWAL_SELWALLPAPER" ' >> $SWAL_EXPORTDIR/swal_wm
printf "$SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
fi
chmod +x $SWAL_EXPORTDIR/swal_wm
}
# Export script to autostart on login for Pywal users
SWAL_EXPORT_SCRIPT_WAL()
{
if [ "$SWAL_RANDOMIZE" = "false" ]; then
printf "#!/bin/sh\n$SWAL_OPT $SWAL_TYPE ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'""\nwal -qi ""'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'"" || rm -rf $HOME/.cache/wal ; xrdb -remove\nxrdb ~/.cache/wal/colors.Xresources" > $SWAL_EXPORTDIR/swal_wm
else
printf "#!/bin/sh" > $SWAL_EXPORTDIR/swal_wm
printf "\nSWAL_WALLPAPERDIR=""'$SWAL_OLDWALLPAPERDIR'""" >> $SWAL_EXPORTDIR/swal_wm
printf "\nSWAL_EXPORTDIR=""'$SWAL_EXPORTDIR'""" >> $SWAL_EXPORTDIR/swal_wm
printf '\nSWAL_SELWALLPAPER="$(find "$SWAL_WALLPAPERDIR"/* -type f | shuf -n 1)"' >> $SWAL_EXPORTDIR/swal_wm
printf "\n$SWAL_OPT $SWAL_TYPE " >> $SWAL_EXPORTDIR/swal_wm
printf '"$SWAL_SELWALLPAPER"' >> $SWAL_EXPORTDIR/swal_wm
printf '\nwal -nqi "$SWAL_SELWALLPAPER" || rm -rf $HOME/.cache/wal ; xrdb -remove\nxrdb $HOME/.cache/wal/colors.Xresources\nxrdb $HOME/.cache/wal/colors.Xresources' >> $SWAL_EXPORTDIR/swal_wm
printf "\nrm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev" >> $SWAL_EXPORTDIR/swal_wm
printf '\nln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" ' >> $SWAL_EXPORTDIR/swal_wm
printf "$SWAL_EXPORTDIR/CurrentWallpaper_prev" >> $SWAL_EXPORTDIR/swal_wm
printf "\nrm -f $SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
printf '\nln -s "$SWAL_SELWALLPAPER" ' >> $SWAL_EXPORTDIR/swal_wm
printf "$SWAL_EXPORTDIR/CurrentWallpaper" >> $SWAL_EXPORTDIR/swal_wm
fi
chmod +x $SWAL_EXPORTDIR/swal_wm
rm -rf $HOME/.cache/wal # Delete previous colors
wal -nqi "'$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER'" && xrdb ~/.cache/wal/colors.Xresources || xrdb -remove # Compatibility with my speedwm build
if [ -e "$SWAL_EXPORTDIR/CurrentWallpaper" ]; then
rm -f $SWAL_EXPORTDIR/CurrentWallpaper_prev ; ln -s "$(readlink $SWAL_EXPORTDIR/CurrentWallpaper)" $SWAL_EXPORTDIR/CurrentWallpaper_prev
fi
rm -f $SWAL_EXPORTDIR/CurrentWallpaper ; ln -s "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER" $SWAL_EXPORTDIR/CurrentWallpaper
command -v wal > /dev/null && wal -nqi "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER"
command -v speedwm_run > /dev/null && speedwm_run -rnoloadcolors
}
# Send notification
SWAL_SENDNOTIFICATION() {
if [ "$SWAL_SELWAL" = "" ]; then
command -v notify-send > /dev/null && notify-send " $SWAL_SELWALLPAPER set as wallpaper in $(echo $SWAL_TYPE | sed "s|--||g") mode."
else
command -v notify-send > /dev/null && notify-send " $SWAL_SELWAL set as wallpaper in $(echo $SWAL_TYPE | sed "s|--||g") mode."
fi
exit 0
}
SWAL_DEFAULT_CONFIG
SWAL_SOURCE || SWAL_DIE
SWAL_CHECK || SWAL_DIE
SWAL_SELWALLPAPER || SWAL_DIE
SET() {
SWAL_SETTYPE || SWAL_DIE
SWAL_SETWALLPAPER || SWAL_DIE
# Pywal
case "$SWAL_USE_WAL" in
"Yes") SWAL_EXPORT_SCRIPT_WAL || SWAL_DIE ;;
"No") SWAL_EXPORT_SCRIPT || SWAL_DIE ;;
"") exit 0 ;;
esac
rm -rf $HOME/.local/share/swal_wm
cp $SWAL_EXPORTDIR/swal_wm $HOME/.local/share/swal_wm
chmod +x $HOME/.local/share/swal_wm
SWAL_SENDNOTIFICATION
}
SET
$0 && exit 0

115
src/speedwm-utils Executable file
View file

@ -0,0 +1,115 @@
#!/bin/sh
# speedwm-utils
# Because controlling speedwm using shell scripts is based.
# Licensed under GNU GPLv3.
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
mkdir -p $HOME/.config/speedwm/global
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() {
GENERALOPTS=$(printf "mfact +\nmfact -\nToggle Sticky\nToggle Bar\nToggle Fullscreen\nReset Layout/mfact\nReorganize Tags" | $RUNLAUNCHER -l 20 -p 'What do you want to do?')
case "$GENERALOPTS" in
"mfact +") speedwm -s "#cmd:18" ;;
"mfact -") speedwm -s "#cmd:19" ;;
"Toggle Sticky") speedwm -s "#cmd:20" ;;
"Toggle Bar") speedwm -s "#cmd:21" ;;
"Toggle Fullscreen") speedwm -s "#cmd:22" ;;
"Reorganize Tags") speedwm -s "#cmd:25" ;;
"Reset Layout/mfact") speedwm -s "#cmd:59" ;;
esac
}
OPT() {
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 ;;
"Reload .Xresources") ${0} reloadcolors && exit 0 ;;
"General") ${0} -general $2 && exit 0 ;;
"Exit") exit 0 ;;
esac
}
HELP() {
printf "speedwm-utils - Control speedwm using your terminal or dmenu.\n"
printf "\nlayout Let the user select a speedwm layout"
printf "\nreloadcolors Reload .Xresources"
printf "\nexec <signum> Execute an fsignal signum"
printf "\nlist List all available signums"
printf "\n"
}
L1="$(printf "L1: Tiling\n")"
L2="$(printf "L2: Floating\n")"
L3="$(printf "L3: Monocle\n")"
L4="$(printf "L4: Grid\n")"
L5="$(printf "L5: Deck\n")"
L6="$(printf "L6: Centered Master\n")"
L7="$(printf "L7: Centered Floating Master\n")"
L8="$(printf "L8: Dwindle\n")"
L9="$(printf "L9: Spiral\n")"
L10="$(printf "L10: Bottom Stack (Vertical)\n")"
L11="$(printf "L11: Bottom Stack (Horizontal)\n")"
L12="$(printf "L12: Grid (Horizontal)\n")"
L13="$(printf "L13: Dynamic Grid\n")"
L14="$(printf "L14: Custom\n")"
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}\nPrevious Layout\nNext Layout\nEnter S expression" | $RUNLAUNCHER -l 21 -p "Pick a layout: ") ;;
"reloadcolors") speedwm -s "#cmd:65" ;;
"list") sed 's|speedwm -s "#cmd:||g; s|"||g; s| - ||g; s@|@-@g' /usr/share/speedwm/example.signal | head -n "$(expr "$(cat /usr/share/speedwm/example.signal | wc -l)" - 1)" ;;
"help") HELP ;;
"exec")
if [ "$2" = "" ]; then
exit 0
else
speedwm -s "#cmd:$2"
fi ;;
"h") HELP ;;
"general") GENERAL ;;
"") OPT ;;
esac
case "$SEL_LAYOUT" in
"Exit") exit 0 ;;
"Previous Layout") speedwm -s "#cmd:16" ;;
"Next Layout") speedwm -s "#cmd:17" ;;
"L1: Tiling") speedwm -s "#cmd:1" ;;
"L2: Floating") speedwm -s "#cmd:2" ;;
"L3: Monocle") speedwm -s "#cmd:3" ;;
"L4: Grid") speedwm -s "#cmd:4" ;;
"L5: Deck") speedwm -s "#cmd:5" ;;
"L6: Centered Master") speedwm -s "#cmd:6" ;;
"L7: Centered Floating Master") speedwm -s "#cmd:7" ;;
"L8: Dwindle") speedwm -s "#cmd:8" ;;
"L9: Spiral") speedwm -s "#cmd:9" ;;
"L10: Bottom Stack (Vertical)") speedwm -s "#cmd:10" ;;
"L11: Bottom Stack (Horizontal)") speedwm -s "#cmd:11" ;;
"L12: Grid (Horizontal)") speedwm -s "#cmd:12" ;;
"L13: Dynamic Grid") speedwm -s "#cmd:13" ;;
"L14: Custom") speedwm -s "#cmd:1" && speedwm -s "#cmd:17" ;;
"Enter S expression") speedwm -s "#cmd:15" ;;
esac

2253
src/speedwm-virtualkeyboard Executable file

File diff suppressed because it is too large Load diff

118
src/speedwm-winnav Executable file
View file

@ -0,0 +1,118 @@
#!/bin/sh
# speedwm-winnav
# Alt+tab navigation for speedwm
#
# This script is from the suckless.org website.
# I made the following changes to it:
# - POSIX compliant
# - Tab goes down, j/k to navigate
# - Removed class from $windows making it look nicer
# - Configuration file
# - dmenu center patch support
# - Other small improvements.
RESTORE() {
if [ -e "${BINDIR}xmodmap" ]; then
xmodmap -e "keycode 23 = Tab"
xmodmap -e "keycode 116 = Down"
# Vim
xmodmap -e "keycode 44 = j"
xmodmap -e "keycode 45 = k"
fi
}
HAVE_GRID="true"
if [ -e "$HOME/.config/speedwm/globalrc" ]; then
. $HOME/.config/speedwm/globalrc
else
mkdir -p $HOME/.config/speedwm/global
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
case "$RUNLAUNCHER" in
"") RUNLAUNCHER=dmenu ;;
esac
BINDIR="$(dirname $(command -v speedwm-core))/"
DOTDIR=$HOME/.config/speedwm/winnav
POSITION="bottom" # top, bottom, center (your $RUNLAUNCHER must support center for this to work)
mkdir -p $HOME/.config/speedwm/winnav
# Create config if it does not exist.
if [ -e "$HOME/.config/speedwm/winnav/config" ]; then
. $HOME/.config/speedwm/winnav/config
else
printf "POSITION=$POSITION # top, bottom, center (Your installed $RUNLAUNCHER must support center (-c) for this to work)" > $HOME/.config/speedwm/winnav/config
fi
# Set position based on config
case "$POSITION" in
"bottom") POSARG="-b" ;;
"top") POSARG="" ;;
"center") POSARG="-c" ;;
esac
# Check if wmctrl is available
if [ -e "${BINDIR}wmctrl" ]; then
echo "wmctrl found"
case "$(wmctrl -xl | wc -l)" in
"") echo "No clients found." ; exit 1 ;;
"1") echo "One client running, will not open menu." ; exit 0 ;;
esac
else
echo "wmctrl not found, exiting." && exit 1
fi
SET() {
if [ -e "${BINDIR}xmodmap" ]; then
xmodmap -e "keycode 23 = Down"
xmodmap -e "keycode 116 = Tab"
# Vim
xmodmap -e "keycode 44 = Down"
xmodmap -e "keycode 45 = Up"
fi
}
SET
windows=$(wmctrl -xl | tr -s '[:blank:]' | cut -d ' ' -f 3-3,5- | sed 's/^[a-zA-Z0-9-]*\.//' | sort | uniq)
echo "Windows are:\n $windows\n============================"
windows_class=$(echo $windows | awk '{ print $1 }')
echo "Class is:\n $windows_class\n============================"
# Add spaces to align the WM_NAMEs of the windows
max=$(echo "$windows" | awk '{cur=length($1); max=(cur>max?cur:max)} END{print max}')
echo "Max is:\n$max"
windows=$(echo "$windows" | \
awk -v max="$max" \
'{cur=length($1); printf $1; \
for(i=0; i < max - cur + 1; i++) printf " "; \
$1 = ""; printf "%s\n", $0}')
target=$(printf "\n$windows" | cut -f 2- -d ' ' | sed 's/^ *//g' | $RUNLAUNCHER $POSARG -l 10 $GRIDARG $GRIDNUM -p "Which window?" | tr -s '[:blank:]' | sed "s/$class | //g")
case "$target" in
"") RESTORE && exit 0 ;;
esac
wmctrl -a "$target" && echo "Switched focus"
# show hidden window
speedwm -s "#cmd:28"
RESTORE