nix-conf-xmonad/modules/xmonad/default.nix

225 lines
7.7 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.xmonad;
xmonadConfig = with pkgs; callPackage ./buildXmonad.nix {inherit (pkgs.haskellPackages) xmonad-masser; } cfg.dhallConfigPath cfg.packages;
gifs = pkgs.callPackage ./gifs.nix {};
saver_mpv = pkgs.writeScript "saver_mpv" ''
#!${pkgs.bash}/bin/bash
PATH=${makeBinPath [pkgs.mpv pkgs.coreutils pkgs.findutils]}:$PATH
video=`find ${gifs} -type f | sort -R | head -n 1`
mpv \
--no-input-terminal \
--really-quiet \
--scale=oversample \
--loop \
--no-stop-screensaver \
--wid="''${XSCREENSAVER_WINDOW}" \
--no-audio "$video" &
exec ${pkgs.xsecurelock}/libexec/xsecurelock/saver_blank
'';
lock = pkgs.writeScript "lock.sh" ''
#!${pkgs.bash}/bin/bash
PATH=${makeBinPath [pkgs.gnupg pkgs.coreutils pkgs.findutils]}:$PATH
gpg-connect-agent reloadagent /bye
export XSECURELOCK_SAVER=${saver_mpv}
export XSECURELOCK_PASSWORD_PROMPT="emoticon"
${pkgs.xsecurelock}/bin/xsecurelock
'';
in {
options = {
programs.xmonad = {
enable = mkEnableOption "Enable xmonad";
dhallConfigPath = mkOption {
type = types.path;
};
packages = mkOption {
type = types.attrsOf types.package;
default = {};
};
};
};
config = mkIf cfg.enable {
home.packages = with pkgs; [
source-code-pro
dmenu
gnome3.zenity
rofi
haskellPackages.xmobar
xorg.xmodmap
xorg.xev
xorg.xset
xorg.xbacklight
xclip
xcalib
i3lock
];
services.screen-locker = {
enable = true;
lockCmd = "${lock}";
};
services.random-background = {
enable = true;
enableXinerama = true;
imageDirectory = "%h/backgrounds";
};
services.picom = {
enable = true;
activeOpacity = "1.0";
inactiveOpacity = "0.95";
backend = "glx";
fade = true;
fadeDelta = 5;
opacityRule = [ "100:name *= 'i3lock'"];
};
xsession = {
enable = true;
windowManager.xmonad = {
enable = true;
enableContribAndExtras = true;
extraPackages = h: [h.xmonad-contrib h.xmonad-masser];
config =
let toAppKey = k: _: "${k} :: FilePath";
toApp = k: v: ''Application {_applicationName = "${k}", _applicationAction = "${v}"}'';
applications = concatStringsSep "\n , " (mapAttrsToList toApp cfg.applications);
orNothingStr = x: if null == x then "Nothing" else ''Just "${x}"'';
quoted = x: ''"${x}"'';
toTopic = k: v: ''TopicRule {_topicRuleName = "${k}", _topicRuleHome = ${orNothingStr v.home}, _topicRuleAction = ${orNothingStr v.action}, _topicRuleClasses = [${concatStringsSep ", " (map quoted v.classes)}]}'';
topics = concatStringsSep "\n , " (mapAttrsToList toTopic cfg.topics);
toSearch = k: v: ''Search {_searchName="${k}", _searchKey="${v.key}", _searchUrl="${v.url}"}'';
searches = concatStringsSep "\n , " (mapAttrsToList toSearch cfg.searches);
in pkgs.writeText "xmonad.hs"
''
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NamedFieldPuns #-}
module Main where
-- This is autogenerated file, don't touch
import XMonad.Config.MasseR
main :: IO ()
main = masser
'';
};
initExtra = ''
xmodmap ~/.Xmodmap
${pkgs.xcape}/bin/xcape -e 'Hyper_L=Tab'
'';
};
services.dunst = {
enable = true;
settings = {
global = {
geometry = "300x5-30+20";
indicate_hidden = "yes";
sort = "yes";
word_wrap = "no";
stack_duplicates = "yes";
show_indicators = "yes";
browser = "${pkgs.firefox}/bin/firefox";
transparency = "0";
separator_height = "2";
padding = "8";
horizontal_padding = 8;
frame_width = "8";
frame_color = "#aaaaaa";
separator_color = "frame";
font = "Monospace 8";
format = "<b>%s</b>\\n%b";
};
urgency_low = {
background = "#222222";
foreground = "#888888";
};
urgency_normal = {
background = "#285577";
foreground = "#ffffff";
};
urgency_critical = {
background = "#900000";
foreground = "#ffffff";
frame_color = "#ff0000";
};
};
};
services.unclutter = {
enable = true;
};
home.file.".xmonad/xmonad.dhall".source = xmonadConfig + "/source.dhall";
# programs.xmonad =
# let
# musicToggle = pkgs.writeScript "musictoggle" ''
# ${pkgs.mpc_cli}/bin/mpc toggle
# '';
# # musicCurrent = with pkgs; writeScript "musiccurrent" ''
# # export PATH=${lib.makeBinPath [sp gawk]}
# # sp current | awk '/^Title/ {$1 = ""; print $0}'
# # '';
# musicCurrent = with pkgs; writeScript "musiccurrent" ''
# export PATH=${lib.makeBinPath [mpc_cli]}
# mpc --format "%title%" current
# '';
# xmobarConf = pkgs.writeText "xmobar" ''
# Config {
# font = "xft:Inconsolata-9"
# , bgColor = "#3F3F3F"
# , fgColor = "#DCDCCC"
# , position = Top
# , lowerOnStart = True
# , pickBroadest = True
# , commands = [
# Run MultiCpu ["-t", "CPU: <total>%"] 30
# , Run Memory ["-t", "Mem: <usedbar> (<cache>M)"] 3600
# , Run Date "%a %b %_d %Y %H:%M:%S" "date" 20
# , Run StdinReader
# , Run Battery [ "--template" , "Batt: <acstatus>"
# , "--Low" , "10" -- units: %
# , "--High" , "80" -- units: %
# , "--low" , "darkred"
# , "--normal" , "darkorange"
# , "--high" , "darkgreen"
#
# , "--" -- battery specific options
# -- discharging status
# , "-o" , "<left>% (<timeleft>)"
# -- AC "on" status
# , "-O" , "<fc=#dAA520>Charging</fc>"
# -- charged status
# , "-i" , "<fc=#006000>Charged</fc>"
# ] 120
# , Run DynNetwork [ "--template" , "<dev>: <tx>kB/s|<rxbar>kB/s"
# , "--Low" , "1000" -- units: B/s
# , "--High" , "500000" -- units: B/s
# , "--normal" , "darkorange"
# , "--high" , "darkred"
# ] 30
# ]
# , sepChar = "%"
# , alignSep = "}{"
# , template = "%StdinReader% }{%dynnetwork% | %battery% | %multicpu% | %memory% | <fc=#FFFFCC>%date%</fc>"
# }
# '';
# # browser = "${pkgs.qutebrowser}/bin/qutebrowser";
# chromiumApp = name: url: pkgs.writeScriptBin "${name}" ''
# ${pkgs.chromium}/bin/chromium --user-data-dir=~/.config/chromium-${name} --app=${url}
# '';
# custom_teams = chromiumApp "teams" "https://teams.microsoft.com";
# flowdock = chromiumApp "flowdock" "https://flowdock.com/app";
# wiki = chromiumApp "wiki" "https://wiki.relexsolutions.com";
# xmonadConfig = with pkgs; callPackage ./buildXmonad.nix {} cfg.dhallConfigPath cfg.packages;
# in
# {
# enable = true;
# configPackage = xmonadConfig;
# };
};
}