nix-dotfiles/home/services/sxhkd.nix

105 lines
3.3 KiB
Nix
Raw Permalink Normal View History

2024-06-02 16:25:58 +02:00
{ config, pkgs, lib, ... }:
let
cfg = config.services.sxhkd;
keybindingsStr = lib.concatStringsSep "\n" (lib.mapAttrsToList (hotkey: command:
lib.optionalString (command != null) ''
${hotkey}
${command}
'') cfg.keybindings);
in
2022-03-07 16:01:52 +01:00
{
services.sxhkd = {
2024-06-02 16:25:58 +02:00
enable = false;
keybindings = {
2022-03-07 16:01:52 +01:00
# make sxhkd reload its configuration files:
"super + Escape" = "pkill -USR1 -x sxhkd && ${pkgs.libnotify}/bin/notify-send -t 3000 \"sxhkd configuration reloaded\"";
# Applications
"super + s" = "$BROWSER";
"super + r" = "${pkgs.rofi}/bin/rofi -show drun";
# Volume
2024-11-18 14:26:43 +01:00
"super + {@F7,@F8}" = "${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%{-,+}";
2022-03-07 16:01:52 +01:00
2024-11-18 14:26:43 +01:00
"{XF86AudioLowerVolume,XF86AudioRaiseVolume}" = "${pkgs.wireplumber}/bin/wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%{-,+}";
2022-03-07 16:01:52 +01:00
2024-11-18 14:26:43 +01:00
"XF86AudioMute" = "${pkgs.wireplumber}/bin/wpctl set-mute toggle";
2022-03-07 16:01:52 +01:00
# Music
"super + p" = "${pkgs.mpc_cli}/bin/mpc toggle";
"XF86AudioPlay" = "${pkgs.mpc_cli}/bin/mpc toggle";
"XF86AudioPrev" = "${pkgs.mpc_cli}/bin/mpc prev";
"XF86AudioNext" = "${pkgs.mpc_cli}/bin/mpc next";
# Monitor
"XF86MonBrightnessUp" = "${pkgs.light}/bin/light -A 5";
"XF86MonBrightnessDown" = "${pkgs.light}/bin/light -U 5";
"@Print" = "${pkgs.maim}/bin/maim --hidecursor --nokeyboard --select | ${pkgs.xclip}/bin/xclip -selection clipboard -target image/png -in";
"shift + @Print" = "${pkgs.maim}/bin/maim --hidecursor --nokeyboard $SCREENSHOT_DIR/$(date +%s).png";
# TODO: Add boomer as package
# "super + @Print" = "boomer";
# Misc
2024-06-08 12:42:12 +02:00
"super + l" = "loginctl lock-session";
2022-03-07 16:01:52 +01:00
"super + a" = "${pkgs.copyq}/bin/copyq toggle";
2024-06-02 16:25:58 +02:00
# fcitx "super + {b,n,m}" = "${pkgs.fcitx}/bin/fcitx-remote -s {mozc,fcitx-keyboard-no,fcitx-keyboard-us}";
2022-03-07 16:01:52 +01:00
# fcitx5
2022-11-20 18:32:03 +01:00
"super + {b,n,m}" = "${pkgs.fcitx5}/bin/fcitx5-remote -s {mozc,keyboard-no,keyboard-us}";
2022-03-07 16:01:52 +01:00
# TODO: fix
2022-03-07 16:01:52 +01:00
# "super + v" = "${pkgs.rofi}/bin/rofi -modi lpass:$HOME/.scripts/rofi/lpass/rofi-lpass -show lpass";
"super + minus" = "${pkgs.xcalib}/bin/xcalib -invert -alter";
# ¯\_(ツ)_/¯
# "super + shift + s"
# sleep 0.3; \
# ${pkgs.xdotool}/bin/xdotool key U00AF; \
# ${pkgs.xdotool}/bin/xdotool key U005C; \
# ${pkgs.xdotool}/bin/xdotool key U005F; \
# ${pkgs.xdotool}/bin/xdotool key U0028; \
# ${pkgs.xdotool}/bin/xdotool key U30C4; \
# ${pkgs.xdotool}/bin/xdotool key U0029; \
# ${pkgs.xdotool}/bin/xdotool key U005F; \
# ${pkgs.xdotool}/bin/xdotool key U002F; \
# ${pkgs.xdotool}/bin/xdotool key U00AF
# é
"super + shift + e" = "sleep 0.3; ${pkgs.xdotool}/bin/xdotool key U00E9";
};
2022-03-07 16:01:52 +01:00
};
2024-06-02 16:25:58 +02:00
xdg.configFile."sxhkd/sxhkdrc".text =
lib.concatStringsSep "\n" [ keybindingsStr cfg.extraConfig ];
home.packages = [ cfg.package ];
systemd.user.services.sxhkd = {
Unit = {
Description = "Simple X hotkey daemon";
PartOf = [ "graphical-session.target" ];
After = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${cfg.package}/bin/sxhkd ${toString cfg.extraOptions}";
Restart = "always";
};
Install.WantedBy = [ "graphical-session.target" ];
};
2022-03-07 16:01:52 +01:00
}