Make verbose and add spinner
This commit is contained in:
parent
b74235d9de
commit
e8efad0d86
@ -1,18 +1,53 @@
|
||||
#!/bin/bash
|
||||
# This script is used to change the background of the desktop
|
||||
#
|
||||
# 2025, Raoul Branten
|
||||
|
||||
# Generate a background image using xstarfish
|
||||
# Function to show a spinning cursor
|
||||
spinner() {
|
||||
local pid=$1
|
||||
local delay=0.1
|
||||
local spinstr='|/-\'
|
||||
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
|
||||
local temp=${spinstr#?}
|
||||
printf " [%c] " "$spinstr"
|
||||
local spinstr=$temp${spinstr%"$temp"}
|
||||
echo -en "\b\b\b\b\b\b"
|
||||
sleep $delay
|
||||
done
|
||||
printf " \b\b\b\b"
|
||||
}
|
||||
|
||||
echo "[1/4] Getting screen resolution..."
|
||||
# get screen resolution using xdpyinfo to get info from X server
|
||||
SCREENWIDTH=$(xdpyinfo | awk '/dimensions/{print $2}' | grep -oE ^[[:digit:]]\+)
|
||||
SCREENHEIGHT=$(xdpyinfo | awk '/dimensions/{print $2}' | grep -oE [[:digit:]]\+$)
|
||||
SIZE="${SCREENWIDTH}x${SCREENHEIGHT}"
|
||||
echo " Screen resolution: $SIZE"
|
||||
|
||||
echo "[2/4] Checking for xstarfish..."
|
||||
# check if xstarfish is installed
|
||||
if [ -f /usr/bin/xstarfish ]; then
|
||||
/usr/bin/xstarfish -g $SIZE -o /tmp/background.jpg
|
||||
echo "[3/4] Generating background image..."
|
||||
# Generate a background image using xstarfish
|
||||
/usr/bin/xstarfish -g $SIZE -o /tmp/background.jpg &
|
||||
spinner $!
|
||||
else
|
||||
echo "ERROR: xstarfish not found"
|
||||
echo "ERROR: xstarfish not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Change the background image
|
||||
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorHDMI-1-0/workspace0/last-image -s /tmp/background.jpg
|
||||
echo "[4/4] Setting background on all displays..."
|
||||
# get all possible displays
|
||||
# use xfconf-query to generate a list of all possible displays
|
||||
# then use grep to cut out the correct path
|
||||
# sort is used for unique results
|
||||
BACKDROP=$(xfconf-query --channel xfce4-desktop --list | grep -E -o '/backdrop/screen0/monitor[a-zA-Z0-1-]+/workspace0/last-image' | sort -u)
|
||||
|
||||
# foreach display set the background image to the generated image
|
||||
while IFS= read -r line; do
|
||||
# set the background image
|
||||
xfconf-query -c xfce4-desktop -p $line -s /tmp/background.jpg
|
||||
echo " Set background for display: $line"
|
||||
done <<< "$BACKDROP"
|
||||
|
||||
echo "✓ Background change completed successfully!"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user