nirish

config files for niri window manager
Log | Files | Refs | README | LICENSE

niriwall (1205B)


      1 #!/usr/bin/env bash
      2 
      3 WALLDIR="$HOME/Pictures/Wallpapers"
      4 CACHE="$HOME/.cache/rofi-wallpaper"
      5 mkdir -p "$CACHE"
      6 
      7 # Generate thumbnails (only missing ones)
      8 find "$WALLDIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.webp" \) | while read -r img; do
      9   name="$(basename "$img")"
     10   thumb="$CACHE/$name.png"
     11   [ ! -f "$thumb" ] && magick "$img" -resize 500x500^ -gravity center -extent 500x500 "$thumb"
     12 done
     13 
     14 # This is the key: use -show-icons and tell rofi where the icons are
     15 chosen=$(find "$WALLDIR" -type f \( -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.png" -o -iname "*.webp" \) | sort |
     16   while read -r img; do
     17     name="$(basename "$img")"
     18     echo -e "$name\0icon\x1f$CACHE/$name.png"
     19   done |
     20   rofi -dmenu \
     21     -p "Wallpaper" \
     22     -i \
     23     -show-icons \
     24     -theme-str 'window { width: 90%; height: 80%; }' \
     25     -theme-str 'listview { columns: 5; lines: 3; spacing: 20px; }' \
     26     -theme-str 'element-icon { size: 200px; horizontal-align: 0.5; }' \
     27     -theme-str 'element-text { enabled: false; }')
     28 
     29 [ -z "$chosen" ] && exit
     30 
     31 fullpath="$WALLDIR/$chosen"
     32 awww img "$fullpath" --transition-type wipe --transition-fps 60 --transition-angle 45 --transition-step 30