From b27f3fa74485d9c69a88edb4bd12388d8540650d Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 30 Mar 2026 19:40:32 +0100 Subject: [PATCH] Backgrounds --- .config/hypr/autostart.conf | 2 +- .local/bin/nixos-todo/splitbg | 29 ------------------------- .local/bin/station-bg-random | 5 +++-- .local/bin/station-bg-set | 11 +++++++++- .local/bin/station-bg-split | 40 +++++++++++++++++++++++++++++++++++ 5 files changed, 54 insertions(+), 33 deletions(-) delete mode 100755 .local/bin/nixos-todo/splitbg create mode 100755 .local/bin/station-bg-split diff --git a/.config/hypr/autostart.conf b/.config/hypr/autostart.conf index 5786fc5..1fef234 100644 --- a/.config/hypr/autostart.conf +++ b/.config/hypr/autostart.conf @@ -3,7 +3,7 @@ exec-once = uwsm-app -- mako exec-once = Enpass # exec-once = uwsm-app -- waybar exec-once = uwsm-app -- fcitx5 --disable notificationitem -exec-once = uwsm-app -- swaybg -i ~/.config/station/current/background -m fill +exec-once = station-bg-random exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 # Slow app launch fix -- set systemd vars diff --git a/.local/bin/nixos-todo/splitbg b/.local/bin/nixos-todo/splitbg deleted file mode 100755 index cf27478..0000000 --- a/.local/bin/nixos-todo/splitbg +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -input_dir="$1" # Replace with your input directory path -output_dir="$2" # Replace with your output directory path - -# Ensure the output directory exists or create it -mkdir -p "$output_dir" - -# Loop through all JPEG files in the input directory -for file in "$input_dir"/*.jpg; do - if [ -e "$file" ]; then - filename=$(basename "$file") - filename_without_extension="${filename%.*}" - output_file1="$output_dir/${filename_without_extension}_left.jpg" - output_file2="$output_dir/${filename_without_extension}_right.jpg" - - # Get the width of the image - width=$(identify -format "%w" "$file") - - # Use ImageMagick to split the image in half - convert "$file" -crop "50%x100%+0+0" "$output_file1" - convert "$file" -crop "50%x100%+$((width / 2))+0" "$output_file2" - - echo "Split $filename into $output_file1 and $output_file2" - fi -done - -echo "Splitting completed." - diff --git a/.local/bin/station-bg-random b/.local/bin/station-bg-random index 4bcc0a8..6391c36 100755 --- a/.local/bin/station-bg-random +++ b/.local/bin/station-bg-random @@ -2,8 +2,9 @@ # Picks and sets a random background -BACKGROUNDS_PATH="$HOME/Tower/Library/Pictures/Wallpapers/3840x2160/" -CURRENT_BACKGROUND_LINK="$HOME/.local/state/station/background" +width=$(hyprctl monitors -j | jq 'map(.width) | add') +height=$(hyprctl monitors -j | jq '.[0].height') +BACKGROUNDS_PATH="$HOME/Tower/Library/Pictures/Wallpapers/${width}x${height}/" mapfile -d '' -t BACKGROUNDS < <(find -L "$BACKGROUNDS_PATH" -maxdepth 1 -type f -print0 2>/dev/null | sort -z) TOTAL=${#BACKGROUNDS[@]} diff --git a/.local/bin/station-bg-set b/.local/bin/station-bg-set index a4ff332..ef49a69 100755 --- a/.local/bin/station-bg-set +++ b/.local/bin/station-bg-set @@ -17,4 +17,13 @@ wal -i "$CURRENT_BACKGROUND_LINK" # Kill existing swaybg and start new one pkill -x swaybg -setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 & + +if [[ $(hyprctl monitors -j | jq 'length') -eq 2 ]]; then + station-bg-split "$CURRENT_BACKGROUND_LINK" "/tmp/bg" + first_mon=$(hyprctl monitors -j | jq -r '.[0].name') + second_mon=$(hyprctl monitors -j | jq -r '.[1].name') + setsid uwsm-app -- swaybg -o "$first_mon" -i /tmp/bg/background_left -m fill >/dev/null 2>&1 & + setsid uwsm-app -- swaybg -o "$second_mon" -i /tmp/bg/background_right -m fill >/dev/null 2>&1 & +else + setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 & +fi diff --git a/.local/bin/station-bg-split b/.local/bin/station-bg-split new file mode 100755 index 0000000..e4cd715 --- /dev/null +++ b/.local/bin/station-bg-split @@ -0,0 +1,40 @@ +#!/bin/bash + +input="$1" # Replace with your input directory path +output_dir="$2" # Replace with your output directory path + +# Ensure the output directory exists or create it +mkdir -p "$output_dir" + +split_img() { + file=$1 + filename=$(basename "$file") + filename_without_extension="${filename%.*}" + extension="${filename##$filename_without_extension}" + output_file1="$output_dir/${filename_without_extension}_left${extension}" + output_file2="$output_dir/${filename_without_extension}_right${extension}" + + # Get the width of the image + width=$(identify -format "%w" "$file") + + # Use ImageMagick to split the image in half + magick "$file" -crop "50%x100%+0+0" "$output_file1" + magick "$file" -crop "50%x100%+$((width / 2))+0" "$output_file2" + + echo "Split $filename into $output_file1 and $output_file2" +} + +# Loop through all JPEG files in the input directory +if [[ -d $input ]]; then + echo "Processing images in directory: $input" + for file in "$input/*.(jpg|jpeg|png)"; do + if [ -e "$file" ]; then + split_img "$file" + fi + done +else + split_img $input +fi + +echo "Splitting completed." +