speedwm-mkpage: Auto-pushed speedwm changes!

This commit is contained in:
speedie 2022-09-02 00:51:45 +02:00
parent 9dca431279
commit 73c0f435fd
4 changed files with 575 additions and 2 deletions

154
4443480134.patch Normal file
View file

@ -0,0 +1,154 @@
From 4443480134d1fbca7ac895db5d5fd599a6591f60 Mon Sep 17 00:00:00 2001
From: speedie <speedie@duck.com>
Date: Thu, 1 Sep 2022 21:38:18 +0200
Subject: [PATCH] Switch to using command -v instead of bindir for a few
executables may do this for more scripts
---
scripts/speedwm-swal | 49 +++++++++++++++-----------------------------
1 file changed, 17 insertions(+), 32 deletions(-)
diff --git a/scripts/speedwm-swal b/scripts/speedwm-swal
index 4af080f..f26d86c 100755
--- a/scripts/speedwm-swal
+++ b/scripts/speedwm-swal
@@ -12,7 +12,7 @@ SWAL_DEFAULT_CONFIG()
"") RUNLAUNCHER=dmenu ;;
esac
SWAL_OPT=xwallpaper
- SWAL_BINDIR=$BINDIR
+ SWAL_BINDIR=$BINDIR # compatibility with old config files
SWAL_EXPORTDIR=$HOME/.config/speedwm-de/swal # Config directory
SWAL_FSIGNAL_RELOAD_XRESOURCES=18 # Fsignal signum when reloading
SWAL_IMAGE_VIEWER="sxiv -to" # Image viewer to use (<char>)
@@ -24,6 +24,7 @@ SWAL_DEFAULT_CONFIG()
HAVE_GRID="true"
if [ -e "$HOME/.config/speedwm-de/global/config" ]; then
. $HOME/.config/speedwm-de/global/config
+ echo "Loaded configuration!"
else
mkdir -p $HOME/.config/speedwm-de/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-de/global/config
@@ -91,7 +92,6 @@ SWAL_MKCONFIG() {
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_BINDIR=$SWAL_BINDIR" >> $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
@@ -109,7 +109,7 @@ SOLIDCOLOR() {
rm -f $SWAL_EXPORTDIR/swal_wm
xrdb -remove
xsetroot -name "fsignal:31"
- test ${BINDIR}notify-send && notify-send " Solid color $ISCOL set as wallpaper."
+ command -v notify-send > /dev/null && notify-send " Solid color $ISCOL set as wallpaper."
exit 0
}
@@ -129,11 +129,14 @@ SWAL_SOURCE()
SWAL_CHECK()
{
if [ "$SWAL_IMAGE_VIEWER" = "" ]; then
- ls "$SWAL_BINDIR/feh" && SWAL_IMAGE_VIEWER=feh
- ls "$SWAL_BINDIR/sxiv" && SWAL_IMAGE_VIEWER=sxiv
+ if [ -e "${BINDIR}feh" ]; then
+ SWAL_IMAGE_VIEWER=feh
+ elif [ -e "${BINDIR}sxiv" ]; then
+ SWAL_IMAGE_VIEWER=sxiv
+ fi
fi
- ls "$SWAL_BINDIR/xwallpaper" || SWAL_DIE
+ command -v xwallpaper > /dev/null || SWAL_DIE
}
# Die
@@ -142,14 +145,6 @@ SWAL_DIE()
SWAL_EXIT=1 && exit 1
}
-# Print help
-SWAL_HELP() {
- echo "swal is a minimal xwallpaper frontend for $RUNLAUNCHER."
- echo "-h | View this help screen."
- echo "-r | Randomize wallpaper."
- echo "-p | Set previous wallpaper."
-}
-
# 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."
@@ -163,11 +158,7 @@ SWAL_USAGE() {
# Select wallpaper
SWAL_SELWALLPAPER()
{
- case "$NEW1" in
- "") ls /tmp/swal_cpath || SWAL_SELWALLPAPER="$(printf "$(ls "$SWAL_WALLPAPERDIR")\n------\n..\nPreview\nPrevious\nSolid Color\nRandom\nFavorites\nAdd used wallpaper to favorites\nOptions\nHelp\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 100 -p "What wallpaper would you like to set?")" ;;
- "-h") SWAL_HELP | $RUNLAUNCHER $GRIDARG $GRIDNUM 1 -l 90 ;;
- "-p") SWAL_SELWALLPAPER="Random" ; SWAL_ASK_TYPE="false" ;;
- esac
+ SWAL_SELWALLPAPER="$(printf "$(ls "$SWAL_WALLPAPERDIR")\n------\n..\nPreview\nPrevious\nSolid Color\nRandom\nFavorites\nAdd used wallpaper to favorites\nOptions\nHelp\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 100 -p "What wallpaper would you like to set?")"
}
# Set the type/check what was selected.
@@ -217,7 +208,7 @@ SWAL_SETTYPE()
# Fail if the wallpaper is not a proper wallpaper.
FAIL_NOT_REAL() {
- test ${BINDIR}notify-send && notify-send "The selected wallpaper is not valid/does not exist."
+ command -v notify-send > /dev/null && notify-send "The selected wallpaper is not valid/does not exist."
$0 ; exit 1
}
@@ -265,6 +256,7 @@ 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
@@ -292,6 +284,7 @@ SWAL_EXPORT_SCRIPT()
chmod +x $SWAL_EXPORTDIR/swal_wm
}
+# Export script to autostart on login for Pywal users
SWAL_EXPORT_SCRIPT_WAL()
{
if [ "$SWAL_RANDOMIZE" = "false" ]; then
@@ -336,30 +329,22 @@ SWAL_EXPORT_SCRIPT_WAL()
speedwm_run -loadconfig # For speedie.gq/speedwm
speedwm_run -rnoload # For speedie.gq/speedwm
- pgrep -x status && pkill status ; status &
-}
-
-
-SWAL_XRESOURCES()
-{
- xrdb -query | grep "swal" | sed "s|: |=|" | sed "s|swal.|swal_|" > /tmp/swal
- . /tmp/swal
+ pgrep -x status && pkill status ; status & # For speedie.gq/speedwm
}
+# Send notification
SWAL_SENDNOTIFICATION() {
if [ "$SWAL_SELWAL" = "" ]; then
- test ${BINDIR}notify-send && notify-send " $SWAL_SELWALLPAPER set as wallpaper in $(echo $SWAL_TYPE | sed "s|--||g") mode."
+ command -v notify-send > /dev/null && notify-send " $SWAL_SELWALLPAPER set as wallpaper in $(echo $SWAL_TYPE | sed "s|--||g") mode."
else
- test ${BINDIR}notify-send && notify-send " $SWAL_SELWAL set as wallpaper in $(echo $SWAL_TYPE | sed "s|--||g") mode."
+ command -v notify-send > /dev/null && notify-send " $SWAL_SELWAL set as wallpaper in $(echo $SWAL_TYPE | sed "s|--||g") mode."
fi
exit 0
}
-rm -f /tmp/swal_cpath
SWAL_DEFAULT_CONFIG
SWAL_SOURCE || SWAL_DIE
-SWAL_XRESOURCES
SWAL_CHECK || SWAL_DIE
SWAL_SELWALLPAPER || SWAL_DIE

View file

@ -119,7 +119,7 @@ Below is a list of all speedwm keybinds.
- Super+Control+r | Switch to layout 1 (Monocle)
- Super+Control+t | Switch to layout 0 (Master & stack)
- Super+Control+y | Switch to layout 4 (Deck)
- Super+Control+0 | Set all windows to use the same tag
- Super+Control+0 | View all windows at once.
- Super+Control+Arrow | Moves a window to any corner of your screen (Arrow key)
- Super+Control+Tab | Open a dmenu prompt asking the user what layout to switch to
- Super+Control+h | Open a list of all keybinds in your terminal using less
@ -162,7 +162,7 @@ Below is a list of all speedwm keybinds.
- Email button | Open your defined email client
- System button | Open your defined status viewer in a terminal
### Mouse
-- Mouse --
These binds can be activated using your mouse
@ -176,6 +176,7 @@ Below is a list of all speedwm keybinds.
- Focused window (Super+Alt+Middle click) | Make the focused window floating
- Focused window title (Middle click) | Rotate stack
- Dragging (Super+Right click) | Increase/decrease size of each window
- Dragging (SuperControl+Right click) | Increase/decrease cfact
There are also keybinds for statuscmd, but you must implement it into your own status bar.
See mouse.h for more information.
@ -324,6 +325,7 @@ Note that the 'xrdb' dependency is required for both pywal and .Xresources suppo
- speedwm.mfact: 0.50
- speedwm.startontag: 1
- speedwm.clicktofocus: 0
- speedwm.focusspawn: 0
- speedwm.enablegaps: 1
- speedwm.smartgaps: 0
- speedwm.smartgapsize: 0

371
scripts/speedwm-swal.orig Executable file
View file

@ -0,0 +1,371 @@
#!/bin/sh
# speedwm-swal
# wallpaper utility written for speedwm.
# Licensed under the GNU GPLv3 free software license.
# 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_BINDIR=$BINDIR # compatibility with old config files
SWAL_EXPORTDIR=$HOME/.config/speedwm-de/swal # Config directory
SWAL_FSIGNAL_RELOAD_XRESOURCES=18 # Fsignal signum when reloading
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-de/global/config" ]; then
. $HOME/.config/speedwm-de/global/config
echo "Loaded configuration!"
else
mkdir -p $HOME/.config/speedwm-de/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-de/global/config
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
}
# use a solid color
SWAL_SOLIDCOLOR() {
ISCOL="$(printf "#000000\n#bbbbbb" | $RUNLAUNCHER -l 2 $GRIDARG $GRIDNUM -p "Enter a hex color:")"
echo $ISCOL | grep -q "#" || exit 1
xwallpaper --clear
xsetroot -solid "$ISCOL"
rm -f $SWAL_EXPORTDIR/swal_wm
xrdb -remove
xsetroot -name "fsignal:31"
printf "#!/bin/sh\nxsetroot -solid "$ISCOL"" > $SWAL_EXPORTDIR/swal_wm
command -v notify-send > /dev/null && notify-send " Solid color $ISCOL set as wallpaper."
exit 0
}
# Binary directory
BINDIR=$(cat /usr/share/speedwm-bindir)
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 [ -e "${BINDIR}feh" ]; then
SWAL_IMAGE_VIEWER=feh
elif [ -e "${BINDIR}sxiv" ]; then
SWAL_IMAGE_VIEWER=sxiv
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()
{
SWAL_SELWALLPAPER="$(printf "$(ls "$SWAL_WALLPAPERDIR")\n------\n..\nPreview\nPrevious\nSolid Color\nRandom\nFavorites\nAdd used wallpaper to favorites\nOptions\nHelp\nExit" | $RUNLAUNCHER $GRIDARG $GRIDNUM -l 100 -p "What wallpaper would you like to set?")"
}
# Set the type/check what was selected.
SWAL_SETTYPE()
{
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 ;;
"Solid Color") SWAL_SOLIDCOLOR ;;
"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
SWAL_TYPE=$(printf "Center\nTile\nZoom\nStretch\n------\nExit" | $RUNLAUNCHER -p "How do you want to set the wallpaper?" $GRIDARG $GRIDNUM -l 7)
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.
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
# 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\nxsetroot -name 'fsignal:$SWAL_FSIGNAL_RELOAD_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 "\nxsetroot -name "fsignal:$SWAL_FSIGNAL_RELOAD_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 && xsetroot -name "fsignal:$SWAL_FSIGNAL_RELOAD_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
if [ -e "$HOME/.config/speedwm-de/speedwmrc" ]; then
. $HOME/.config/speedwm-de/speedwmrc
fi
command -v wal > /dev/null && wal -nqi "$SWAL_WALLPAPERDIR/$SWAL_SELWALLPAPER"
# Reload dmenu colors if supported
command -v ${RUNLAUNCHER}_run > /dev/null && grep "PYWAL" ${BINDIR}${RUNLAUNCHER}_run && printf "\n${RUNLAUNCHER}_run -r" >> $SWAL_EXPORTDIR/swal_wm
command -v ${RUNLAUNCHER}_run > /dev/null && ${RUNLAUNCHER}_run -r # For speedie.gq/dmenu
command -v speedwm_run > /dev/null && speedwm_run -loadconfig # For speedie.gq/speedwm
command -v speedwm_run > /dev/null && speedwm_run -rnoload # For speedie.gq/speedwm
pgrep -x status && pkill status ; status & # For speedie.gq/speedwm
pgrep -x stellar && pkill stellar ; stellar & # For speedie.gq/stellar
}
# 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 > /dev/null
$0 && exit 0

46
scripts/speedwm-swal.rej Normal file
View file

@ -0,0 +1,46 @@
--- speedwm-swal
+++ speedwm-swal
@@ -109,7 +109,7 @@ SOLIDCOLOR() {
rm -f $SWAL_EXPORTDIR/swal_wm
xrdb -remove
xsetroot -name "fsignal:31"
- command -v notify-send > /dev/null && notify-send " Solid color $ISCOL set as wallpaper."
+ test ${BINDIR}notify-send && notify-send " Solid color $ISCOL set as wallpaper."
exit 0
}
@@ -336,22 +343,30 @@ SWAL_EXPORT_SCRIPT_WAL()
speedwm_run -loadconfig # For speedie.gq/speedwm
speedwm_run -rnoload # For speedie.gq/speedwm
- pgrep -x status && pkill status ; status & # For speedie.gq/speedwm
+ pgrep -x status && pkill status ; status &
+}
+
+
+SWAL_XRESOURCES()
+{
+ xrdb -query | grep "swal" | sed "s|: |=|" | sed "s|swal.|swal_|" > /tmp/swal
+ . /tmp/swal
}
-# 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."
+ test ${BINDIR}notify-send && 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."
+ test ${BINDIR}notify-send && notify-send " $SWAL_SELWAL set as wallpaper in $(echo $SWAL_TYPE | sed "s|--||g") mode."
fi
exit 0
}
+rm -f /tmp/swal_cpath
SWAL_DEFAULT_CONFIG
SWAL_SOURCE || SWAL_DIE
+SWAL_XRESOURCES
SWAL_CHECK || SWAL_DIE
SWAL_SELWALLPAPER || SWAL_DIE