randwall 979 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/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. swaymsg -t get_outputs -r | jq -r ".[].name" | parallel 'swaybg -o {} -i $(find ~/Pictures/* -type f | shuf -n 1) &'
  8. }
  9. # Function to set wallpaper using swaybg on Hyprland
  10. set_wallpaper_hyprland() {
  11. hyprctl monitors -j | jq -r ".[].name" | parallel 'swaybg -o {} -i $(find ~/Pictures/* -type f | shuf -n 1) &'
  12. }
  13. # Function to set wallpaper using feh on i3
  14. set_wallpaper_i3() {
  15. # Count number of connected monitors
  16. monitor_count=$(xrandr --query | grep " connected" | wc -l)
  17. # Get random wallpapers equal to monitor count
  18. readarray -t wallpapers < <(find ~/Pictures/* -type f | shuf -n "$monitor_count")
  19. # Construct the feh command with multiple --bg-fill arguments
  20. cmd="feh"
  21. for wallpaper in "${wallpapers[@]}"; do
  22. cmd+=" --bg-fill '$wallpaper'"
  23. done
  24. # Execute the command
  25. eval "$cmd"
  26. }
  27. set_wallpaper_sway