Created
January 7, 2025 20:37
-
-
Save killajoe/f8acec20abb6ff0f78dc846334635b92 to your computer and use it in GitHub Desktop.
adding EndavourOS wallpaper properly for each detected display and all 4 workspaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Path to the configuration file | |
CONFIG_FILE="$HOME/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml" | |
# Path to the wallpaper image | |
IMAGE_PATH="/usr/share/endeavouros/backgrounds/endeavouros-wallpaper-dark.png" | |
# Get the list of connected monitors using xrandr | |
MONITORS=$(xrandr | grep ' connected' | awk '{print $1}') | |
echo "Detected monitors: $MONITORS" | |
# Initialize the new content for the configuration file | |
NEW_CONTENT="" | |
MONITOR_XML="" | |
# Read the original file into a variable | |
ORIGINAL_CONTENT=$(cat "$CONFIG_FILE") | |
# Debug: print the original content for verification | |
echo "Original content:" | |
echo "$ORIGINAL_CONTENT" | |
# Prepare the monitor XML sections | |
for MONITOR in $MONITORS; do | |
MONITOR_NAME="monitor$MONITOR" | |
MONITOR_XML+="\t\t<property name=\"$MONITOR_NAME\" type=\"empty\"> | |
\t\t\t<property name=\"workspace0\" type=\"empty\"> | |
\t\t\t\t<property name=\"last-image\" type=\"string\" value=\"$IMAGE_PATH\"/></property> | |
\t\t\t<property name=\"workspace1\" type=\"empty\"> | |
\t\t\t\t<property name=\"last-image\" type=\"string\" value=\"$IMAGE_PATH\"/></property> | |
\t\t\t<property name=\"workspace2\" type=\"empty\"> | |
\t\t\t\t<property name=\"last-image\" type=\"string\" value=\"$IMAGE_PATH\"/></property> | |
\t\t\t<property name=\"workspace3\" type=\"empty\"> | |
\t\t\t\t<property name=\"last-image\" type=\"string\" value=\"$IMAGE_PATH\"/></property> | |
\t\t\t<property name=\"workspace4\" type=\"empty\"> | |
\t\t\t\t<property name=\"last-image\" type=\"string\" value=\"$IMAGE_PATH\"/></property> | |
\t\t</property>\n" | |
done | |
# Insert the monitor XML sections into the original content before the specified part | |
NEW_CONTENT=$(echo "$ORIGINAL_CONTENT" | awk -v insert="$MONITOR_XML" ' | |
/<property name="monitor" type="empty">/ { | |
print insert | |
found=1 | |
} | |
{print} | |
') | |
# Write the modified content back to the file | |
echo -e "$NEW_CONTENT" > "$CONFIG_FILE" | |
echo "Configuration updated for all monitors and workspaces." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment