213 lines
9.3 KiB
Nix
213 lines
9.3 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
inputs,
|
|
system,
|
|
...
|
|
}:
|
|
{
|
|
options.custom.gui = with lib; {
|
|
i3 = {
|
|
enable = mkEnableOption "Enable i3";
|
|
};
|
|
};
|
|
config = lib.mkIf config.custom.gui.i3.enable {
|
|
xdg.configFile."i3status/config".source = pkgs.replaceVars ./i3status.config { };
|
|
services.picom = {
|
|
enable = true;
|
|
};
|
|
services.dunst = {
|
|
enable = true;
|
|
};
|
|
home.pointerCursor = {
|
|
package = pkgs.adwaita-icon-theme;
|
|
name = "Adwaita";
|
|
size = 32;
|
|
x11.enable = true;
|
|
};
|
|
xsession = {
|
|
enable = true;
|
|
scriptPath = ".xsession-hm";
|
|
initExtra = ''
|
|
# export GDK_SCALE=2
|
|
# export GDK_DPI_SCALE=0.5
|
|
export _JAVA_OPTIONS="-Dsun.java2d.uiScale=2"
|
|
export QT_AUTO_SCREEN_SCALE_FACTOR=1
|
|
export QT_DEVICE_PIXEL_RATIO=2
|
|
# export XCURSOR_SIZE=128
|
|
# ${pkgs.xorg.xsetroot}/bin/xsetroot -cursor_name ${pkgs.vanilla-dmz}/share/icons/Vanilla-DMZ/cursors/left_ptr 128 &disown
|
|
if test -e $HOME/.Xresources; then
|
|
${pkgs.xorg.xrdb}/bin/xrdb -merge $HOME/.Xresources &disown
|
|
fi
|
|
echo "Xft.dpi: 192" | ${pkgs.xorg.xrdb}/bin/xrdb -merge
|
|
'';
|
|
windowManager.i3 =
|
|
let
|
|
modifier = "Mod4";
|
|
powerManagementMode = " : Screen [l]ock, [e]xit, [s]uspend, [h]ibernate, [R]eboot, [S]hutdown";
|
|
miscellaneousMode = "D [p]ause, D [c]ontinue";
|
|
resizeMode = " : [h] , [j] , [k] , [l] ";
|
|
light = lib.getExe' pkgs.brightnessctl "brightnessctl";
|
|
pactl = lib.getExe' pkgs.pulseaudio "pactl";
|
|
maim = lib.getExe' pkgs.maim "maim";
|
|
clipboard = lib.getExe' pkgs.xclip "xclip";
|
|
yazi = lib.getExe' pkgs.yazi "yazi";
|
|
terminal = lib.getExe' inputs.ghostty.packages."${system}".default "ghostty";
|
|
# terminal = lib.getExe' pkgs.kitty "kitty";
|
|
# second_terminal = lib.getExe' pkgs.wezterm "wezterm";
|
|
playerctl = lib.getExe' pkgs.playerctl "playerctl";
|
|
dmenu = lib.getExe' pkgs.dmenu "dmenu_run";
|
|
refresh_i3status = "killall -SIGUSR1 i3status";
|
|
boomer = lib.getExe' pkgs.custom.boomer "boomer";
|
|
# config = pkgs.substituteAll {
|
|
# inherit term second_term;
|
|
# src = ./config;
|
|
# raise_vol = "${pactl} set-sink-volume @DEFAULT_SINK@ +1% && $refresh_i3status";
|
|
# lower_vol = "${pactl} set-sink-volume @DEFAULT_SINK@ -1% && $refresh_i3status";
|
|
# mute_vol = "${pactl} set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status";
|
|
# mute_mic = "${pactl} set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status";
|
|
# screenshot = "${maim} -s ~/Pictures/screenshots/$(date +%Y-%m-%d-%H-%M-%S).png";
|
|
# screenshot_clipboard = "${maim} -s | ${clipboard} -selection clipboard -t image/png";
|
|
# media_play = "${playerctl} play-pause";
|
|
# media_pause = "${playerctl} play-pause";
|
|
# media_next = "${playerctl} next";
|
|
# media_prev = "${playerctl} previous";
|
|
# fm = "${term} -e ${fm}";
|
|
# startup = ''
|
|
# exec --no-startup-id ${pkgs.dex}/bin/dex --autostart --environment i3
|
|
# exec --no-startup-id ${pkgs.networkmanagerapplet}/bin/nm-applet
|
|
# exec --no-startup-id ${pkgs.pasystray}/bin/pasystray
|
|
# exec --no-startup-id ${pkgs.xss-lock}/bin/xss-lock --transfer-sleep-lock -- i3lock --nofork
|
|
# '';
|
|
# };
|
|
in
|
|
{
|
|
enable = true;
|
|
config = {
|
|
inherit modifier terminal;
|
|
keybindings = lib.mkOptionDefault {
|
|
"${modifier}+h" = "focus left";
|
|
"${modifier}+j" = "focus down";
|
|
"${modifier}+k" = "focus up";
|
|
"${modifier}+l" = "focus right";
|
|
"${modifier}+Shift+h" = "move left";
|
|
"${modifier}+Shift+j" = "move down";
|
|
"${modifier}+Shift+k" = "move up";
|
|
"${modifier}+Shift+l" = "move right";
|
|
"${modifier}+v" = "split h";
|
|
"${modifier}+Shift+v" = "split v";
|
|
"${modifier}+s" = "layout stacking";
|
|
"${modifier}+t" = "layout tabbed";
|
|
"${modifier}+e" = "layout toggle split";
|
|
"${modifier}+p" = "floating toggle";
|
|
"${modifier}+Shift+p" = "focus mode_toggle";
|
|
"${modifier}+Shift+c" = "reload";
|
|
"${modifier}+Shift+r" = "restart";
|
|
# mode
|
|
"${modifier}+r" = ''mode "${resizeMode}"'';
|
|
"${modifier}+Escape" = ''mode "${powerManagementMode}"'';
|
|
"${modifier}+Shift+Escape" = ''mode "${miscellaneousMode}"'';
|
|
# workspace
|
|
# "${modifier}+Shift+minus" = "move scratchpad";
|
|
# "${modifier}+minus" = "scratchpad show";
|
|
# media
|
|
"XF86AudioRaiseVolume" =
|
|
"exec --no-startup-id ${pactl} set-sink-volume @DEFAULT_SINK@ +1% && ${refresh_i3status}";
|
|
"XF86AudioLowerVolume" =
|
|
"exec --no-startup-id ${pactl} set-sink-volume @DEFAULT_SINK@ -1% && ${refresh_i3status}";
|
|
"XF86AudioMute" =
|
|
"exec --no-startup-id ${pactl} set-sink-mute @DEFAULT_SINK@ toggle && ${refresh_i3status}";
|
|
"XF86AudioMicMute" =
|
|
"exec --no-startup-id ${pactl} set-source-mute @DEFAULT_SOURCE@ toggle && ${refresh_i3status}";
|
|
"XF86AudioPlay" = "exec --no-startup-id ${playerctl} play-pause";
|
|
"XF86AudioPause" = "exec --no-startup-id ${playerctl} play-pause";
|
|
"XF86AudioNext" = "exec --no-startup-id ${playerctl} next";
|
|
"XF86AudioPrev" = "exec --no-startup-id ${playerctl} previous";
|
|
# brightness
|
|
"XF86MonBrightnessUp" = "exec --no-startup-id ${light} s +10%";
|
|
"XF86MonBrightnessDown" = "exec --no-startup-id ${light} s 10%-";
|
|
# screenshot
|
|
"${modifier}+o" =
|
|
"exec --no-startup-id ${maim} -s ~/Pictures/screenshots/$(date +%Y-%m-%d-%H-%M-%S).png";
|
|
"${modifier}+Shift+o" =
|
|
"exec --no-startup-id ${maim} -s | ${clipboard} -selection clipboard -t image/png";
|
|
# others
|
|
"${modifier}+space" = "exec --no-startup-id ${dmenu}";
|
|
"${modifier}+b" = "exec --no-startup-id ${terminal} -e ${yazi}";
|
|
"${modifier}+z" = "exec --no-startup-id ${boomer}"; # tsoding's zoom
|
|
# "${modifier}+Shift+Return" = "exec ${second_terminal}";
|
|
# reset
|
|
"${modifier}+Shift+e" = null;
|
|
"${modifier}+w" = null;
|
|
"${modifier}+d" = null;
|
|
};
|
|
modes =
|
|
let
|
|
exitMode = {
|
|
"Escape" = "mode default";
|
|
"Return" = "mode default";
|
|
};
|
|
in
|
|
{
|
|
"${resizeMode}" = {
|
|
"Left" = "resize shrink width 10 px or 10 ppt";
|
|
"Down" = "resize grow height 10 px or 10 ppt";
|
|
"Up" = "resize shrink height 10 px or 10 ppt";
|
|
"Right" = "resize grow width 10 px or 10 ppt";
|
|
"Escape" = "mode default";
|
|
"Return" = "mode default";
|
|
} // exitMode;
|
|
"${powerManagementMode}" = {
|
|
l = "mode default, exec loginctl lock-session";
|
|
e = "mode default, exec loginctl terminate-session $XDG_SESSION_ID";
|
|
s = "mode default, exec systemctl suspend";
|
|
h = "mode default, exec systemctl hibernate";
|
|
"Shift+r" = "mode default, exec systemctl reboot";
|
|
"Shift+s" = "mode default, exec systemctl poweroff";
|
|
} // exitMode;
|
|
"${miscellaneousMode}" = {
|
|
p = "mode default, exec kill -SIGUSR1 $(pidof dunst)";
|
|
c = "mode default, exec kill -SIGUSR2 $(pidof dunst";
|
|
} // exitMode;
|
|
};
|
|
startup = [
|
|
{
|
|
command = "${pkgs.hsetroot}/bin/hsetroot -solid \"#062329\"";
|
|
notification = false;
|
|
}
|
|
{
|
|
command = "${pkgs.dex}/bin/dex --autostart --environment i3";
|
|
notification = false;
|
|
}
|
|
{
|
|
command = "${pkgs.networkmanagerapplet}/bin/nm-applet";
|
|
notification = false;
|
|
}
|
|
{
|
|
command = "${pkgs.pasystray}/bin/pasystray";
|
|
notification = false;
|
|
}
|
|
{
|
|
command = "${pkgs.xss-lock}/bin/xss-lock --transfer-sleep-lock -- i3lock --nofork";
|
|
notification = false;
|
|
}
|
|
{
|
|
command = "${pkgs.autorandr}/bin/autorandr -c";
|
|
always = false; # Important, run only on first start (will loop otherwise)!
|
|
notification = false;
|
|
}
|
|
{
|
|
command = "${pkgs.xfce.xfce4-volumed-pulse}/bin/xfce4-volumed-pulse &";
|
|
always = false;
|
|
notification = false;
|
|
}
|
|
{
|
|
command = "${light} s 25%";
|
|
}
|
|
];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|