Kieran's opinionated (and probably slightly dumb) nix config

feat: add hyprrec

dunkirk.sh 43304ccd b9c23e26

verified
+91 -1
+3 -1
home-manager/dots/hyprland.conf
··· 142 142 143 143 # Tools 144 144 bind=CTRL,PRINT,exec,grimblast copy area; notify-desktop "copied screenshot of selection to the clipboard" 145 - bind=ALT,PRINT,exec,grimblast copy active; notify-desktop "copied screenshot of active window to clipboard" 146 145 bind=,PRINT,exec,grimblast copy output; notify-desktop "copied screenshot of screen to the clipboard" 146 + bind=CTRL,XF86AudioMedia,exec,~/.config/hypr/hyprrec.sh 147 + bind=,XF86AudioMedia,exec,~/.config/hypr/hyprrec.sh fullscreen 148 + 147 149 148 150 bind=CTRL + SHIFT, PRINT, exec, START_TIME=$(date +%s); bash ~/.config/hypr/prettify-ss.sh; notify-desktop "Prettified Screenshot" "Taking $(($(date +%s) - START_TIME))s" 149 151
+78
home-manager/dots/hyprrec.sh
··· 1 + ## Requirements: 2 + ## - `slurp`: to select an area 3 + ## - `notify-send`: to show notifications (provided by libnotify) 4 + ## - `wl-screenrec`: for screen recording 5 + ## - `ffmpeg`: for thumbnail generation 6 + # If wl-screenrec is already running, stop recording. 7 + if pgrep -x "wl-screenrec" > /dev/null; then 8 + killall -s 2 wl-screenrec 9 + exit 0 10 + fi 11 + 12 + # Set up file path for recording 13 + FILE="$HOME/Downloads/screencast_$(date +%Y%m%d_%H%M%S).mp4" 14 + 15 + # Get audio device information using wireplumber 16 + MONITOR_DEVICE="" 17 + DEFAULT_DEVICE=$(wpctl status | grep "Default Configured Devices" -A 2 | grep "Audio/Sink" | awk '{print $NF}') 18 + 19 + if [ -n "$DEFAULT_DEVICE" ]; then 20 + # Try to construct the monitor device name 21 + MONITOR_DEVICE="${DEFAULT_DEVICE}.monitor" 22 + 23 + # Check if the device exists by attempting to get its properties 24 + wpctl inspect $(wpctl status | grep -A 1 "Built-in Audio Analog Stereo" | grep -o '[0-9]\+\.' | head -1 | tr -d '.') > /dev/null 2>&1 25 + if [ $? -eq 0 ]; then 26 + echo "Found audio device, will use monitor: $MONITOR_DEVICE" 27 + AUDIO_ARGS="--audio --audio-device \"$MONITOR_DEVICE\"" 28 + else 29 + echo "Couldn't confirm monitor device, falling back to default audio" 30 + AUDIO_ARGS="--audio" 31 + fi 32 + else 33 + echo "No default audio device found, falling back to default audio capture" 34 + AUDIO_ARGS="--audio" 35 + fi 36 + 37 + # Process arguments to determine if full screen or area selection 38 + if [ "$1" = "fullscreen" ]; then 39 + # Full screen recording 40 + notify-send -t 1000 -a "wl-screenrec" "Starting full screen recording" 41 + ARGS="" 42 + else 43 + # Area selection 44 + notify-send -t 1000 -a "wl-screenrec" "Select area or window to record" 45 + # Get list of visible windows for slurp to highlight 46 + WINDOWS="$(hyprctl clients -j | jq -r '.[] | "\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')" 47 + # Use slurp with window detection 48 + GEOMETRY=$(echo "$WINDOWS" | slurp) 49 + # Check if user canceled selection 50 + if [ -z "$GEOMETRY" ]; then 51 + notify-send -t 3000 -a "wl-screenrec" "Recording canceled" 52 + exit 1 53 + fi 54 + notify-send -t 1000 -a "wl-screenrec" "Starting area recording" 55 + ARGS="-g \"$GEOMETRY\"" 56 + fi 57 + 58 + # Start recording with the selected parameters 59 + touch /tmp/notify_result.txt 60 + eval "wl-screenrec $ARGS $AUDIO_ARGS -f \"$FILE\"" && \ 61 + # Create a thumbnail from the recording 62 + ffmpeg -i "$FILE" -ss 00:00:00 -vframes 1 -update 1 -frames:v 1 /tmp/screenrec_thumbnail.png -y && \ 63 + # Notify that recording is saved with clickable action 64 + notify-send -a "wl-screenrec" "Recording saved to $FILE" \ 65 + -i "/tmp/screenrec_thumbnail.png" \ 66 + -A "default=Open" > /tmp/notify_result.txt 67 + 68 + # Check if notification was clicked 69 + if [ -f /tmp/notify_result.txt ] && grep -q "default" /tmp/notify_result.txt; then 70 + if command -v xdg-open > /dev/null; then 71 + xdg-open "$FILE" 72 + elif command -v gdbus > /dev/null; then 73 + gdbus call --session \ 74 + --dest org.freedesktop.FileManager1 \ 75 + --object-path /org/freedesktop/FileManager1 \ 76 + --method org.freedesktop.FileManager1.ShowItems "['file://$FILE']" "" 77 + fi 78 + fi
+3
home-manager/wm/hyprland/default.nix
··· 26 26 xdg.configFile."hypr/wall/acon-forest.jpg".source = ../../dots/wallpapers/acon-forest.jpg; 27 27 xdg.configFile."hypr/wall/acon-gradient-clouds.jpg".source = ../../dots/wallpapers/acon-gradient-clouds.jpg; 28 28 29 + # hyprrec.sh 30 + xdg.configFile."hypr/hyprrec.sh".source = ../../dots/hyprrec.sh; 31 + 29 32 # portal 30 33 xdg.portal = { 31 34 enable = true;
+7
moonlark/configuration.nix
··· 172 172 pkgs.unstable.kikit 173 173 pkgs.cmake 174 174 pkgs.unstable.zotero 175 + pkgs.wl-screenrec 176 + pkgs.libnotify 177 + pkgs.coreutils 178 + pkgs.grim 179 + pkgs.jq 180 + pkgs.slurp 181 + pkgs.xdg-user-dirs 175 182 ]; 176 183 177 184 programs.nh = {