Hyprland dotfiles
feat: broken af gif recorder
2 files changed, +65 -0
+1-0UserConfigs/UserKeybinds.conf
| @@ -80,6 +80,7 @@ bind = $mainMod ALT, B, exec, $scriptsDir/WaybarLayout.sh # Waybar Layout Menu | ||
| 80 | 80 | # FEATURES / EXTRAS (UserScripts) |
| 81 | 81 | bind = $mainMod, S, exec, $UserScripts/ToggleStudy.sh |
| 82 | 82 | bind = $mainMod SHIFT, M, exec, $UserScripts/RofiBeats.sh # online music using rofi |
| 83 | +bind = $mainMod SHIFT, G, exec, $UserScripts/ScreenGif.sh # region screen-to-GIF (toggle) | |
| 83 | 84 | bind = $mainMod, W, exec, $UserScripts/WallpaperSelect.sh # Select wallpaper to apply |
| 84 | 85 | bind = $mainMod SHIFT, W, exec, $UserScripts/WallpaperEffects.sh # Wallpaper Effects by imagemagick |
| 85 | 86 | bind = CTRL ALT, W, exec, $UserScripts/WallpaperRandom.sh # Random wallpapers |
+64-0UserScripts/ScreenGif.sh
| @@ -0,0 +1,64 @@ | ||
| 1 | +#!/bin/bash | |
| 2 | +# /* ---- 💫 Region screen-to-GIF capture 💫 ---- */ ## | |
| 3 | +# Toggle binding: first press selects a region with slurp and starts | |
| 4 | +# wf-recorder. Second press stops the recording and converts the result | |
| 5 | +# to GIF via ffmpeg with a generated palette for better quality. | |
| 6 | +# Output is saved to ~/Pictures/Screencasts. Feedback is rendered via | |
| 7 | +# hyprctl notify so a notification daemon is not required. | |
| 8 | + | |
| 9 | +# Variables | |
| 10 | +outDIR="$HOME/Pictures/Screencasts" | |
| 11 | +tmpMP4="/tmp/screengif-record.mp4" | |
| 12 | +tmpPAL="/tmp/screengif-palette.png" | |
| 13 | +fps=12 | |
| 14 | +maxWidth=720 | |
| 15 | + | |
| 16 | +mkdir -p "$outDIR" | |
| 17 | + | |
| 18 | +notify() { | |
| 19 | + # args: time_ms message color(optional) | |
| 20 | + local ms="$1"; shift | |
| 21 | + local color="${2:-rgb(f6004c)}" | |
| 22 | + hyprctl notify -1 "$ms" "$color" "$1" >/dev/null | |
| 23 | +} | |
| 24 | + | |
| 25 | +# Stop running recorder (toggle off) | |
| 26 | +if pgrep -x wf-recorder >/dev/null; then | |
| 27 | + notify 1500 "Stopping recording…" | |
| 28 | + pkill -SIGINT -x wf-recorder | |
| 29 | + | |
| 30 | + while pgrep -x wf-recorder >/dev/null; do sleep 0.1; done | |
| 31 | + | |
| 32 | + if [ ! -s "$tmpMP4" ]; then | |
| 33 | + notify 3000 "No recording captured." | |
| 34 | + exit 1 | |
| 35 | + fi | |
| 36 | + | |
| 37 | + ts="$(date +%Y%m%d-%H%M%S)" | |
| 38 | + outGIF="$outDIR/screengif-$ts.gif" | |
| 39 | + | |
| 40 | + notify 2000 "Encoding GIF…" | |
| 41 | + | |
| 42 | + ffmpeg -y -v error -i "$tmpMP4" \ | |
| 43 | + -vf "fps=${fps},scale='min(${maxWidth},iw)':-2:flags=lanczos,palettegen=stats_mode=diff" \ | |
| 44 | + "$tmpPAL" | |
| 45 | + | |
| 46 | + ffmpeg -y -v error -i "$tmpMP4" -i "$tmpPAL" -filter_complex \ | |
| 47 | + "fps=${fps},scale='min(${maxWidth},iw)':-2:flags=lanczos[x];[x][1:v]paletteuse=dither=bayer:bayer_scale=5" \ | |
| 48 | + "$outGIF" | |
| 49 | + | |
| 50 | + rm -f "$tmpMP4" "$tmpPAL" | |
| 51 | + | |
| 52 | + sizeKB=$(( $(stat -c %s "$outGIF") / 1024 )) | |
| 53 | + echo -n "$outGIF" | wl-copy | |
| 54 | + notify 5000 "Saved ${outGIF##*/} (${sizeKB} KB) — path on clipboard" | |
| 55 | + exit 0 | |
| 56 | +fi | |
| 57 | + | |
| 58 | +# Start a new recording (toggle on) | |
| 59 | +region="$(slurp)" || { notify 2000 "Region selection cancelled."; exit 1; } | |
| 60 | + | |
| 61 | +rm -f "$tmpMP4" | |
| 62 | +notify 3000 "Recording — press Mod+Shift+G to stop" | |
| 63 | + | |
| 64 | +wf-recorder -g "$region" -f "$tmpMP4" |