randwall 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/usr/bin/env bash
  2. # Kill any existing swaybg or feh instances
  3. pkill swaybg
  4. pkill feh
  5. # Function to set wallpaper using swaybg on Sway
  6. set_wallpaper_sway() {
  7. if [ "$(hostname)" == "main" ]; then
  8. swaymsg -t get_outputs -r | jq -r ".[].name" | parallel 'swaybg -o {} -i $(find ~/Pictures/* -type f | shuf -n 1) &'
  9. elif [ "$(hostname)" == "fw" ]; then
  10. swaybg -m fill -i "/home/mzunino/Pictures/hwtioswoamne1.jpeg"
  11. fi
  12. }
  13. # Function to set wallpaper using swaybg on Hyprland
  14. set_wallpaper_hyprland() {
  15. hyprctl monitors -j | jq -r ".[].name" | parallel 'swaybg -o {} -i $(find ~/Pictures/* -type f | shuf -n 1) &'
  16. }
  17. # Function to set wallpaper using feh on i3
  18. set_wallpaper_i3() {
  19. # Count number of connected monitors
  20. monitor_count=$(xrandr --query | grep " connected" | wc -l)
  21. # Get random wallpapers equal to monitor count
  22. readarray -t wallpapers < <(find ~/Pictures/* -type f | shuf -n "$monitor_count")
  23. # Construct the feh command with multiple --bg-fill arguments
  24. cmd="feh"
  25. for wallpaper in "${wallpapers[@]}"; do
  26. cmd+=" --bg-fill '$wallpaper'"
  27. done
  28. # Execute the command
  29. eval "$cmd"
  30. }
  31. set_wallpaper_sway