dotfiles/home/apps/i3.nix

479 lines
15 KiB
Nix
Raw Normal View History

{
2023-02-10 07:46:37 +01:00
config,
lib,
flakePath,
pkgs,
swayfx,
2023-02-10 07:46:37 +01:00
...
}: let
inherit (pkgs.stdenv.hostPlatform) isLinux;
2023-02-13 03:00:55 +01:00
fonts = {
2023-03-08 00:30:37 +01:00
names = ["IBM Plex Sans" "Symbols Nerd Font"];
2023-02-13 03:00:55 +01:00
size = 16.0;
};
2023-03-12 14:25:42 +01:00
commonConfig = {wayland ? false}: rec {
modifier = "Mod4";
focus.wrapping = "no";
2023-03-12 21:46:45 +01:00
focus.mouseWarping =
if wayland
then "container"
else true;
2023-03-12 14:25:42 +01:00
startup = [
{
command = "${lib.getExe pkgs.autotiling} -l2";
always = true;
}
{
command = "${lib.getExe pkgs._1password-gui} --silent";
}
2023-03-28 12:59:48 +02:00
{
command = "${pkgs.volnoti}/bin/volnoti";
}
2023-03-12 14:25:42 +01:00
];
workspaceAutoBackAndForth = true;
terminal = "wezterm start --always-new-process";
menu = "";
defaultWorkspace = "$ws1";
2023-03-12 14:25:42 +01:00
keybindings = let
mod = modifier;
modMove = "${mod}+Shift";
modFocus = "${mod}+Ctrl";
hyper = "Mod4+Mod1+Shift+Ctrl";
gopass = lib.getExe pkgs.unstable.gopass;
rofi = lib.getExe config.programs.rofi.package;
thunar = lib.getExe pkgs.xfce.thunar;
xargs = "${lib.getExe pkgs.findutils}/bin/xargs";
xdotool = lib.getExe pkgs.xdotool;
screenshot =
if wayland
then "${lib.getExe pkgs.sway-contrib.grimshot} copy area"
2023-03-28 12:59:48 +02:00
else "${pkgs.flameshot}/bin/flameshot gui";
2023-03-12 14:25:42 +01:00
playerctl = lib.getExe pkgs.playerctl;
wpctl = pkgs.wireplumber + "/bin/wpctl";
2023-03-28 12:59:48 +02:00
volnotify = pkgs.writeShellScript "volnotify" ''
volumeRaw=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | head -n1)
volume=$(echo $volumeRaw | sed 's/Volume: //' | awk '{printf "%.0f\n", $1 * 100}')
if [[ "$volumeRaw" =~ "MUTED" ]]; then
volnoti-show -m
else
volnoti-show $volume
fi
'';
gopassRofi = pkgs.writeShellScript "gopass-rofi" ''
${gopass} ls --flat | \
${rofi} -dmenu -dpi $dpi | \
${xargs} --no-run-if-empty ${gopass} show -o | \
${xdotool} type --clearmodifiers --file -
'';
2023-03-12 14:25:42 +01:00
in {
"${mod}+Shift+b" = "border none";
"${mod}+b" = "border pixel 2";
"${mod}+n" = "border normal";
# reload the configuration file
2023-03-17 03:46:27 +01:00
"${mod}+Shift+r" = "reload";
2023-03-12 14:25:42 +01:00
# kill focused window
"${mod}+Shift+q" = "kill";
# Start Applications
"${mod}+Shift+Return" = "exec ${terminal}";
"${mod}+e" = "exec --no-startup-id ${thunar}";
"${mod}+Ctrl+x" = "exec --no-startup-id ${lib.getExe pkgs.xorg.xkill}";
# TODO: replace xdotool with wayland equivalent
2023-03-28 12:59:48 +02:00
"${hyper}+space" = "exec --no-startup-id ${gopassRofi}";
"${hyper}+p" = "exec --no-startup-id ${screenshot}";
2023-03-12 14:25:42 +01:00
# change focus
"${modFocus}+h" = "focus left";
"${modFocus}+j" = "focus down";
"${modFocus}+k" = "focus up";
"${modFocus}+l" = "focus right";
"${modFocus}+Left" = "focus left";
"${modFocus}+Down" = "focus down";
"${modFocus}+Up" = "focus up";
"${modFocus}+Right" = "focus right";
# move focus
"${modMove}+h" = "move left";
"${modMove}+j" = "move down";
"${modMove}+k" = "move up";
"${modMove}+l" = "move right";
"${modMove}+Left" = "move left";
"${modMove}+Down" = "move down";
"${modMove}+Up" = "move up";
"${modMove}+Right" = "move right";
# move workspaces across monitors
"${modMove}+greater" = "move workspace to output right";
"${modMove}+less" = "move workspace to output left";
# split orientation
"${mod}+q" = "split toggle";
# toggle fullscreen mode for the focused container
"${mod}+f" = "fullscreen toggle";
# change container layout (stacked, tabbed, toggle split)
"${mod}+s" = "layout toggle";
# toggle tiling / floating
"${mod}+Shift+d" = "floating toggle";
# change focus between tiling / floating windows
"${mod}+d" = "focus mode_toggle";
# toggle sticky
"${mod}+Shift+s" = "sticky toggle";
# focus the parent container
"${mod}+a" = "focus parent";
# move the currently focused window to the scratchpad
"${mod}+Shift+Tab" = "move scratchpad";
# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
"${mod}+Tab" = "scratchpad show";
"${mod}+m" = "[class=\"discord\"] scratchpad show";
# switch to workspace
"${modFocus}+1" = "workspace $ws1";
"${modFocus}+2" = "workspace $ws2";
"${modFocus}+3" = "workspace $ws3";
"${modFocus}+4" = "workspace $ws4";
"${modFocus}+5" = "workspace $ws5";
"${modFocus}+6" = "workspace $ws6";
"${modFocus}+7" = "workspace $ws7";
"${modFocus}+8" = "workspace $ws8";
"${modFocus}+9" = "workspace $ws9";
"${modFocus}+0" = "workspace $ws10";
# Move to workspace with focused container
"${modMove}+1" = "move container to workspace $ws1; workspace $ws1";
"${modMove}+2" = "move container to workspace $ws2; workspace $ws2";
"${modMove}+3" = "move container to workspace $ws3; workspace $ws3";
"${modMove}+4" = "move container to workspace $ws4; workspace $ws4";
"${modMove}+5" = "move container to workspace $ws5; workspace $ws5";
"${modMove}+6" = "move container to workspace $ws6; workspace $ws6";
"${modMove}+7" = "move container to workspace $ws7; workspace $ws7";
"${modMove}+8" = "move container to workspace $ws8; workspace $ws8";
"${modMove}+9" = "move container to workspace $ws9; workspace $ws9";
"${modMove}+0" = "move container to workspace $ws10; workspace $ws10";
# rofi instead of drun
"${mod}+space" = "exec --no-startup-id ${rofi} -show drun -dpi $dpi";
# 1password
"${mod}+Shift+space" = "exec ${lib.getExe pkgs._1password-gui} --quick-access";
# audio
2023-03-28 12:59:48 +02:00
"XF86AudioRaiseVolume" = "exec --no-startup-id ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 5%+ -l 1.0 && ${volnotify}";
"XF86AudioLowerVolume" = "exec --no-startup-id ${wpctl} set-volume @DEFAULT_AUDIO_SINK@ 5%- -l 1.0 && ${volnotify}";
"XF86AudioMute" = "exec --no-startup-id ${wpctl} set-mute @DEFAULT_AUDIO_SINK@ toggle && ${volnotify}";
2023-03-12 14:25:42 +01:00
"XF86AudioNext" = "exec --no-startup-id ${playerctl} next";
"XF86AudioPrev" = "exec --no-startup-id ${playerctl} previous";
"XF86AudioPause" = "exec --no-startup-id ${playerctl} play-pause";
# modes
"${mod}+r" = "mode \"resize\"";
"${mod}+p" = "mode \"power: (l)ock, (e)xit, (r)eboot, (s)uspend, (h)ibernate, (S)hut off\"";
2023-03-12 14:25:42 +01:00
};
modes = {
"power: (l)ock, (e)xit, (r)eboot, (s)uspend, (h)ibernate, (S)hut off" = let
lock =
if wayland
then "swaylock"
else "i3lock";
msg =
if wayland
then "swaymsg"
else "i3-msg";
in {
l = "exec --no-startup-id ${lock} --color 000000, mode \"default\"";
e = "exec --no-startup-id ${msg} exit, mode \"default\"";
r = "exec --no-startup-id systemctl reboot, mode \"default\"";
s = "exec --no-startup-id systemctl suspend, mode \"default\"";
h = "exec --no-startup-id systemctl hibernate, mode \"default\"";
"Shift+s" = "exec --no-startup-id systemctl poweroff, mode \"default\"";
2023-03-12 14:25:42 +01:00
Escape = "mode default";
Return = "mode default";
};
resize = {
Escape = "mode default";
Return = "mode default";
h = "resize shrink width 10 px or 10 ppt";
j = "resize grow height 10 px or 10 ppt";
k = "resize shrink height 10 px or 10 ppt";
l = "resize grow width 10 px or 10 ppt";
R = "resize set 50 ppt 50 ppt";
};
};
inherit fonts;
bars = [
{
mode = "hide";
# use waybar if wayland
command = lib.mkIf wayland "${lib.getExe config.programs.waybar.package}";
position = "top";
workspaceNumbers = false;
inherit fonts;
colors = {
background = "#000000";
focusedWorkspace = {
background = "#F5C2E7";
text = "#000000";
border = "#F5C2E7";
};
activeWorkspace = {
background = "#CBA6F7";
text = "#000000";
border = "#CBA6F7";
};
inactiveWorkspace = {
background = "#000000";
text = "#CDD6F4";
border = "#000000";
};
};
}
];
colors = rec {
2023-03-12 14:25:42 +01:00
focused = {
background = "#000000";
border = "#F5C2E7";
childBorder = "#F5C2E7";
text = "#CDD6F4";
indicator = "#F5C2E7";
};
urgent = {
background = "#000000";
border = "#F38BA8";
childBorder = "#F38BA8";
text = "#CDD6F4";
indicator = "#F38BA8";
};
unfocused = {
background = "#000000";
border = "#CBA6F7";
childBorder = "#CBA6F7";
text = "#CDD6F4";
indicator = "#CBA6F7";
};
2023-03-12 14:25:42 +01:00
focusedInactive = unfocused;
placeholder = unfocused;
};
window = {
titlebar = false;
hideEdgeBorders = "none";
border = 2;
};
gaps = {
inner = 5;
outer = 2;
2023-03-12 14:25:42 +01:00
};
};
commonExtraConfig = ''
title_align center
set $ws1 1:
set $ws2 2:
set $ws3 3:
set $ws4 4:
set $ws5 5:
set $ws6 6:
set $ws7 7:
set $ws8 8:
set $ws9 9:
set $ws10 10:
# floating sticky
for_window [class="1Password"] floating enable sticky enable border pixel 1
for_window [window_role="PictureInPicture"] floating enable sticky enable border pixel 1
# floating
for_window [class="GParted"] floating enable
for_window [title="(?i)SteamTinkerLaunch"] floating enable
for_window [title="Blender Render"] floating enable
# general WM role settings
for_window [title="splash"] floating enable
for_window [urgent=latest] focus
for_window [window_role="pop-up"] floating enable
for_window [window_role="task_dialog"] floating enable
# apps
for_window [class="Pavucontrol"] floating enable
for_window [class="Yad" title="Authentication"] floating enable
for_window [class="jetbrains*" title="Welcome*"] floating enable
for_window [title="File Transfer*"] floating enable
for_window [title="Steam Guard*"] floating enable
# keep apps in scratchpad
for_window [class="discord"] move scratchpad sticky
set $mode_gaps Gaps: (o)uter, (i)nner
set $mode_gaps_outer Outer Gaps: +|-|0 (local), Shift + +|-|0 (global)
set $mode_gaps_inner Inner Gaps: +|-|0 (local), Shift + +|-|0 (global)
bindsym ${(commonConfig {}).modifier}+Shift+g mode "$mode_gaps"
mode "$mode_gaps" {
bindsym o mode "$mode_gaps_outer"
bindsym i mode "$mode_gaps_inner"
bindsym Return mode "$mode_gaps"
bindsym Escape mode "default"
}
mode "$mode_gaps_outer" {
bindsym plus gaps outer current plus 5
bindsym minus gaps outer current minus 5
bindsym 0 gaps outer current set 0
bindsym Shift+plus gaps outer all plus 5
bindsym Shift+minus gaps outer all minus 5
bindsym Shift+0 gaps outer all set 0
bindsym Return mode "$mode_gaps"
bindsym Escape mode "default"
}
mode "$mode_gaps_inner" {
bindsym plus gaps inner current plus 5
bindsym minus gaps inner current minus 5
bindsym 0 gaps inner current set 0
bindsym Shift+plus gaps inner all plus 5
bindsym Shift+minus gaps inner all minus 5
bindsym Shift+0 gaps inner all set 0
bindsym Return mode "$mode_gaps"
bindsym Escape mode "default"
}
2023-03-12 14:25:42 +01:00
'';
2023-02-10 07:46:37 +01:00
in {
2023-02-13 03:00:55 +01:00
fonts.fontconfig.enable = true;
home = lib.mkIf isLinux {
packages = with pkgs; [
2023-02-12 08:05:51 +01:00
arandr
blueberry
2023-03-28 12:59:48 +02:00
flameshot
pavucontrol
2023-03-28 12:59:48 +02:00
sway-contrib.grimshot
volnoti
2023-02-12 16:35:19 +01:00
xclip
];
};
services = lib.mkIf isLinux {
2023-04-01 23:52:51 +02:00
darkman = {
enable = true;
config = {
lat = 48.210033;
lng = 16.363449;
useGeoclue = false;
};
};
dunst.enable = true;
gnome-keyring = {
enable = true;
2023-02-10 07:46:37 +01:00
components = ["secrets"];
};
picom = {
2023-03-28 12:59:48 +02:00
enable = false;
2023-02-13 03:00:55 +01:00
package = pkgs.nur.repos.nekowinston.picom-ft-labs;
fade = false;
backend = "glx";
vSync = true;
shadow = true;
settings = {
animations = true;
animation-exclude = [
"window_type = 'dock'"
"window_type = 'desktop'"
];
animation-for-open-window = "zoom";
animation-for-unmap-window = "zoom";
animation-for-prev-tag = "zoom";
animation-for-next-tag = "zoom";
enable-fading-prev-tag = true;
enable-fading-next-tag = true;
blur.method = "dual_kawase";
blur-background-exclude = [
"window_type = 'dock'"
"window_type = 'desktop'"
"_NET_WM_NAME@:s *?= 'Discover Voice'"
"_NET_WM_NAME@:s *?= 'Discover Text'"
];
};
};
screen-locker = {
2023-03-28 12:59:48 +02:00
enable = false;
inactiveInterval = 5;
lockCmd = "${lib.getExe pkgs.i3lock} -n -c 000000";
};
udiskie.enable = true;
};
# https://github.com/nix-community/home-manager/issues/2064
2023-02-13 03:00:55 +01:00
systemd = lib.mkIf isLinux {
user.targets.tray.Unit = {
Description = "Home Manager System Tray";
Requires = ["graphical-session-pre.target"];
};
};
2023-02-12 16:35:19 +01:00
xsession = lib.mkIf isLinux {
enable = true;
2023-02-19 02:33:38 +01:00
profilePath = "${config.xdg.configHome}/profile";
scriptPath = "${config.xdg.cacheHome}/X11/xsession";
2023-02-12 16:35:19 +01:00
windowManager.i3 = {
enable = true;
2023-03-12 14:25:42 +01:00
package = pkgs.unstable.i3;
2023-03-28 12:59:48 +02:00
config =
commonConfig {wayland = false;}
// {
startup = [
{
command = "${lib.getExe pkgs.flameshot}";
}
];
};
2023-03-12 14:25:42 +01:00
extraConfig = ''
set_from_resource $dpi Xft.dpi 140
${commonExtraConfig}
'';
};
};
2023-02-12 16:35:19 +01:00
wayland.windowManager.sway = lib.mkIf isLinux {
2023-03-12 14:25:42 +01:00
enable = true;
package = swayfx;
2023-03-12 14:25:42 +01:00
config =
commonConfig {wayland = true;}
// {
2023-03-26 00:49:05 +01:00
input."type:keyboard" = {
xkb_options = "ctrl:nocaps";
};
2023-03-28 12:59:48 +02:00
output = {
"*" = {
scale = "2";
bg = "${flakePath}/home/wallpapers/dhm_1610.png fill #171320";
};
};
2023-03-12 14:25:42 +01:00
startup = [
2023-02-12 16:35:19 +01:00
{
2023-03-28 12:59:48 +02:00
command = "wl-paste -t text --watch clipman store";
2023-02-12 16:35:19 +01:00
}
];
};
extraConfig = ''
${commonExtraConfig}
2023-03-17 03:46:27 +01:00
shadows on
shadow_color #00000099
shadow_blur_radius 10
corner_radius 5
smart_corner_radius on
'';
2023-03-12 14:25:42 +01:00
systemdIntegration = true;
wrapperFeatures = {
base = true;
gtk = true;
};
};
}