2022-07-31 11:03:59 +02:00
|
|
|
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
2021-01-24 17:43:50 +01:00
|
|
|
{
|
2022-07-31 11:03:59 +02:00
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.magic_rb.programs.xmonad;
|
|
|
|
in {
|
2021-04-11 00:25:36 +02:00
|
|
|
options.magic_rb.programs.xmonad = {
|
|
|
|
enable = mkEnableOption "Enable xmonad config";
|
2021-01-24 17:43:50 +01:00
|
|
|
|
2021-04-11 00:25:36 +02:00
|
|
|
enableDunst = mkOption {
|
|
|
|
description = "Enable dunst";
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
enablePicom = mkOption {
|
|
|
|
description = "Enable picom";
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
2022-04-15 09:52:23 +02:00
|
|
|
enableKeynav = mkOption {
|
|
|
|
description = "Enable keynav";
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
|
2021-04-11 00:25:36 +02:00
|
|
|
picomExperimentalBackends = mkOption {
|
|
|
|
description = "Enable experimental backends in picom";
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
home.packages = with pkgs; [
|
|
|
|
powerline-fonts
|
|
|
|
font-awesome
|
|
|
|
dejavu_fonts
|
|
|
|
];
|
|
|
|
|
2022-04-15 09:52:23 +02:00
|
|
|
home.file.".keynavrc".source = ./keynavrc;
|
|
|
|
|
2021-12-22 23:48:31 +01:00
|
|
|
home.file.".xmonad/xmonad.hs".source = pkgs.writeSubstitutedFile {
|
2021-04-11 00:25:36 +02:00
|
|
|
name = "xmonad.hs";
|
|
|
|
file = ./xmonad.hs;
|
|
|
|
substitutes = {
|
2023-05-28 13:56:08 +02:00
|
|
|
"screenshot" = lib.getExe pkgs.magic_rb.screenshot;
|
2023-05-28 12:49:08 +02:00
|
|
|
"emacs-rofi" = lib.getExe pkgs.emacs-rofi;
|
2023-05-28 13:56:08 +02:00
|
|
|
"notify" = lib.getExe pkgs.libnotify;
|
|
|
|
"reload" = pkgs.writeShellScript "xmonad-reload"
|
|
|
|
''
|
|
|
|
${lib.getExe pkgs.libnotify} -t 5000 "recompiling xmonad"
|
|
|
|
|
|
|
|
if xmonad --recompile
|
|
|
|
then
|
|
|
|
${lib.getExe pkgs.libnotify} -t 5000 "compilation succeeded"
|
|
|
|
xmonad --restart
|
|
|
|
else
|
|
|
|
${lib.getExe pkgs.libnotify} -t 5000 "compilation failed"
|
|
|
|
fi
|
|
|
|
'';
|
2023-05-28 12:49:08 +02:00
|
|
|
"auxmenu" = pkgs.writeShellScript "auxmenu"
|
|
|
|
''
|
2023-05-28 16:14:30 +02:00
|
|
|
export SUDO_ASKPASS=${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass
|
|
|
|
|
|
|
|
_options="toggle-mic\ntoggle-radio\nscreenshot-all\nscreenshot-select\nscreenshot-focused\nsuspend\nreboot\nkexec\npoweroff"
|
2021-04-11 00:25:36 +02:00
|
|
|
|
2023-05-28 12:49:08 +02:00
|
|
|
_option="$(echo -e $_options | emacs-rofi "command: " 90 30 | awk '{print $1}' | tr -d '\r\n')"
|
|
|
|
if [ ''${#_option} -gt 0 ]
|
|
|
|
then
|
|
|
|
case $_option in
|
|
|
|
toggle-mic)
|
|
|
|
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle
|
|
|
|
;;
|
|
|
|
toggle-radio)
|
|
|
|
if [ "$(nmcli radio wifi)" = "enabled" ]
|
|
|
|
then
|
|
|
|
nmcli radio wifi off
|
|
|
|
else
|
|
|
|
nmcli radio wifi on
|
|
|
|
fi
|
|
|
|
;;
|
2023-05-28 13:56:08 +02:00
|
|
|
screenshot-all)
|
|
|
|
${lib.getExe pkgs.magic_rb.screenshot} screen
|
|
|
|
;;
|
|
|
|
screenshot-select)
|
|
|
|
${lib.getExe pkgs.magic_rb.screenshot} select
|
|
|
|
;;
|
|
|
|
screenshot-focused)
|
|
|
|
${lib.getExe pkgs.magic_rb.screenshot} focused
|
|
|
|
;;
|
2023-05-28 16:14:30 +02:00
|
|
|
suspend)
|
|
|
|
systemctl suspend
|
|
|
|
;;
|
|
|
|
reboot)
|
|
|
|
systemctl reboot
|
|
|
|
;;
|
|
|
|
poweroff)
|
|
|
|
systemctl poweroff
|
|
|
|
;;
|
|
|
|
kexec)
|
|
|
|
sudo -A kexec -l /run/current-system/kernel --initrd=/run/current-system/initrd --reuse-cmdline
|
|
|
|
systemctl kexec
|
|
|
|
;;
|
2023-05-28 12:49:08 +02:00
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
"dmenu_run" = "${pkgs.dmenu}/bin/dmenu_run";
|
|
|
|
"polybar" = pkgs.writeShellScript "polybar"
|
|
|
|
''
|
|
|
|
monitors=$(polybar --list-monitors | cut -f 1 -d':')
|
|
|
|
MONITOR=''${monitors[$1]} ${lib.getExe pkgs.polybarFull} -c ${./polybar.ini} top
|
|
|
|
'';
|
|
|
|
"dunst" = lib.getExe pkgs.dunst;
|
2021-04-11 00:25:36 +02:00
|
|
|
"dunstConfig" = ./dunstrc;
|
|
|
|
|
2023-05-28 12:49:08 +02:00
|
|
|
"picom" = lib.getExe pkgs.picom;
|
2021-04-11 00:25:36 +02:00
|
|
|
"picomConfig" = ./picom.conf;
|
2023-05-28 12:49:08 +02:00
|
|
|
"picomArgs" =
|
2022-07-31 11:03:59 +02:00
|
|
|
if cfg.picomExperimentalBackends
|
|
|
|
then "--experimental-backends"
|
|
|
|
else "";
|
2022-04-15 09:52:23 +02:00
|
|
|
|
2023-05-28 12:49:08 +02:00
|
|
|
"keynav" = lib.getExe pkgs.keynav;
|
|
|
|
"lightLocker" = lib.getExe pkgs.lightlocker;
|
|
|
|
"lightLockerCommand" = "${pkgs.lightlocker}/bin/light-locker-command";
|
|
|
|
"brightnessctl" = lib.getExe pkgs.brightnessctl;
|
2021-04-11 00:25:36 +02:00
|
|
|
};
|
2021-01-24 17:43:50 +01:00
|
|
|
};
|
2021-02-26 10:24:58 +01:00
|
|
|
};
|
2021-01-24 17:43:50 +01:00
|
|
|
}
|