summaryrefslogtreecommitdiff
path: root/home
diff options
context:
space:
mode:
Diffstat (limited to 'home')
-rw-r--r--home/cez/home.nix5
-rw-r--r--home/cez/modules/wayland.nix8
-rw-r--r--home/wayland/modules/sway/home.nix2
-rw-r--r--home/wayland/pkgs/wayland-scripts/default.nix7
-rwxr-xr-xhome/wayland/pkgs/wayland-scripts/src/bin/freezshot51
5 files changed, 70 insertions, 3 deletions
diff --git a/home/cez/home.nix b/home/cez/home.nix
index bba7bd9..018c19c 100644
--- a/home/cez/home.nix
+++ b/home/cez/home.nix
@@ -1,3 +1,6 @@
{ ... }: {
- imports = [ ../pc/home.nix ];
+ imports = [
+ ../pc/home.nix
+ ./modules/wayland.nix
+ ];
}
diff --git a/home/cez/modules/wayland.nix b/home/cez/modules/wayland.nix
new file mode 100644
index 0000000..4c9e0ac
--- /dev/null
+++ b/home/cez/modules/wayland.nix
@@ -0,0 +1,8 @@
+{ pkgs, ... }: let
+ wayland-scripts = pkgs.callPackage ../../wayland/pkgs/wayland-scripts {};
+ freezshot = "${wayland-scripts}/bin/freezshot";
+in {
+ # vendor hardcoded screenshot key
+ wayland.windowManager.sway.settings.bindsym."mod4+shift+s" =
+ "exec ${freezshot}";
+}
diff --git a/home/wayland/modules/sway/home.nix b/home/wayland/modules/sway/home.nix
index dd0a275..0b42155 100644
--- a/home/wayland/modules/sway/home.nix
+++ b/home/wayland/modules/sway/home.nix
@@ -149,8 +149,8 @@ in {
gaps.inner = 10;
default_border.pixel = 2;
floating_modifier = "${mod} normal";
- "client.focused" = "#4c7899 #285577 #ffffff #285577";
output."*".background = "${background} fill";
+ "client.focused" = "#4c7899 #285577 #ffffff #285577";
};
};
}
diff --git a/home/wayland/pkgs/wayland-scripts/default.nix b/home/wayland/pkgs/wayland-scripts/default.nix
index bded5e7..c98def5 100644
--- a/home/wayland/pkgs/wayland-scripts/default.nix
+++ b/home/wayland/pkgs/wayland-scripts/default.nix
@@ -7,11 +7,14 @@
sway,
ffmpeg,
libnotify,
+ imv,
+ grim,
+ slurp,
}:
stdenvNoCC.mkDerivation {
pname = "wayland-scipts";
- version = "1717572072";
+ version = "1717606223";
src = ./src;
strictDeps = true;
@@ -34,6 +37,8 @@ stdenvNoCC.mkDerivation {
postInstall = ''
wrapProgram $out/bin/cwall \
--prefix PATH : ${lib.makeBinPath [ ffmpeg libnotify sway ]}
+ wrapProgram $out/bin/freezshot \
+ --prefix PATH : ${lib.makeBinPath [ ffmpeg sway grim slurp imv ]}
'';
meta = {
diff --git a/home/wayland/pkgs/wayland-scripts/src/bin/freezshot b/home/wayland/pkgs/wayland-scripts/src/bin/freezshot
new file mode 100755
index 0000000..a47e9c8
--- /dev/null
+++ b/home/wayland/pkgs/wayland-scripts/src/bin/freezshot
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+
+tmp="${XDG_RUNTIME_DIR:-${TMPDIR:-/tmp}}"
+tmp="$(mktemp -d "${tmp}/freezhot.XXXX")"
+out="${GRIM_DEFAULT_DIR:-${XDG_PICTURES_DIR:-.}}"
+
+wl_res()
+{
+ swaymsg -pt get_outputs | while read -r line; do
+ case "$line" in
+ "Current mode"*)
+ line="${line#*Current mode: }"
+ echo "${line%% *}"
+ return
+ esac
+ done
+}
+
+########
+# MAIN #
+########
+
+if [ ! -d "$out" ]; then
+ mkdir -p "$out"
+fi
+GRIM_DEFAULT_DIR="$tmp" grim
+trap 'rm -r "$tmp"' EXIT
+imv -f "$tmp"/* &
+view_pid=$!
+
+region=$(slurp -f '%wx%h %x:%y') > /dev/null 2>&1
+r=$?
+kill $view_pid
+if [ $r != 0 ]; then
+ exit 1
+fi
+
+img="$(ls "$tmp")"
+res="${region% *}"
+if [ "$res" = "$(wl_res)" ]; then
+ cp "$tmp/$img" "$out"
+else
+ width=${res%x*}
+ hight="${res#*x}"
+ position="${region#* }"
+ ffmpeg \
+ -loglevel quiet \
+ -i "$tmp/$img" \
+ -vf "crop=$width:$hight:$position" \
+ "$out/$img"
+fi