Commit f01224073754

Vincent Demeester <vincent@sbr.pm>
2022-08-24 15:44:19
users/vincent: add screenshot capabilities to sway
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 62ab987
Changed files (3)
nix
packages
my
scripts
users
vincent
desktop
nix/packages/my/scripts/bin/shot
@@ -1,6 +1,14 @@
 #!/usr/bin/env bash
 
-maim -g $(slop; sleep ${2:-0}) | {
+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}) | {
     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" ;;
nix/packages/my/scripts/bin/shotf
@@ -1,6 +1,10 @@
 #!/usr/bin/env bash
 
-maim -d | {
+SCREENSHOT_BIN="main -d"
+if ! command -v grim &> /dev/null; then
+    SCREENSHOT_BIN=grim
+fi
+$SCREENSHOT_BIN | {
     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" ;;
users/vincent/desktop/sway.nix
@@ -201,7 +201,10 @@ in
         bindsym XF86AudioPrev exec "playerctl previous"
 
         bindcode ${mod}+49 exec swaymsg [app_id="metask"] scratchpad show || exec ${pkgs.kitty}/bin/kitty --title metask --class metask tmux
-        bindcode ${mod}+Shift+49 exec swaymsg '[app_id="emacs" title="^_emacs scratchpad_$"]' scratchpad show || exec ${config.programs.emacs.package}/bin/emacsclient -c -F "((name . \"_emacs scratchpad_\"))" 
+        bindcode ${mod}+Shift+49 exec swaymsg '[app_id="emacs" title="^_emacs scratchpad_$"]' scratchpad show || exec ${config.programs.emacs.package}/bin/emacsclient -c -F "((name . \"_emacs scratchpad_\"))"
+
+        bindsym ${mod}+F10 exec ${pkgs.my.scripts}/bin/shot %d
+        bindsym ${mod}+Shift+F10 exec ${pkgs.my.scripts}/bin/shotf %d 
       '';
   };
   programs = {
@@ -281,6 +284,8 @@ in
     wofi
     waybar
     slurp
+    grim
+    zenity
     # terminals
     # FIXME move this away, they work on both Xorg and Wayland/Sway
     alacritty