nix-config/users/common/Xorg/i3.nix

104 lines
3.3 KiB
Nix
Raw Normal View History

2023-09-27 13:16:36 +02:00
{
config,
pkgs,
lib,
2023-09-27 13:16:36 +02:00
...
2024-07-26 22:12:48 +02:00
}:
{
2023-09-24 20:43:44 +02:00
# import shared sway config
2024-07-26 22:12:48 +02:00
imports = [ ../sway3.nix ];
systemd.user.services = {
2024-07-26 22:12:48 +02:00
flameshot.Install.WantedBy = lib.mkForce [ "i3-session.target" ];
};
2023-09-22 20:57:08 +02:00
stylix.targets.i3.enable = true;
2023-12-25 18:15:29 +01:00
2023-09-13 21:32:05 +02:00
xsession.windowManager.i3 = {
enable = true;
2023-12-25 18:15:29 +01:00
enableSystemdTarget = true;
2023-09-24 20:43:44 +02:00
config = {
startup = [
2024-07-26 22:12:48 +02:00
{
command = "${pkgs.xorg.xrandr}/bin/xrandr --output DVI-D-0 --mode 1920x1080 --pos 0x0 --rate 60.00 --output DP-4 --mode 2560x1440 --pos 1920x720 --primary --rate 144 --output HDMI-0 --pos 0x1080 --rate 60.00";
}
];
2023-09-24 20:43:44 +02:00
menu = "rofi -show drun";
2024-07-26 22:12:48 +02:00
keybindings =
let
cfg = config.xsession.windowManager.i3.config;
maim = "${pkgs.maim}/bin/maim -qs -b 1 --hidecursor";
2023-09-27 20:49:09 +02:00
in
2024-07-26 22:12:48 +02:00
{
"Menu" = "exec ${cfg.menu}";
"Ctrl+F9" = "exec ${config.xsession.wallpapers.script}";
"${cfg.modifier}+F12" =
"exec "
+ toString (
pkgs.writeShellScript "clipboard-screenshot" ''
${maim} | ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png
''
);
"${cfg.modifier}+F11" =
"exec "
+ toString (
pkgs.writeShellScript "clipboard-screenshot" ''
out="screenshot-$(date +"%Y-%m-%dT%H:%M:%S%:z")"
${maim} | ${pkgs.xclip}/bin/xclip -selection clipboard -t image/png
''
);
"${cfg.modifier}+F10" =
let
nsend = ''
${pkgs.libnotify}/bin/notify-send \
-h string:category:Screenshot\
'';
in
"exec "
+ toString (
pkgs.writeShellScript "clipboard-qr-screenshot" ''
set -euo pipefail
if qr=$(${maim} | ${pkgs.zbar}/bin/zbarimg -q --raw -); then
return=$?
else
return=$?
fi
case "$return" in
"0")
${nsend} "Copied qr to clipboard"
${pkgs.xclip}/bin/xclip -selection clipboard -f <<< ''${qr%"''${qr##*[![:space:]]}"}
exit 0
;;
"4")
${nsend} "No qr found"
;;
*)
${nsend} "Failure scanning qr"
;;
esac
''
);
"${cfg.modifier}+F9" =
"exec "
+ toString (
pkgs.writeShellScript "clipboard-ocr-screenshot" ''
set -euo pipefail
qr=$(${maim} | ${pkgs.zbar}/bin/zbarimg -q --raw -) || true
case "$?" in
0)
${pkgs.libnotify}/bin/notify-send -h string:category:"Screenshot" "Copied qr to clipboard"
${pkgs.xclip}/bin/xclip -selection clipboard -f <<< ''${qr%"''${qr##*[![:space:]]}"}
exit 0
;;
4)
${pkgs.libnotify}/bin/notify-send -h string:category:"Screenshot" "No qr found"
;;
*)
${pkgs.libnotify}/bin/notify-send -h string:category:"Screenshot" "Failure scanning qr"
;;
esac
''
);
};
2023-09-24 20:43:44 +02:00
};
2023-09-13 21:32:05 +02:00
};
}