Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a script to to toggle between current wallpaper and live wallpaper using mpvpaper #460

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions config/hypr/UserConfigs/UserKeybinds.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# if you think I should replace the Pre-defined Keybinds in ~/.config/hypr/configs/Keybinds.conf , submit an issue or let me know in DC and present me a valid reason as to why, such as conflicting with global shortcuts, etc etc

# See https://wiki.hyprland.org/Configuring/Keywords/ for more settings and variables
# See also Laptops.conf for laptops keybinds
# See also Laptops.conf for laptops keybinds

$mainMod = SUPER
$files = thunar
Expand All @@ -18,18 +18,19 @@ bind = $mainMod, D, exec, pkill rofi || rofi -show drun -modi drun,filebrowser,r
# ags overview
bind = $mainMod, A, exec, pkill rofi || true && ags -t 'overview'

bind = $mainMod, Return, exec, $term # Launch terminal
bind = $mainMod, T, exec, $files # Launch file manager
bind = $mainMod, Return, exec, $term # Launch terminal
bind = $mainMod, T, exec, $files # Launch file manager

bind = $mainMod ALT, C, exec, $UserScripts/RofiCalc.sh # calculator (qalculate)

# pyprland
bind = $mainMod SHIFT, Return, exec, pypr toggle term # Dropdown terminal
bind = $mainMod, Z, exec, pypr zoom # Toggle Zoom
bind = $mainMod, Z, exec, pypr zoom # Toggle Zoom

# User Added Keybinds
bind = $mainMod SHIFT, O, exec, $UserScripts/ZshChangeTheme.sh # Change oh-my-zsh theme
bind = $mainMod SHIFT, O, exec, $UserScripts/ZshChangeTheme.sh # Change oh-my-zsh theme
bindn = ALT_L, SHIFT_L, exec, $scriptsDir/SwitchKeyboardLayout.sh # Changing the keyboard layout
bind = $mainMod Alt , 2, exec, $UserScripts/livewallpaper.sh

# For passthrough keyboard into a VM
# bind = $mainMod ALT, P, submap, passthru
Expand Down
47 changes: 47 additions & 0 deletions config/hypr/UserScripts/livewallpaper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

# Log output to a file
exec >>~/script_log.txt 2>&1
echo "Script run at: $(date)"

# Define paths for the default wallpaper and the video
DEFAULT_WALLPAPER="$HOME/.config/rofi/.current_wallpaper"
VIDEO_PATH="$HOME/Pictures/wallpapers/livewallpaper/catgirl.mp4"

# Function to restore the wallpaper
restore_wallpaper() {
echo "Restoring normal wallpaper..."
swww-daemon &
swww img "$DEFAULT_WALLPAPER"
}

# Check if mpvpaper is already running
if pgrep mpvpaper >/dev/null; then
echo "mpvpaper is running. Stopping mpvpaper and restoring normal wallpaper..."

# Kill mpvpaper forcefully
pkill -9 mpvpaper
sleep 1 # Wait for a second to ensure it has stopped
restore_wallpaper

else
echo "mpvpaper is not running. Stopping swww-daemon if it's running..."

# Stop swww-daemon if running
if pgrep swww-daemon >/dev/null; then
echo "Stopping swww-daemon..."
pkill -9 swww-daemon
sleep 1 # Wait for a second to ensure it has stopped
else
echo "swww-daemon is not running."
fi

# Check if the video file exists before trying to run mpvpaper
if [[ -f "$VIDEO_PATH" ]]; then
# Run mpvpaper in the background without hardware acceleration
echo "Running mpvpaper without hardware acceleration..."
mpvpaper -o "--no-config --hwdec=no --loop-playlist" '*' "$VIDEO_PATH" & # Add & to run it in the background
else
echo "Error: Video file does not exist at $VIDEO_PATH."
fi
fi
173 changes: 88 additions & 85 deletions upgrade.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash
# /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ #
# for Semi-Manual upgrading your system.
# NOTE: requires rsync

# NOTE: requires rsync

# Set some colors for output messages
OK="$(tput setaf 2)[OK]$(tput sgr0)"
Expand All @@ -14,10 +13,9 @@ ORANGE=$(tput setaf 166)
YELLOW=$(tput setaf 3)
RESET=$(tput sgr0)


# Create Directory for Upgrade Logs
if [ ! -d Upgrade-Logs ]; then
mkdir Upgrade-Logs
mkdir Upgrade-Logs
fi

LOG="Upgrade-Logs/upgrade-$(date +%d-%H%M%S)_upgrade_dotfiles.log"
Expand All @@ -28,66 +26,71 @@ target_dir="$HOME/.config"

# Specify the update source directories, their corresponding target directories, and their exclusions
declare -A directories=(
["config/hypr/"]="$HOME/.config/hypr/"
["config/kitty/"]="$HOME/.config/kitty/"
["config/Kvantum/"]="$HOME/.config/Kvantum/"
["config/nvim/"]="$HOME/.config/nvim/"
["config/qt5ct/"]="$HOME/.config/qt5ct"
["config/qt6ct/"]="$HOME/.config/qt6ct/"
["config/rofi/"]="$HOME/.config/rofi/"
["config/swaync/"]="$HOME/.config/swaync/"
["config/waybar/"]="$HOME/.config/waybar/"
["config/cava/"]="$HOME/.config/cava/"
["config/ags/"]="$HOME/.config/ags/"
["config/fastfetch/"]="$HOME/.config/fastfetch/"
["config/wallust/"]="$HOME/.config/wallust/"
["config/wlogout/"]="$HOME/.config/wlogout/"
# Add more directories to compare as needed
["config/hypr/"]="$HOME/.config/hypr/"
["config/kitty/"]="$HOME/.config/kitty/"
["config/Kvantum/"]="$HOME/.config/Kvantum/"
["config/nvim/"]="$HOME/.config/nvim/"
["config/qt5ct/"]="$HOME/.config/qt5ct"
["config/qt6ct/"]="$HOME/.config/qt6ct/"
["config/rofi/"]="$HOME/.config/rofi/"
["config/swaync/"]="$HOME/.config/swaync/"
["config/waybar/"]="$HOME/.config/waybar/"
["config/cava/"]="$HOME/.config/cava/"
["config/ags/"]="$HOME/.config/ags/"
["config/fastfetch/"]="$HOME/.config/fastfetch/"
["config/wallust/"]="$HOME/.config/wallust/"
["config/wlogout/"]="$HOME/.config/wlogout/"
# Add more directories to compare as needed
)

# Update the exclusion rules
declare -A exclusions=(
["config/hypr/"]="--exclude=UserConfigs/ --exclude=UserScripts/"
["config/waybar/"]="--exclude=config --exclude=style.css"
["config/rofi/"]="--exclude=.current_wallpaper"
# Add more exclusions as needed
["config/hypr/"]="--exclude=UserConfigs/ --exclude=UserScripts/"
["config/waybar/"]="--exclude=config --exclude=style.css"
["config/rofi/"]="--exclude=.current_wallpaper"
["config/cava"]=--exclude=config
["config/nvim"]=--exclude=*
["config/kitty"]=--exclude=*
["config/qt6ct"]=--exclude=*
["config/qt5ct"]=--exclude=*
# Add more exclusions as needed
)

# Function to compare directories
compare_directories() {
local source_dir="$1"
local target_dir="$2"
local exclusion="${exclusions[$source_dir]}" # Get exclusions for the source directory
local source_dir="$1"
local target_dir="$2"
local exclusion="${exclusions[$source_dir]}" # Get exclusions for the source directory

# Perform dry-run comparison using rsync with exclusions
diff=$(rsync -avn --delete "$source_dir" "$target_dir" $exclusion)
echo "$diff"
# Perform dry-run comparison using rsync with exclusions
diff=$(rsync -avn --delete "$source_dir" "$target_dir" $exclusion)
echo "$diff"
}

# Function to create backup of target directory
create_backup() {
local target_dir="$1"
local backup_suffix="-b4-upgrade"
local target_base=$(basename "$target_dir")
local backup_dir="$HOME/.config/${target_base}${backup_suffix}"

if [ -d "$backup_dir" ]; then
echo "$NOTE Updating existing backup of the $target_dir..."
rsync -av --delete "$target_dir" "$backup_dir"
echo "$NOTE $backup_dir Backup updated successfully." 2>&1 | tee -a "$LOG"
else
echo "$NOTE Creating backup of the $target_dir..."
rsync -av --exclude="${backup_suffix}" "$target_dir" "$backup_dir"/
echo "$NOTE $backup_dir Backup created successfully." 2>&1 | tee -a "$LOG"
fi
local target_dir="$1"
local backup_suffix="-b4-upgrade"
local target_base=$(basename "$target_dir")
local backup_dir="$HOME/.config/${target_base}${backup_suffix}"

if [ -d "$backup_dir" ]; then
echo "$NOTE Updating existing backup of the $target_dir..."
rsync -av --delete "$target_dir" "$backup_dir"
echo "$NOTE $backup_dir Backup updated successfully." 2>&1 | tee -a "$LOG"
else
echo "$NOTE Creating backup of the $target_dir..."
rsync -av --exclude="${backup_suffix}" "$target_dir" "$backup_dir"/
echo "$NOTE $backup_dir Backup created successfully." 2>&1 | tee -a "$LOG"
fi
}

# Check if the version file exists in target directory, if not exit
target_version_file=$(find "$target_dir/hypr" -name 'v*' | sort -V | tail -n 1)
if [ -z "$target_version_file" ]; then
echo "$ERROR Version number not found in ~/.config/hypr/" 2>&1 | tee -a "$LOG"
echo "$ERROR Upgrade your dots first by running ./copy.sh" 2>&1 | tee -a "$LOG"
exit 1
echo "$ERROR Version number not found in ~/.config/hypr/" 2>&1 | tee -a "$LOG"
echo "$ERROR Upgrade your dots first by running ./copy.sh" 2>&1 | tee -a "$LOG"
exit 1
fi

# Get the stored version from the target directory
Expand All @@ -102,58 +105,58 @@ version_gt() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }

# Compare versions
if version_gt "$latest_version" "$stored_version"; then
echo "$CAT newer version ($latest_version) is available. Do you want to upgrade? (Y/N)" 2>&1 | tee -a "$LOG"
read -r answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
# Loop through directories for comparison
for source_folder in "${!directories[@]}"; do
target_folder="${directories[$source_folder]}"
echo "$YELLOW Comparing directories: $source_folder and $target_folder" $RESET
# Compare source and target folders
comparison=$(compare_directories "$source_folder" "$target_folder")
if [ -n "$comparison" ]; then
echo "$CAT newer version ($latest_version) is available. Do you want to upgrade? (Y/N)" 2>&1 | tee -a "$LOG"
read -r answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
# Loop through directories for comparison
for source_folder in "${!directories[@]}"; do
target_folder="${directories[$source_folder]}"
echo "$YELLOW Comparing directories: $source_folder and $target_folder" $RESET
# Compare source and target folders
comparison=$(compare_directories "$source_folder" "$target_folder")
if [ -n "$comparison" ]; then
echo "$NOTE Here are difference of $source_folder and $target_folder:"
echo "$comparison"

printf "\n%.0s" {1..2}

# Prompt user for action
echo "$CAT Do you want to copy files and folders from $source_folder to $target_folder? (Y/N)"
read -r answer

if [[ "$answer" =~ ^[Yy]$ ]]; then
# Creating backup of the target folder
create_backup "$target_folder"
printf "\n%.0s" {1..2}
# Copy differences from source folder to target folder
rsync -av --delete ${exclusions[$source_folder]} "$source_folder" "$target_folder"
echo "$NOTE Differences of "$target_folder" copied successfully." 2>&1 | tee -a "$LOG"
printf "\n%.0s" {1..2}
# Creating backup of the target folder
create_backup "$target_folder"

printf "\n%.0s" {1..2}
# Copy differences from source folder to target folder
rsync -av --delete ${exclusions[$source_folder]} "$source_folder" "$target_folder"
echo "$NOTE Differences of "$target_folder" copied successfully." 2>&1 | tee -a "$LOG"
printf "\n%.0s" {1..2}
else
echo "$NOTE No changes were made for $target_folder" 2>&1 | tee -a "$LOG"
fi
else
echo "$OK No differences found between $source_folder and $target_folder" 2>&1 | tee -a "$LOG"
fi
done
printf "\n%.0s" {1..2}
echo "$NOTE Files or Folders updated successfully to version $latest_version" 2>&1 | tee -a "$LOG"

# Set some files as executable
chmod +x ~/.config/hypr/scripts/* 2>&1 | tee -a "$LOG"
chmod +x ~/.config/hypr/UserScripts/* 2>&1 | tee -a "$LOG"
chmod +x ~/.config/hypr/initial-boot.sh 2>&1 | tee -a "$LOG"
else
echo "$ORANGE Upgrade declined. No files or folders changed" 2>&1 | tee -a "$LOG"
fi
echo "$NOTE No changes were made for $target_folder" 2>&1 | tee -a "$LOG"
fi
else
echo "$OK No differences found between $source_folder and $target_folder" 2>&1 | tee -a "$LOG"
fi
done
printf "\n%.0s" {1..2}
echo "$NOTE Files or Folders updated successfully to version $latest_version" 2>&1 | tee -a "$LOG"

# Set some files as executable
chmod +x ~/.config/hypr/scripts/* 2>&1 | tee -a "$LOG"
chmod +x ~/.config/hypr/UserScripts/* 2>&1 | tee -a "$LOG"
chmod +x ~/.config/hypr/initial-boot.sh 2>&1 | tee -a "$LOG"

else
echo "$ORANGE Upgrade declined. No files or folders changed" 2>&1 | tee -a "$LOG"
fi
else
echo "$OK No upgrade found. The installed version ($stored_version) is up to date with the Hyprland-Dots version ($latest_version)." 2>&1 | tee -a "$LOG"
echo "$OK No upgrade found. The installed version ($stored_version) is up to date with the Hyprland-Dots version ($latest_version)." 2>&1 | tee -a "$LOG"
fi

printf "\n%.0s" {1..3}
echo "$(tput bold)$(tput setaf 3)ATTENTION!!!! VERY IMPORTANT NOTICE!!!! $(tput sgr0)"
echo "$(tput bold)$(tput setaf 3)ATTENTION!!!! VERY IMPORTANT NOTICE!!!! $(tput sgr0)"
echo "$(tput bold)$(tput setaf 7)If you updated waybar folder, and you have your own waybar layout and styles $(tput sgr0)"
echo "$(tput bold)$(tput setaf 7)Copy those files from the created backup ~/.config/waybar-b4-upgrade $(tput sgr0)"
echo "$(tput bold)$(tput setaf 7)Make sure to set your waybar and style before logout or reboot $(tput sgr0)"
Expand Down
Binary file added wallpapers/livewallpaper/bluecomp.mp4
Binary file not shown.
Binary file added wallpapers/livewallpaper/catgirl.mp4
Binary file not shown.