Added screenshots module
This commit is contained in:
27
config/grapheio/scripts/screenshot.sh
Executable file
27
config/grapheio/scripts/screenshot.sh
Executable file
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Dependencies:
|
||||||
|
# - slurp
|
||||||
|
# - grim
|
||||||
|
|
||||||
|
ACTION=$1
|
||||||
|
|
||||||
|
DATESTAMP=$(date +"%Y%m%d%H%M%S")
|
||||||
|
OUT_DIR="${HOME}/screenshots"
|
||||||
|
OUT_FILE="capture-${ACTION}-${DATESTAMP}.png"
|
||||||
|
|
||||||
|
case $ACTION in
|
||||||
|
region)
|
||||||
|
[[ ! -d "${OUT_DIR}" ]] && mkdir $OUT_DIR
|
||||||
|
slurp | grim -t png -g - "${OUT_DIR}/${OUT_FILE}"
|
||||||
|
;;
|
||||||
|
screen)
|
||||||
|
[[ ! -d "${OUT_DIR}" ]] && mkdir $OUT_DIR
|
||||||
|
grim -t png "${OUT_DIR}/${OUT_FILE}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown action"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
@@ -115,6 +115,8 @@ in
|
|||||||
swaync.enable = true;
|
swaync.enable = true;
|
||||||
# Clipboard manager (history)
|
# Clipboard manager (history)
|
||||||
cliphist.enable = true;
|
cliphist.enable = true;
|
||||||
|
# Take screenshots
|
||||||
|
screenshot.enable = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
31
modules/desktop/tools/screenshot.nix
Normal file
31
modules/desktop/tools/screenshot.nix
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{ config, lib, pkgs, inputs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.samfelag.modules.desktop.tools.screenshot;
|
||||||
|
hyprCfg = config.samfelag.modules.desktop.wm.hyprland;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.samfelag.modules.desktop.tools.screenshot = {
|
||||||
|
enable = mkEnableOption "Screenshot utilities";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
# - Screenshot utilities ---------------------
|
||||||
|
environment.systemPackages = [
|
||||||
|
pkgs.slurp # to select the region
|
||||||
|
pkgs.grim # actual screenshot program
|
||||||
|
];
|
||||||
|
|
||||||
|
# - Hyprland keybindings ---------------------
|
||||||
|
hm.wayland.windowManager.hyprland.settings = lib.mkIf hyprCfg.enable {
|
||||||
|
bind = [
|
||||||
|
# Screenshots
|
||||||
|
"${hyprCfg.mod}, s, exec, $HOME/.config/grapheio/scripts/screenshot.sh region"
|
||||||
|
"${hyprCfg.mod}, SHIFT s, exec, $HOME/.config/grapheio/scripts/screenshot.sh screen"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user