Commit 50af9e24b300

Vincent Demeester <vincent@sbr.pm>
2022-08-24 15:55:59
users/vincent: fix some scripts for sway
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent f012240
Changed files (5)
nix
packages
users
vincent
desktop
nix/packages/my/scripts/bin/pbcopy
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 set -e
 if [ ! $(uname -s) = "Darwin" ]; then
-    if ! command -v wl-copy  &> /dev/null; then
+    if command -v wl-copy  &> /dev/null; then
         wl-copy $@
     else
         xsel --clipboard --input $@
nix/packages/my/scripts/bin/pbpaste
@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 set -e
 if [ ! $(uname -s) = "Darwin" ]; then
-    if ! command -v wl-paste &> /dev/null; then
+    if command -v wl-paste &> /dev/null; then
         wl-paste $@
     else
         xsel --clipboard --output $@
nix/packages/my/scripts/bin/shot
@@ -1,18 +1,19 @@
 #!/usr/bin/env bash
 
-SCREENSHOT_BIN=main
-SLOP_BIN=slop
-if ! command -v grim &> /dev/null; then
-    SCREENSHOT_BIN=grim
-fi
-if ! command -v slurp &> /dev/null; then
-    SLOP_BIN=slurp
-fi
-$SCREENSHOT_BIN -g $($SLOP_BIN; sleep ${2:-0}) | {
+to=""
+if command -v grim &> /dev/null; then
     case $1 in
-	%c) to='clipboard'; xclip -selection clipboard -t image/png ;;
-	%d) to=~/desktop/pictures/screenshots/$(hostname)/$(date +'%Y-%m-%d-%H%M%S').png; cat > "$to" ;;
-	*)  to=$1; cat > "$to" ;;
+	    %c) to='clipboard'; grim -g "$(slurp)" - | wl-copy ;;
+	    %d) to=~/desktop/pictures/screenshots/$(hostname)/$(date +'%Y-%m-%d-%H%M%S').png; grim -g "$(slurp)" "$to" ;;
+	    *)  to=$1; grim -g "$(slurp)" "$to" ;;
     esac
-    notify-send -i accessories-screenshot 'Screenshot Taken' "Saved to $to"
-}
+else
+    maim -g $(slop; sleep ${2:-0}) | {
+        case $1 in
+	        %c) to='clipboard'; xclip -selection clipboard -t image/png ;;
+	        %d) to=~/desktop/pictures/screenshots/$(hostname)/$(date +'%Y-%m-%d-%H%M%S').png; cat > "$to" ;;
+	        *)  to=$1; cat > "$to" ;;
+        esac        
+    }
+fi
+notify-send -i accessories-screenshot 'Screenshot Taken' "Saved to $to"
nix/packages/my/scripts/bin/shotf
@@ -1,14 +1,19 @@
 #!/usr/bin/env bash
 
 SCREENSHOT_BIN="main -d"
-if ! command -v grim &> /dev/null; then
-    SCREENSHOT_BIN=grim
-fi
-$SCREENSHOT_BIN | {
+if command -v grim &> /dev/null; then
+    case $1 in
+	    %c) to='clipboard'; grim - | wl-copy ;;
+	    %d) to=~/desktop/pictures/screenshots/$(hostname)/$(date +'%Y-%m-%d-%H%M%S').png; grim "$to" ;;
+	    *)  to=$1; grim "$to" ;;
+    esac
+else
+maim -d | {
     case $1 in
 	%c) to='clipboard'; xclip -selection clipboard -t image/png ;;
 	%d) to=~/desktop/pictures/screenshots/$(hostname)/$(date +'%Y-%m-%d-%H%M%S').png; cat > "$to" ;;
 	*)  to=$1; cat > "$to" ;;
     esac
-    notify-send -i accessories-screenshot 'Screenshot Taken' "Saved to $to"
 }
+fi
+notify-send -i accessories-screenshot 'Screenshot Taken' "Saved to $to"
users/vincent/desktop/sway.nix
@@ -279,13 +279,14 @@ in
     swaylock
     swayidle
     swaybg
+    wf-recorder
     wl-clipboard
     mako
     wofi
     waybar
     slurp
     grim
-    zenity
+    gnome3.zenity
     # terminals
     # FIXME move this away, they work on both Xorg and Wayland/Sway
     alacritty