commit f012240737542210421a2fca164bf2c4d09d9c34
parent 62ab987e6c34db529b6bf6f7cf40b1ae62531a30
Author: Vincent Demeester <vincent@sbr.pm>
Date: Wed, 24 Aug 2022 15:44:19 +0200
users/vincent: add screenshot capabilities to sway
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat:
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/nix/packages/my/scripts/bin/shot b/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" ;;
diff --git a/nix/packages/my/scripts/bin/shotf b/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" ;;
diff --git a/users/vincent/desktop/sway.nix b/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