1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 18:21:07 +01:00

feat: add scrot-dmenu script

This commit is contained in:
Kierán Meinhardt
2020-05-24 10:08:13 +02:00
parent 9a33c1a106
commit fd36d5279c
3 changed files with 45 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
{ config, pkgs, lib, ... }:
let
scripts = import <niveum/packages/scripts> { inherit pkgs lib; };
myLib = import <niveum/lib> { inherit pkgs; };
inherit (myLib) writeTOML;
@@ -185,15 +186,15 @@ in with config.niveum; {
"${modifier}+p" = "exec --no-startup-id ${pkgs.pass}/bin/passmenu -l 5";
"${modifier}+u" = "exec ${emoji-menu}/bin/emoji-menu";
"Print" = "exec ${pkgs.scrot} -e 'mv $f /tmp'";
"Print" = "exec ${scripts.scrot-dmenu}/bin/scrot-dmenu";
"XF86AudioLowerVolume" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -d 5";
"XF86AudioMute" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -t";
"XF86AudioRaiseVolume" = "exec --no-startup-id ${pkgs.pamixer}/bin/pamixer -i 5";
"XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc";
"XF86AudioPause" = "exec --no-startup-id ${pkgs.playerctl} pause";
"XF86AudioPlay" = "exec --no-startup-id ${pkgs.playerctl} play-pause";
"XF86AudioNext" = "exec --no-startup-id ${pkgs.playerctl} next";
"XF86AudioPrev" = "exec --no-startup-id ${pkgs.playerctl} previous";
"XF86AudioPause" = "exec --no-startup-id ${pkgs.playerctl}/bin/playerctl pause";
"XF86AudioPlay" = "exec --no-startup-id ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioNext" = "exec --no-startup-id ${pkgs.playerctl}/bin/playerctl next";
"XF86AudioPrev" = "exec --no-startup-id ${pkgs.playerctl}/bin/playerctl previous";
"XF86ScreenSaver" = "exec ${pkgs.xautolock}/bin/xautolock -locknow";
"XF86Display" = "exec ${pkgs.xcalib}/bin/xcalib -invert -alter";

View File

@@ -1,5 +1,6 @@
{ pkgs, lib, ... }:
let
kpaste = pkgs.callPackage <stockholm/krebs/5pkgs/simple/kpaste> {};
wrapScript = { packages ? [], name, script }: pkgs.writers.writeDashBin name ''
PATH=$PATH:${lib.makeBinPath (packages ++ [pkgs.coreutils pkgs.findutils])}
${script} "$@"
@@ -117,6 +118,12 @@ in
packages = [ pkgs.python3 ];
};
scrot-dmenu = wrapScript {
script = ./scrot-dmenu.sh;
name = "dmenu-scrot";
packages = [ pkgs.xclip pkgs.scrot kpaste pkgs.libnotify pkgs.dmenu ];
};
bvg = pkgs.callPackage ./bvg.nix {};
nav = pkgs.callPackage ./nav.nix {};
}

32
packages/scripts/scrot-dmenu.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/sh
# ref https://gitlab.com/dwt1/dotfiles/-/blob/master/.dmenu/dmenu-scrot.sh
APP_NAME="📸 Scrot"
IMG_PATH="$HOME/Downloads/Screenshots"
TIME=3000 #Miliseconds notification should remain visible
cmd=$(printf "fullscreen\nsection\nupload_fullscreen\nupload_section\n" | dmenu -p 'Screenshot')
cd "$IMG_PATH" || exit
case ${cmd%% *} in
fullscreen)
scrot -d 1 \
&& notify-send -u low -t $TIME -a "$APP_NAME" 'Screenshot (full screen) saved.'
;;
section)
scrot -s \
&& notify-send -u low -t $TIME -a "$APP_NAME" 'Screenshot (section) saved.'
;;
upload_fullscreen)
scrot -d 1 -e "kpaste < \$f" | tail --lines=1 | xclip -selection clipboard -in \
&& notify-send -u low -t $TIME -a "$APP_NAME" "Screenshot (full screen) uploaded: $(xclip -selection clipboard -out)"
;;
upload_section)
scrot -s -e "kpaste < \$f" | tail --lines=1 | xclip -selection clipboard -in \
&& notify-send -u low -t $TIME -a "$APP_NAME" "Screenshot (section) uploaded: $(xclip -selection clipboard -out)"
;;
esac