Added screenshots module

This commit is contained in:
marc
2025-10-05 18:23:02 +02:00
parent 18cfc610e1
commit e87b0ddd24
3 changed files with 60 additions and 0 deletions

View 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

View File

@@ -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;
}; };
}; };

View 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"
];
};
};
}