mirror of
https://github.com/oddlama/nix-config.git
synced 2025-10-10 23:00:39 +02:00
refactor(screenshots): use separate scripts package
This commit is contained in:
parent
3e0e03fc31
commit
6e8aae7d8d
15 changed files with 216 additions and 109 deletions
36
flake.lock
generated
36
flake.lock
generated
|
@ -664,11 +664,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1697323135,
|
"lastModified": 1697371398,
|
||||||
"narHash": "sha256-tlAv11c0NIRTk2IzpFxYknHrveeFXojVyCTAMg749Zg=",
|
"narHash": "sha256-Tn5feZ5SoYHQM9BTjw5e06DuNu8wc21gC9+bq/kXA8Y=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "d4a5076ea8c2c063c45e0165f9f75f69ef583e20",
|
"rev": "3b67ae3f665379c06999641f99d94dba75b53876",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -698,11 +698,11 @@
|
||||||
"nixpkgs-lib": "nixpkgs-lib"
|
"nixpkgs-lib": "nixpkgs-lib"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696766909,
|
"lastModified": 1697371715,
|
||||||
"narHash": "sha256-lU1BmCWpQ9cx64YnJKc89lMg9cx4pCokXIbh5J//2t0=",
|
"narHash": "sha256-1ZV4qoL1B35DsciS/inC+z6vAwjxjWHL3+4G4QQhT0A=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "lib-aggregate",
|
"repo": "lib-aggregate",
|
||||||
"rev": "9f495e4feea66426589cbb59ac8b972993b5d872",
|
"rev": "af42578368ca0c97d5836ba55b146745911aaecc",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -773,11 +773,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696736548,
|
"lastModified": 1697340827,
|
||||||
"narHash": "sha256-Dg0gJ9xVXud55sAbXspMapFYZOpVAldQQo7MFp91Vb0=",
|
"narHash": "sha256-XlrR68N7jyaZ0bs8TPrhqcWG0IPG3pbjrKzJMpYOsos=",
|
||||||
"owner": "Mic92",
|
"owner": "Mic92",
|
||||||
"repo": "nix-index-database",
|
"repo": "nix-index-database",
|
||||||
"rev": "2902dc66f64f733bfb45754e984e958e9fe7faf9",
|
"rev": "29977d0796c058bbcfb2df5b18eb5badf1711007",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -877,11 +877,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs-lib": {
|
"nixpkgs-lib": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1696726172,
|
"lastModified": 1697331025,
|
||||||
"narHash": "sha256-89yxFXzTA7JRyWo6hg7SD4DlS/ejYt8Y8IvGZHbSWsg=",
|
"narHash": "sha256-a5LJWWHfEvnq9tBd9UyNVdtzLXc2ehu5MCp//Bex/0E=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs.lib",
|
"repo": "nixpkgs.lib",
|
||||||
"rev": "59da6ac0c02c48aa92dee37057f978412797db2a",
|
"rev": "05c07c73de74725ec7efa6609011687035a92c0f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -948,11 +948,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1697300259,
|
"lastModified": 1697372844,
|
||||||
"narHash": "sha256-gmLtTy9kuLnw5MekDHY1Roc36kkEsLNTnKq8lSQkD3U=",
|
"narHash": "sha256-Ut7Bojh7SqNf2pKRIoGPWWRU9ZjvSxSJS+GByC8AHD0=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "nixpkgs-wayland",
|
"repo": "nixpkgs-wayland",
|
||||||
"rev": "6b428305043afaf77119adb44dfea246c809e07f",
|
"rev": "3bd7c4e831bc3dc82828e179397b06652adf2878",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -1258,11 +1258,11 @@
|
||||||
},
|
},
|
||||||
"templates": {
|
"templates": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1691421369,
|
"lastModified": 1697364028,
|
||||||
"narHash": "sha256-Agfum0ykpUxUUS4AKYPVSWF+NeHPWay2o1TTNH0BFXA=",
|
"narHash": "sha256-t7IGwY/nvopK9n9tgCVrHlLimhU2MuoP9VbVy07AR2A=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "templates",
|
"repo": "templates",
|
||||||
"rev": "0fb94bf87144b18e42765693c3e15ac5f17eeab0",
|
"rev": "98bc26d94008617aac7cd0244fb09ff04d6c8cf6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
_inputs: _self: super: {
|
_inputs: _final: prev: {
|
||||||
lib =
|
lib =
|
||||||
super.lib
|
prev.lib
|
||||||
// {
|
// {
|
||||||
disko = {
|
disko = {
|
||||||
gpt = {
|
gpt = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
inputs: self: super: let
|
inputs: _final: prev: let
|
||||||
inherit
|
inherit
|
||||||
(super.lib)
|
(prev.lib)
|
||||||
concatMapStrings
|
concatMapStrings
|
||||||
escapeShellArg
|
escapeShellArg
|
||||||
filter
|
filter
|
||||||
|
@ -71,7 +71,7 @@ inputs: self: super: let
|
||||||
hexToDec = v: foldl' (acc: x: acc * 16 + hexLiteralValues.${x}) 0 (stringToCharacters v);
|
hexToDec = v: foldl' (acc: x: acc * 16 + hexLiteralValues.${x}) 0 (stringToCharacters v);
|
||||||
in {
|
in {
|
||||||
lib =
|
lib =
|
||||||
super.lib
|
prev.lib
|
||||||
// {
|
// {
|
||||||
inherit
|
inherit
|
||||||
concatAttrs
|
concatAttrs
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
inputs: self: super: let
|
inputs: final: prev: let
|
||||||
inherit
|
inherit
|
||||||
(inputs.nixpkgs.lib)
|
(inputs.nixpkgs.lib)
|
||||||
all
|
all
|
||||||
|
@ -22,7 +22,7 @@ inputs: self: super: let
|
||||||
;
|
;
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
(self.lib)
|
(final.lib)
|
||||||
hexToDec
|
hexToDec
|
||||||
pow
|
pow
|
||||||
;
|
;
|
||||||
|
@ -37,7 +37,7 @@ inputs: self: super: let
|
||||||
.lib
|
.lib
|
||||||
.net;
|
.net;
|
||||||
in {
|
in {
|
||||||
lib = recursiveUpdate super.lib {
|
lib = recursiveUpdate prev.lib {
|
||||||
net = recursiveUpdate (removeAttrs libNet ["types"]) {
|
net = recursiveUpdate (removeAttrs libNet ["types"]) {
|
||||||
cidr = rec {
|
cidr = rec {
|
||||||
# host :: (ip | mac | integer) -> cidr -> ip
|
# host :: (ip | mac | integer) -> cidr -> ip
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
inputs: _self: super: let
|
inputs: _final: prev: let
|
||||||
inherit
|
inherit
|
||||||
(inputs.nixpkgs.lib)
|
(inputs.nixpkgs.lib)
|
||||||
all
|
all
|
||||||
|
@ -39,7 +39,7 @@ inputs: _self: super: let
|
||||||
# automatically be coerced to the given type when merged.
|
# automatically be coerced to the given type when merged.
|
||||||
lazyOf = type: types.coercedTo (lazyValueOf type) (x: x._lazyValue) type;
|
lazyOf = type: types.coercedTo (lazyValueOf type) (x: x._lazyValue) type;
|
||||||
in {
|
in {
|
||||||
lib = recursiveUpdate super.lib {
|
lib = recursiveUpdate prev.lib {
|
||||||
types = {
|
types = {
|
||||||
inherit
|
inherit
|
||||||
isLazyValue
|
isLazyValue
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
inputs: self: super: let
|
inputs: final: prev: let
|
||||||
inherit
|
inherit
|
||||||
(inputs.nixpkgs.lib)
|
(inputs.nixpkgs.lib)
|
||||||
assertMsg
|
assertMsg
|
||||||
|
@ -19,21 +19,21 @@ inputs: self: super: let
|
||||||
;
|
;
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
(self.lib)
|
(final.lib)
|
||||||
net
|
net
|
||||||
concatAttrs
|
concatAttrs
|
||||||
types
|
types
|
||||||
;
|
;
|
||||||
|
|
||||||
inherit
|
inherit
|
||||||
(self.lib.secrets)
|
(final.lib.secrets)
|
||||||
rageDecryptArgs
|
rageDecryptArgs
|
||||||
;
|
;
|
||||||
|
|
||||||
inherit (inputs.self) nodes;
|
inherit (inputs.self) nodes;
|
||||||
in {
|
in {
|
||||||
lib =
|
lib =
|
||||||
super.lib
|
prev.lib
|
||||||
// {
|
// {
|
||||||
wireguard = wgName: let
|
wireguard = wgName: let
|
||||||
# Returns the given node's wireguard configuration of this network
|
# Returns the given node's wireguard configuration of this network
|
||||||
|
|
|
@ -102,6 +102,8 @@
|
||||||
imports = cfg.commonImports ++ vmCfg.modules;
|
imports = cfg.commonImports ++ vmCfg.modules;
|
||||||
node.name = vmCfg.nodeName;
|
node.name = vmCfg.nodeName;
|
||||||
|
|
||||||
|
# TODO needed because of https://github.com/NixOS/nixpkgs/issues/102137
|
||||||
|
environment.noXlibs = mkForce false;
|
||||||
lib.microvm.mac = mac;
|
lib.microvm.mac = mac;
|
||||||
|
|
||||||
microvm = {
|
microvm = {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
self: super: let
|
_final: prev: let
|
||||||
inherit
|
inherit
|
||||||
(self.lib)
|
(prev.lib)
|
||||||
escapeShellArg
|
escapeShellArg
|
||||||
concatMapStrings
|
concatMapStrings
|
||||||
flip
|
flip
|
||||||
|
@ -20,9 +20,9 @@ self: super: let
|
||||||
version,
|
version,
|
||||||
}: "go get ${escapeShellArg name}@${escapeShellArg version}\n");
|
}: "go get ${escapeShellArg name}@${escapeShellArg version}\n");
|
||||||
in
|
in
|
||||||
super.caddy.override {
|
prev.caddy.override {
|
||||||
buildGoModule = args:
|
buildGoModule = args:
|
||||||
super.buildGoModule (args
|
prev.buildGoModule (args
|
||||||
// {
|
// {
|
||||||
inherit vendorHash;
|
inherit vendorHash;
|
||||||
passthru.plugins = plugins;
|
passthru.plugins = plugins;
|
||||||
|
@ -44,5 +44,5 @@ in {
|
||||||
# ];
|
# ];
|
||||||
# vendorHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
# vendorHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
|
||||||
# }
|
# }
|
||||||
caddy = super.caddy.overrideAttrs (_: {passthru.withPackages = make-custom-caddy;});
|
caddy = prev.caddy.overrideAttrs (_: {passthru.withPackages = make-custom-caddy;});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
[
|
[
|
||||||
(import ./caddy.nix)
|
(import ./caddy.nix)
|
||||||
(import ./oauth2-proxy)
|
(import ./oauth2-proxy)
|
||||||
(_self: super: {
|
(import ./scripts)
|
||||||
deploy = super.callPackage ./deploy.nix {};
|
(_final: prev: {
|
||||||
git-fuzzy = super.callPackage ./git-fuzzy {};
|
deploy = prev.callPackage ./deploy.nix {};
|
||||||
kanidm-secret-manipulator = super.callPackage ./kanidm-secret-manipulator.nix {};
|
git-fuzzy = prev.callPackage ./git-fuzzy {};
|
||||||
segoe-ui-ttf = super.callPackage ./segoe-ui-ttf.nix {};
|
kanidm-secret-manipulator = prev.callPackage ./kanidm-secret-manipulator.nix {};
|
||||||
zsh-histdb-skim = super.callPackage ./zsh-skim-histdb.nix {};
|
segoe-ui-ttf = prev.callPackage ./segoe-ui-ttf.nix {};
|
||||||
|
zsh-histdb-skim = prev.callPackage ./zsh-skim-histdb.nix {};
|
||||||
|
|
||||||
kanidm = super.kanidm.overrideAttrs (_finalAttrs: _previousAttrs: {
|
kanidm = prev.kanidm.overrideAttrs (_finalAttrs: _previousAttrs: {
|
||||||
patches = [
|
patches = [
|
||||||
(super.fetchpatch {
|
(prev.fetchpatch {
|
||||||
name = "group-list-json-output.patch";
|
name = "group-list-json-output.patch";
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/kanidm/kanidm/pull/2016.patch";
|
url = "https://patch-diff.githubusercontent.com/raw/kanidm/kanidm/pull/2016.patch";
|
||||||
hash = "sha256-gc75KBzhth4fZvuvRa3Rjg1J7DIGy25mzUPCf2aha80=";
|
hash = "sha256-gc75KBzhth4fZvuvRa3Rjg1J7DIGy25mzUPCf2aha80=";
|
||||||
})
|
})
|
||||||
(super.fetchpatch {
|
(prev.fetchpatch {
|
||||||
name = "person-and-oauth-json-output.patch";
|
name = "person-and-oauth-json-output.patch";
|
||||||
url = "https://patch-diff.githubusercontent.com/raw/kanidm/kanidm/pull/2017.patch";
|
url = "https://patch-diff.githubusercontent.com/raw/kanidm/kanidm/pull/2017.patch";
|
||||||
hash = "sha256-fZgJ7dY2LHvBi64A/6o7kfArUAsLqjWRRpH2q1GL5ic=";
|
hash = "sha256-fZgJ7dY2LHvBi64A/6o7kfArUAsLqjWRRpH2q1GL5ic=";
|
||||||
|
@ -26,9 +27,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
formats =
|
formats =
|
||||||
super.formats
|
prev.formats
|
||||||
// {
|
// {
|
||||||
ron = import ./ron.nix {inherit (super) lib pkgs;};
|
ron = import ./ron.nix {inherit (prev) lib pkgs;};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|
7
pkgs/scripts/default.nix
Normal file
7
pkgs/scripts/default.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
_final: prev: {
|
||||||
|
scripts = {
|
||||||
|
screenshot-area = prev.callPackage ./screenshot-area.nix {};
|
||||||
|
screenshot-area-scan-qr = prev.callPackage ./screenshot-area-scan-qr.nix {};
|
||||||
|
screenshot-screen = prev.callPackage ./screenshot-screen.nix {};
|
||||||
|
};
|
||||||
|
}
|
58
pkgs/scripts/screenshot-area-scan-qr.nix
Normal file
58
pkgs/scripts/screenshot-area-scan-qr.nix
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
writeShellApplication,
|
||||||
|
libnotify,
|
||||||
|
xclip,
|
||||||
|
maim,
|
||||||
|
zbar,
|
||||||
|
yq,
|
||||||
|
}:
|
||||||
|
writeShellApplication {
|
||||||
|
name = "screenshot-area-scan-qr";
|
||||||
|
text = ''
|
||||||
|
set -euo pipefail
|
||||||
|
umask 077
|
||||||
|
|
||||||
|
# Create in-memory tmpfile
|
||||||
|
TMPFILE=$(mktemp)
|
||||||
|
exec 3<>"$TMPFILE"
|
||||||
|
rm "$TMPFILE" # still open in-memory as /dev/fd/3
|
||||||
|
TMPFILE=/dev/fd/3
|
||||||
|
|
||||||
|
date=$(date +"%Y-%m-%dT%H:%M:%S%:z")
|
||||||
|
out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$date-selection.png"
|
||||||
|
mkdir -p "$(dirname "$out")"
|
||||||
|
|
||||||
|
if ${maim}/bin/maim --color=.4,.7,1 --bordersize=1.0 --nodecorations=1 --hidecursor --format=png --quality=10 --noopengl --select \
|
||||||
|
| ${zbar}/bin/zbarimg --xml - > "$TMPFILE"; then
|
||||||
|
N=$(${yq}/bin/xq -r '.barcodes.source.index.symbol | if type == "array" then length else 1 end' < "$TMPFILE")
|
||||||
|
# Append codes Copy data separated by ---
|
||||||
|
DATA=$(${yq}/bin/xq -r '.barcodes.source.index.symbol | if type == "array" then .[0].data else .data end' < "$TMPFILE")
|
||||||
|
for ((i=1;i<N;++i)); do
|
||||||
|
DATA="$DATA"$'\n'"---"$'\n'"$(${yq}/bin/xq -r ".barcodes.source.index.symbol[$i].data" < "$TMPFILE")"
|
||||||
|
done
|
||||||
|
${xclip}/bin/xclip -selection clipboard <<< "$DATA"
|
||||||
|
${libnotify}/bin/notify-send \
|
||||||
|
"🔍 QR Code scan" "✅ $N codes detected\n📋 copied ''${#DATA} bytes" \
|
||||||
|
--hint="string:image-path:$out" \
|
||||||
|
--hint="string:wired-tag:screenshot-$date" \
|
||||||
|
|| true
|
||||||
|
else
|
||||||
|
case "$?" in
|
||||||
|
"4")
|
||||||
|
${libnotify}/bin/notify-send \
|
||||||
|
"🔍 QR Code scan" "❌ 0 codes detected" \
|
||||||
|
--hint="string:image-path:$out" \
|
||||||
|
--hint="string:wired-tag:screenshot-$date" \
|
||||||
|
|| true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
${libnotify}/bin/notify-send \
|
||||||
|
"🔍 QR Code scan" "❌ Error while processing image: zbarimg exited with code $?" \
|
||||||
|
--hint="string:image-path:$out" \
|
||||||
|
--hint="string:wired-tag:screenshot-$date" \
|
||||||
|
|| true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
}
|
46
pkgs/scripts/screenshot-area.nix
Normal file
46
pkgs/scripts/screenshot-area.nix
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
writeShellApplication,
|
||||||
|
libnotify,
|
||||||
|
xclip,
|
||||||
|
tesseract,
|
||||||
|
maim,
|
||||||
|
}:
|
||||||
|
writeShellApplication {
|
||||||
|
name = "screenshot-area";
|
||||||
|
text = ''
|
||||||
|
set -euo pipefail
|
||||||
|
umask 077
|
||||||
|
|
||||||
|
date=$(date +"%Y-%m-%dT%H:%M:%S%:z")
|
||||||
|
out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$date-selection.png"
|
||||||
|
mkdir -p "$(dirname "$out")"
|
||||||
|
|
||||||
|
${maim}/bin/maim --color=.4,.7,1,0.2 --bordersize=1.0 --nodecorations=1 \
|
||||||
|
--hidecursor --format=png --quality=10 --noopengl --select "$out"
|
||||||
|
${xclip}/bin/xclip -selection clipboard -t image/png < "$out"
|
||||||
|
action=$(${libnotify}/bin/notify-send \
|
||||||
|
"📷 Screenshot captured" "📋 copied to clipboard" \
|
||||||
|
--hint="string:wired-tag:screenshot-$date" \
|
||||||
|
--action=ocr=OCR) \
|
||||||
|
|| true
|
||||||
|
|
||||||
|
if [[ "$action" == "ocr" ]]; then
|
||||||
|
${libnotify}/bin/notify-send \
|
||||||
|
"📷 Screenshot captured" "⏳ Running OCR ..." \
|
||||||
|
--hint="string:wired-tag:screenshot-$date" \
|
||||||
|
|| true
|
||||||
|
|
||||||
|
if ${tesseract}/bin/tesseract "$out" - -l eng+deu | ${xclip}/bin/xclip -selection clipboard; then
|
||||||
|
${libnotify}/bin/notify-send \
|
||||||
|
"📷 Screenshot captured" "🔠 OCR copied to clipboard" \
|
||||||
|
--hint="string:wired-tag:screenshot-$date" \
|
||||||
|
|| true
|
||||||
|
else
|
||||||
|
${libnotify}/bin/notify-send \
|
||||||
|
"📷 Screenshot captured" "❌ Error while running OCR" \
|
||||||
|
--hint="string:wired-tag:screenshot-$date" \
|
||||||
|
|| true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
}
|
20
pkgs/scripts/screenshot-screen.nix
Normal file
20
pkgs/scripts/screenshot-screen.nix
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
writeShellApplication,
|
||||||
|
libnotify,
|
||||||
|
maim,
|
||||||
|
}:
|
||||||
|
writeShellApplication {
|
||||||
|
name = "screenshot-screen";
|
||||||
|
text = ''
|
||||||
|
set -euo pipefail
|
||||||
|
umask 077
|
||||||
|
|
||||||
|
out="''${XDG_PICTURES_DIR-$HOME/Pictures}/screenshots/$(date +"%Y-%m-%dT%H:%M:%S%:z")-fullscreen.png"
|
||||||
|
mkdir -p "$(dirname "$out")"
|
||||||
|
|
||||||
|
${maim}/bin/maim --hidecursor --format=png --quality=10 --noopengl "$out"
|
||||||
|
${libnotify}/bin/notify-send \
|
||||||
|
"📷 Screenshot captured" "💾 Saved to $out" \
|
||||||
|
|| true
|
||||||
|
'';
|
||||||
|
}
|
|
@ -88,67 +88,9 @@ in {
|
||||||
# TODO only open if not already open
|
# TODO only open if not already open
|
||||||
# TODO shortcut to open these from eww bar with 1 click
|
# TODO shortcut to open these from eww bar with 1 click
|
||||||
"b" = "exec firefox"; # TODO ; exec signal-desktop; exec discord
|
"b" = "exec firefox"; # TODO ; exec signal-desktop; exec discord
|
||||||
"Shift+s" =
|
"Shift+s" = "exec --no-startup-id ${getExe pkgs.scripts.screenshot-area}";
|
||||||
"exec --no-startup-id "
|
"F11" = "exec --no-startup-id ${getExe pkgs.scripts.screenshot-area-scan-qr}";
|
||||||
+ toString (pkgs.writeShellScript "screenshot-area" ''
|
"F12" = "exec --no-startup-id ${getExe pkgs.scripts.screenshot-screen}";
|
||||||
set -euo pipefail
|
|
||||||
umask 077
|
|
||||||
|
|
||||||
out="/tmp/screenshots.$UID/$(date +"%Y-%m-%dT%H:%M:%S%:z")-selection.png"
|
|
||||||
mkdir -p "$(dirname "$out")"
|
|
||||||
|
|
||||||
${pkgs.maim}/bin/maim --color=.4,.7,1,0.2 --bordersize=1.0 --nodecorations=1 --hidecursor --format=png --quality=10 --noopengl --select "$out"
|
|
||||||
notification_id=$(${pkgs.libnotify}/bin/notify-send --icon="$out" --print-id --app-name "screenshot-area" "Screenshot Captured" "📋 copied to clipboard\n⌛ Running OCR...")
|
|
||||||
${pkgs.xclip}/bin/xclip -selection clipboard -t image/png < "$out"
|
|
||||||
if ${pkgs.tesseract}/bin/tesseract "$out" - -l eng+deu | ${pkgs.xclip}/bin/xclip -selection primary; then
|
|
||||||
${pkgs.libnotify}/bin/notify-send --icon="$out" --replace-id="$notification_id" --app-name "screenshot-area" "Screenshot Captured" "📋 copied to clipboard\n✅ OCR (copied to primary)."
|
|
||||||
else
|
|
||||||
${pkgs.libnotify}/bin/notify-send --icon="$out" --replace-id="$notification_id" --app-name "screenshot-area" "Screenshot Captured" "📋 copied to clipboard\n❌ Error while running OCR."
|
|
||||||
fi
|
|
||||||
'');
|
|
||||||
"F11" =
|
|
||||||
"exec --no-startup-id "
|
|
||||||
# TODO use writeShellApplication for shellcheck
|
|
||||||
# TODO --icon=some-qr-image
|
|
||||||
+ toString (pkgs.writeShellScript "screenshot-area-scan-qr" ''
|
|
||||||
set -euo pipefail
|
|
||||||
umask 077
|
|
||||||
|
|
||||||
# Create in-memory tmpfile
|
|
||||||
TMPFILE=$(mktemp)
|
|
||||||
exec 3<>"$TMPFILE"
|
|
||||||
rm "$TMPFILE" # still open in-memory as /dev/fd/3
|
|
||||||
TMPFILE=/dev/fd/3
|
|
||||||
|
|
||||||
if ${pkgs.maim}/bin/maim --color=.4,.7,1 --bordersize=1.0 --nodecorations=1 --hidecursor --format=png --quality=10 --noopengl --select \
|
|
||||||
| ${pkgs.zbar}/bin/zbarimg --xml - > "$TMPFILE"; then
|
|
||||||
N=$(${pkgs.yq}/bin/xq -r '.barcodes.source.index.symbol | if type == "array" then length else 1 end' < "$TMPFILE")
|
|
||||||
# Append codes Copy data separated by ---
|
|
||||||
DATA=$(${pkgs.yq}/bin/xq -r '.barcodes.source.index.symbol | if type == "array" then .[0].data else .data end' < "$TMPFILE")
|
|
||||||
for ((i=1;i<N;++i)); do
|
|
||||||
DATA="$DATA"$'\n'"---"$'\n'"$(${pkgs.yq}/bin/xq -r ".barcodes.source.index.symbol[$i].data" < "$TMPFILE")"
|
|
||||||
done
|
|
||||||
${pkgs.xclip}/bin/xclip -selection clipboard <<< "$DATA"
|
|
||||||
${pkgs.libnotify}/bin/notify-send --app-name "screenshot-area-scan-qr" "QR Scan" "✅ $N codes detected\\n📋 copied ''${#DATA} bytes"
|
|
||||||
else
|
|
||||||
case "$?" in
|
|
||||||
"4") ${pkgs.libnotify}/bin/notify-send --app-name "screenshot-area-scan-qr" "QR Scan" "❌ 0 codes detected" ;;
|
|
||||||
*) ${pkgs.libnotify}/bin/notify-send --app-name "screenshot-area-scan-qr" "QR Scan" "❌ Error while processing image: zbarimg exited with code $?" ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
'');
|
|
||||||
"F12" =
|
|
||||||
"exec --no-startup-id "
|
|
||||||
+ toString (pkgs.writeShellScript "screenshot-screen" ''
|
|
||||||
set -euo pipefail
|
|
||||||
umask 077
|
|
||||||
|
|
||||||
out="${config.xdg.userDirs.pictures}/screenshots/$(date +"%Y-%m-%dT%H:%M:%S%:z")-fullscreen.png"
|
|
||||||
mkdir -p "$(dirname "$out")"
|
|
||||||
|
|
||||||
${pkgs.maim}/bin/maim --hidecursor --format=png --quality=10 --noopengl "$out"
|
|
||||||
notification_id=$(${pkgs.libnotify}/bin/notify-send --icon="$out" --print-id --app-name "screenshot-screen" "Screenshot Captured" "💾 saved to $out")
|
|
||||||
'');
|
|
||||||
|
|
||||||
"Shift+r" = "reload";
|
"Shift+r" = "reload";
|
||||||
"q" = "kill";
|
"q" = "kill";
|
||||||
|
@ -261,9 +203,39 @@ in {
|
||||||
};
|
};
|
||||||
in ''
|
in ''
|
||||||
exec_always --no-startup-id ${getExe i3-per-workspace-layout} --config ${configLayouts}
|
exec_always --no-startup-id ${getExe i3-per-workspace-layout} --config ${configLayouts}
|
||||||
|
for_window [class="^flameshot$"] floating enable, border none
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.user = {
|
||||||
|
targets.i3-session = {
|
||||||
|
Unit = {
|
||||||
|
Description = "i3 session";
|
||||||
|
Documentation = ["man:systemd.special(7)"];
|
||||||
|
BindsTo = ["graphical-session.target"];
|
||||||
|
Wants = ["graphical-session-pre.target"];
|
||||||
|
After = ["graphical-session-pre.target"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
services = {
|
||||||
|
#feh = {
|
||||||
|
# Unit = {
|
||||||
|
# Description = "feh background";
|
||||||
|
# PartOf = [ "i3-session.target" ];
|
||||||
|
# After = [ "xrandr.service" "picom.service" ];
|
||||||
|
# };
|
||||||
|
# Service = {
|
||||||
|
# ExecStart = "${pkgs.feh}/bin/feh --bg-fill ${config.xdg.dataHome}/wall.png";
|
||||||
|
# RemainAfterExit = true;
|
||||||
|
# Type = "oneshot";
|
||||||
|
# };
|
||||||
|
# Install.WantedBy = [ "i3-session.target" ];
|
||||||
|
#};
|
||||||
|
wired.Install.WantedBy = lib.mkForce ["i3-session.target"];
|
||||||
|
flameshot.Install.WantedBy = lib.mkForce ["i3-session.target"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
programs.autorandr.enable = true;
|
programs.autorandr.enable = true;
|
||||||
programs.autorandr.profiles =
|
programs.autorandr.profiles =
|
||||||
{
|
{
|
||||||
|
|
|
@ -165,6 +165,7 @@ in {
|
||||||
.${nixosConfig.node.name}
|
.${nixosConfig.node.name}
|
||||||
or {};
|
or {};
|
||||||
};
|
};
|
||||||
|
# TODO for_window [app_id="flameshot"] border pixel 0, floating enable, fullscreen disable, move absolute position 0 0
|
||||||
|
|
||||||
home.sessionVariables = {
|
home.sessionVariables = {
|
||||||
# Let nixos electron wrappers enable wayland
|
# Let nixos electron wrappers enable wayland
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue