Backgrounds

This commit is contained in:
2026-03-30 19:40:32 +01:00
parent 1c845777e8
commit b27f3fa744
5 changed files with 54 additions and 33 deletions

View File

@@ -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

View File

@@ -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."

View File

@@ -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[@]}

View File

@@ -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

40
.local/bin/station-bg-split Executable file
View File

@@ -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."