{ config, pkgs, lib, ... }:

let
  cfg = config.subs.sxhkd;
in 
{
  options.subs.sxhkd.enable = lib.mkOption {
    default = false;
    type = lib.types.bool;
  };

  config = lib.mkIf cfg.enable {
    services.sxhkd = {
      enable = true;
      keybindings = {
        "super + Return" = "ghostty";
        "super + b" = "zen-beta";
        "super + f" = "thunar";
        "super + m" = "emacsclient -ca ''";
        "super + t" = "flatpak run eu.betterbird.Betterbird";
        "super + c" = "speedcrunch";
        "super + ctrl + 1" = "/home/dpv/.local/bin/books";
        "XF86MonBrightness{Up,Down}" = "brightnessctl {-q set 3%+,--min-val=2 -q set 3%-}";
        "super + ctrl + {equal,minus}" = "brightnessctl {-q set 3%+,--min-val=2 -q set 3%-}";
        "XF86PowerOff" = "~/.config/rofi/scripts/powermenu.sh";
        "XF86Audio{Raise,Lower}Volume" = "pactl set-sink-volume @DEFAULT_SINK@ {+5%,-5%}";
        "XF86Audio{Mic,_}Mute" = "pactl {set-source-mute @DEFAULT_SOURCE@,set-sink-mute @DEFAULT_SINK@} toggle";
        "XF86Audio{Prev,Next}" = "mpc -q {prev,next}";
        "XF86Audio{Stop,Play}" = "mpc {stop,toggle}";
        "super + ctrl + {comma,period,slash}" = "mpc {-q prev,-q next,toggle}";
        "alt + space" = "/home/dpv/.config/rofi/scripts/launcher.sh";
        "super + shift + d" = "/home/dpv/.local/bin/define";
        "super + ctrl + shift + 7" = "/home/dpv/.local/bin/keyboard-toggle";
        "super + ctrl + shift + 6" = "/home/dpv/.local/bin/touchpad-toggle-xinput";
        "super + shift + F8" = "setxkbmap -option 'caps:escape' && notify-send 'Caps' 'Remapped to Esc'";
        "super + z" = "rofi -modi 'Clipboard:greenclip print' -show Clipboard -run-command '{cmd}' -theme ~/.config/rofi/menu.rasi";
        "super + ctrl + shift + k" = "screenkey";
        "ctrl + Print" = "flameshot gui";
        "super + shift + p" = "flameshot gui";
        "Print" = "flameshot full";
        "ctrl + alt + n" = "/home/dpv/.config/rofi/scripts/powermenu.sh";
      };
    };

    systemd.user.services.sxhkd-daemon = {
      Unit = { Description = "SXHKD Daemon."; };
      Install = {
        WantedBy = [ "graphical-session.target" "default.target" ];
      };
      Service = {
        ExecStart = "${pkgs.sxhkd}/bin/sxhkd -m 1";
        Restart = "always";
      };
    };
  };
}
