dotfiles/home-manager/modules/xmonad/default.nix

141 lines
4.2 KiB
Nix
Raw Normal View History

# 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
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.magic_rb.programs.xmonad;
in {
options.magic_rb.programs.xmonad = {
enable = mkEnableOption "Enable xmonad config";
2021-01-24 17:43:50 +01:00
enableDunst = mkOption {
description = "Enable dunst";
type = types.bool;
default = true;
};
enablePicom = mkOption {
description = "Enable picom";
type = types.bool;
default = true;
};
enableKeynav = mkOption {
description = "Enable keynav";
type = types.bool;
default = true;
};
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
];
home.file.".keynavrc".source = ./keynavrc;
home.file.".xmonad/xmonad.hs".source = pkgs.writeSubstitutedFile {
name = "xmonad.hs";
file = ./xmonad.hs;
substitutes = {
"screenshot" = lib.getExe pkgs.magic_rb.screenshot;
"emacs-rofi" = lib.getExe pkgs.emacs-rofi;
"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
'';
"auxmenu" = pkgs.writeShellScript "auxmenu"
''
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"
_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
;;
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
;;
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
;;
*)
;;
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;
"dunstConfig" = ./dunstrc;
"picom" = lib.getExe pkgs.picom;
"picomConfig" = ./picom.conf;
"picomArgs" =
if cfg.picomExperimentalBackends
then "--experimental-backends"
else "";
"keynav" = lib.getExe pkgs.keynav;
"lightLocker" = lib.getExe pkgs.lightlocker;
"lightLockerCommand" = "${pkgs.lightlocker}/bin/light-locker-command";
"brightnessctl" = lib.getExe pkgs.brightnessctl;
};
2021-01-24 17:43:50 +01:00
};
2021-02-26 10:24:58 +01:00
};
2021-01-24 17:43:50 +01:00
}