A custom action for thunar. To set mbwallpaper dir.
#!/bin/bash
# Define the config file path
CONFIG_FILE="$HOME/.config/mbwallpaper/mbwallpaper.conf"
# Check if a directory is selected
if [ -z "$1" ]; then
echo "No directory selected."
exit 1
fi
# Check if the config file exists; if not, create the directory and the file
if [ ! -f "$CONFIG_FILE" ]; then
mkdir -p "$(dirname "$CONFIG_FILE")" # Create the directory if it doesn't exist
touch "$CONFIG_FILE" # Create the config file
echo "Config file created at: $CONFIG_FILE"
fi
# Write the selected directory to the config file, replacing the existing wallpaper_dir value
# If the line containing wallpaper_dir already exists, replace it. If not, ap#!/bin/bash
# Define the config file path
CONFIG_FILE="$HOME/.config/mbwallpaper/mbwallpaper.conf"
# Check if a directory is selected
if [ -z "$1" ]; then
echo "No directory selected."
exit 1
fi
# Check if the config file exists; if not, create the directory and the file
if [ ! -f "$CONFIG_FILE" ]; then
mkdir -p "$(dirname "$CONFIG_FILE")" # Create the directory if it doesn't exist
touch "$CONFIG_FILE" # Create the config file
echo "Config file created at: $CONFIG_FILE"
fi
# Write the selected directory to the config file, replacing the existing wallpaper_dir value
# If the line containing wallpaper_dir already exists, replace it. If not, append it.
grep -q "^wallpaper_dir=" "$CONFIG_FILE"
if [ $? -eq 0 ]; then
# If the line exists, replace it
sed -i "s|^wallpaper_dir=.*|wallpaper_dir=\"$1\"|" "$CONFIG_FILE"
else
# If the line doesn't exist, append it
echo "wallpaper_dir=\"$1\"" >> "$CONFIG_FILE"
fi
# Notify the user
notify-send -t 5000 -i wallpaper "Wallpaper directory has been set to: " "$1"
pend it.
grep -q "^wallpaper_dir=" "$CONFIG_FILE"
if [ $? -eq 0 ]; then
# If the line exists, replace it
sed -i "s|^wallpaper_dir=.*|wallpaper_dir=\"$1\"|" "$CONFIG_FILE"
else
# If the line doesn't exist, append it
echo "wallpaper_dir=\"$1\"" >> "$CONFIG_FILE"
fi
# Notify the user
notify-send -t 5000 -i wallpaper "Wallpaper directory has been set to: " "$1"
yad-icon-browser