mirror of
https://github.com/elenapan/dotfiles.git
synced 2025-12-26 23:34:57 +08:00
Former-commit-id: 46c2bf7d26
Former-commit-id: ec0b4e689f3f8e97d837848929a1a6a9e45f779b
Former-commit-id: 19f055447f5fd666a270a51cf98b05d70716e826
108 lines
2.8 KiB
Bash
Executable file
108 lines
2.8 KiB
Bash
Executable file
#!/bin/bash
|
|
# Requires wal or pywal (github)
|
|
|
|
# Run like this
|
|
# wally /path/to/wallpaper/or/directory
|
|
# examples:
|
|
# wally ~/Pictures/Wallpapers
|
|
# wally .
|
|
# wally ~/Pictures/Wallpapers/pape.jpg
|
|
# wally -f ~/path/to/color/file ~/path/to/wallpaper
|
|
|
|
# Arguments checking
|
|
if [ $# == 0 ]; then
|
|
echo "> No path to wallpaper or directory specified :("
|
|
exit 0;
|
|
fi
|
|
|
|
if [[ "$1" = "-c" ]]; then
|
|
echo "> Cleaning backups and exiting."
|
|
rm -rf ~/.wally/wally_backup-*
|
|
exit 0;
|
|
fi
|
|
|
|
# Create backup of linked files
|
|
echo "> Backing up linked files"
|
|
TIMESTAMP="$(date +%F-%H:%M:%S)"
|
|
cp -r -L ~/.wally/links ~/.wally/wally_backup-$TIMESTAMP
|
|
cp ~/.wally/path_to_wallpaper ~/.wally/wally_backup-$TIMESTAMP
|
|
|
|
# TODO!
|
|
# To restore backups "cp -L desired_backup_dir/* ~/.wally/links"
|
|
# And then "wally wallpaper_of_backed_up_dir"
|
|
|
|
# Declare arrays
|
|
declare -a color
|
|
declare -a XCOLOR_OLD
|
|
declare -a XCOLOR_NEW
|
|
|
|
# Grab old Xresources colors
|
|
for (( i = 0; i < 8; i++ )); do
|
|
color[$i]="$(echo color$i)"
|
|
XCOLOR_OLD[$i]="$(cat ~/.Xresources | grep -m 1 ${color[$i]} | awk '{print $2}')"
|
|
done
|
|
|
|
# Call wal to generate new colors
|
|
if [[ "$1" = "-f" ]]; then
|
|
COLORS_PATH=$2
|
|
echo "> Applying custom terminal colorscheme from $COLORS_PATH..."
|
|
wal -f $COLORS_PATH
|
|
PAPE_PATH=$3
|
|
echo "> Setting $PAPE_PATH as wallpaper..."
|
|
feh --bg-fill $3
|
|
else
|
|
ARG=$1
|
|
echo "> Calling wal at $ARG... toot toot..."
|
|
wal -i $ARG
|
|
feh --bg-fill $ARG
|
|
echo "> New colorscheme generated!"
|
|
fi
|
|
|
|
# Apply new colors to Xresources
|
|
echo "> Setting .Xresources..."
|
|
cp ~/.wally/Xresources-clean ~/.wally/Xresources-new
|
|
cat ~/.cache/wal/colors.xresources >> ~/.wally/Xresources-new
|
|
cp ~/.wally/Xresources-new ~/.Xresources
|
|
reloadXr
|
|
echo "> New .Xresources set!"
|
|
|
|
# Grab new Xresources colors
|
|
for (( i = 0; i < 8; i++ )); do
|
|
XCOLOR_NEW[$i]="$(cat ~/.Xresources | grep -m 1 ${color[$i]} | awk '{print $2}')"
|
|
done
|
|
|
|
# Replace colors to all linked files in wally's folder
|
|
for (( i = 0; i < 8; i++ )); do
|
|
sed -i --follow-symlinks "s@${XCOLOR_OLD[$i]}@${XCOLOR_NEW[$i]}@gI" ~/.wally/links/*
|
|
done
|
|
|
|
# Restart tint2 to reload config file
|
|
tint2restart
|
|
echo "> tint2 has restarted!"
|
|
|
|
# Reconfigure openbox to reload theme
|
|
# Template: ~/.local/share/themes/thebox/openbox-3/themerc
|
|
openbox --reconfigure
|
|
echo "> Openbox is reconfigured!"
|
|
|
|
# Restarting dunst so it reloads config file
|
|
dunst_restart
|
|
|
|
# Create steam theme
|
|
python3 ~/Programs/wal_steam/mywalsteam.py -w
|
|
echo "> Generated steam theme!"
|
|
|
|
# Copy new wallpaper path to wally's directory
|
|
if [[ "$1" = "-f" ]]; then
|
|
CUSTOMPAPEPATH="$(readlink -f $3)"
|
|
echo $CUSTOMPAPEPATH > ~/.wally/path_to_wallpaper
|
|
else
|
|
cp ~/.cache/wal/wal ~/.wally/path_to_wallpaper
|
|
fi
|
|
WALLPAPER="$(cat ~/.wally/path_to_wallpaper)"
|
|
|
|
# Display new colors with a color script
|
|
# (other good scripts: spectrum, colortest)
|
|
~/Scripts/Color/colortest
|
|
echo "> Current wallpaper: $WALLPAPER"
|
|
echo "> All done :)"
|