Skip to content

Commit

Permalink
feat(sway): add preliminary configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
kmein committed Mar 3, 2024
1 parent f263d5d commit 8c12edf
Showing 1 changed file with 190 additions and 157 deletions.
347 changes: 190 additions & 157 deletions configs/i3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@
'';
};
};

new-workspace = pkgs.writers.writeDash "new-workspace" ''
i3-msg workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
'';
move-to-new-workspace = pkgs.writers.writeDash "new-workspace" ''
i3-msg move container to workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
'';
in {
age.secrets = {
github-token-i3status-rust = {
Expand Down Expand Up @@ -106,169 +99,209 @@ in {
'';
};

home-manager.users.me.xsession.windowManager.i3 = let
home-manager.users.me = let
modifier = "Mod4";
in {
enable = true;
extraConfig = ''
bindsym --release ${modifier}+Shift+w exec /run/wrappers/bin/slock
'';
config = rec {
inherit modifier;
window = {
titlebar = false;
border = 2;
hideEdgeBorders = "smart";
commands = [
{
criteria = {class = "floating";};
command = "floating enable";
}
{
criteria = {class = "fzfmenu";};
command = "floating enable";
}
{
criteria = {class = ".*";};
command = "border pixel 2";
}
{
criteria = {class = "mpv";};
command = lib.strings.concatStringsSep ", " [
"floating enable"
"sticky enable"
"fullscreen disable"
"resize set 640 480"
"move position mouse"
];
}
];
};
gaps.inner = 4;
floating = {
titlebar = false;
border = 1;
};
bars = [
(config.home-manager.users.me.lib.stylix.i3.bar
// rec {
workspaceButtons = false;
mode = "dock"; # "hide";
position = "bottom";
statusCommand = toString (pkgs.writers.writeDash "i3status-rust" ''
export I3RS_GITHUB_TOKEN="$(cat ${config.age.secrets.github-token-i3status-rust.path})"
export OPENWEATHERMAP_API_KEY="$(cat ${config.age.secrets.openweathermap-api-key.path})"
${config.home-manager.users.me.programs.i3status-rust.package}/bin/i3status-rs ${config.home-manager.users.me.home.homeDirectory}/.config/i3status-rust/config-${position}.toml
'');
fonts = {
names = ["${config.stylix.fonts.sansSerif.name}" "FontAwesome 6 Free"];
size = config.stylix.fonts.sizes.desktop * 0.8;
};
})
modes.resize = {
"Escape" = ''mode "default"'';
"Return" = ''mode "default"'';
"h" = "resize shrink width 10 px or 5 ppt";
"j" = "resize grow height 10 px or 5 ppt";
"k" = "resize shrink height 10 px or 5 ppt";
"l" = "resize grow width 10 px or 5 ppt";
};
gaps.inner = 4;
floating = {
titlebar = false;
border = 1;
};
bars = [
(config.home-manager.users.me.lib.stylix.i3.bar
// rec {
workspaceButtons = false;
mode = "dock"; # "hide";
position = "bottom";
statusCommand = toString (pkgs.writers.writeDash "i3status-rust" ''
export I3RS_GITHUB_TOKEN="$(cat ${config.age.secrets.github-token-i3status-rust.path})"
export OPENWEATHERMAP_API_KEY="$(cat ${config.age.secrets.openweathermap-api-key.path})"
${config.home-manager.users.me.programs.i3status-rust.package}/bin/i3status-rs ${config.home-manager.users.me.home.homeDirectory}/.config/i3status-rust/config-${position}.toml
'');
fonts = {
names = ["${config.stylix.fonts.sansSerif.name}" "FontAwesome 6 Free"];
size = config.stylix.fonts.sizes.desktop * 0.8;
};
})
];
window = {
titlebar = false;
border = 2;
hideEdgeBorders = "smart";
commands = [
{
criteria = {class = "floating";};
command = "floating enable";
}
{
criteria = {class = "fzfmenu";};
command = "floating enable";
}
{
criteria = {class = ".*";};
command = "border pixel 2";
}
{
criteria = {class = "mpv";};
command = lib.strings.concatStringsSep ", " [
"floating enable"
"sticky enable"
"fullscreen disable"
"resize set 640 480"
"move position mouse"
];
}
];
colors = let
background = config.lib.stylix.colors.withHashtag.base00;
in {
unfocused = {
border = lib.mkForce background;
childBorder = lib.mkForce background;
};
};
modes.resize = {
"Escape" = ''mode "default"'';
"Return" = ''mode "default"'';
"h" = "resize shrink width 10 px or 5 ppt";
"j" = "resize grow height 10 px or 5 ppt";
"k" = "resize shrink height 10 px or 5 ppt";
"l" = "resize grow width 10 px or 5 ppt";
};
colors = let
background = config.lib.stylix.colors.withHashtag.base00;
in {
unfocused = {
border = lib.mkForce background;
childBorder = lib.mkForce background;
};
keybindings = {
"${modifier}+Shift+h" = "move left 25 px";
"${modifier}+Shift+j" = "move down 25 px";
"${modifier}+Shift+k" = "move up 25 px";
"${modifier}+Shift+l" = "move right 25 px";
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";

"${modifier}+Shift+b" = "move window to workspace prev";
"${modifier}+Shift+n" = "move window to workspace next";
"${modifier}+Shift+x" = "exec ${move-to-new-workspace}";
"${modifier}+b" = "workspace prev";
"${modifier}+n" = "workspace next";
"${modifier}+x" = "exec ${new-workspace}";
};
keybindings = {
"${modifier}+Shift+h" = "move left 25 px";
"${modifier}+Shift+j" = "move down 25 px";
"${modifier}+Shift+k" = "move up 25 px";
"${modifier}+Shift+l" = "move right 25 px";
"${modifier}+h" = "focus left";
"${modifier}+j" = "focus down";
"${modifier}+k" = "focus up";
"${modifier}+l" = "focus right";

"${modifier}+Shift+c" = "reload";
"${modifier}+Shift+q" = "kill";
"${modifier}+Shift+r" = "restart";
"${modifier}+Shift+b" = "move window to workspace prev";
"${modifier}+Shift+n" = "move window to workspace next";
"${modifier}+b" = "workspace prev";
"${modifier}+n" = "workspace next";

"${modifier}+z" = "sticky toggle";
"${modifier}+Shift+z" = "floating toggle";
"${modifier}+Shift+c" = "reload";
"${modifier}+Shift+q" = "kill";
"${modifier}+Shift+r" = "restart";

"${modifier}+s" = "scratchpad show";
"${modifier}+Shift+s" = "move scratchpad";
"${modifier}+z" = "sticky toggle";
"${modifier}+Shift+z" = "floating toggle";

"${modifier}+c" = "split h";
"${modifier}+e" = "layout toggle split";
"${modifier}+f" = "fullscreen toggle";
"${modifier}+r" = "mode resize";
"${modifier}+v" = "split v";
"${modifier}+w" = "layout tabbed";
"${modifier}+q" = "exec ${config.services.clipmenu.package}/bin/clipmenu";
"${modifier}+s" = "scratchpad show";
"${modifier}+Shift+s" = "move scratchpad";

"${modifier}+Return" = "exec ${(defaultApplications pkgs).terminal}";
"${modifier}+t" = "exec ${(defaultApplications pkgs).fileManager}";
"${modifier}+y" = "exec ${(defaultApplications pkgs).browser}";
"${modifier}+0" = "exec ${niveumPackages.menu-calc}/bin/=";
"${modifier}+c" = "split h";
"${modifier}+e" = "layout toggle split";
"${modifier}+f" = "fullscreen toggle";
"${modifier}+r" = "mode resize";
"${modifier}+v" = "split v";
"${modifier}+w" = "layout tabbed";
"${modifier}+q" = "exec ${config.services.clipmenu.package}/bin/clipmenu";

"${modifier}+d" = "exec ${pkgs.writers.writeDash "run" ''exec rofi -modi run,ssh,window -show run''}";
"${modifier}+Shift+d" = "exec ${niveumPackages.notemenu}/bin/notemenu";
"${modifier}+p" = "exec rofi-pass";
"${modifier}+Shift+p" = "exec rofi-pass --insert";
"${modifier}+u" = "exec ${niveumPackages.unicodmenu}/bin/unicodmenu";
"${modifier}+Return" = "exec ${(defaultApplications pkgs).terminal}";
"${modifier}+t" = "exec ${(defaultApplications pkgs).fileManager}";
"${modifier}+y" = "exec ${(defaultApplications pkgs).browser}";
"${modifier}+0" = "exec ${niveumPackages.menu-calc}/bin/=";

"${modifier}+F6" = "exec ${pkgs.xorg.xkill}/bin/xkill";
"${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" ''
if ${pkgs.procps}/bin/pgrep screenkey; then
exec ${pkgs.procps}/bin/pkill screenkey
else
exec ${pkgs.screenkey}/bin/screenkey
fi
''}";
"${modifier}+F8" = "exec switch-theme toggle";
"${modifier}+F9" = "exec ${pkgs.redshift}/bin/redshift -O 4000 -b 0.85";
"${modifier}+F10" = "exec ${pkgs.redshift}/bin/redshift -x";
"${modifier}+F11" = "exec ${pkgs.xcalib}/bin/xcalib -invert -alter";
"${modifier}+F12" = "exec ${klem}/bin/klem";
"Print" = "exec flameshot gui";
"XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 5";
"XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t";
"XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 5";
"XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc";
"XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next";
"XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous";
"XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop";
"XF86ScreenSaver" = "exec ${niveumPackages.k-lock}/bin/k-lock";
"${modifier}+d" = "exec ${pkgs.writers.writeDash "run" ''exec rofi -modi run,ssh,window -show run''}";
"${modifier}+Shift+d" = "exec ${niveumPackages.notemenu}/bin/notemenu";
"${modifier}+p" = "exec rofi-pass";
"${modifier}+Shift+p" = "exec rofi-pass --insert";
"${modifier}+u" = "exec ${niveumPackages.unicodmenu}/bin/unicodmenu";

"XF86Display" = "exec ${niveumPackages.dmenu-randr}/bin/dmenu-randr";
"${modifier}+F7" = "exec ${pkgs.writers.writeDash "showkeys-toggle" ''
if ${pkgs.procps}/bin/pgrep screenkey; then
exec ${pkgs.procps}/bin/pkill screenkey
else
exec ${pkgs.screenkey}/bin/screenkey
fi
''}";
"${modifier}+F12" = "exec ${klem}/bin/klem";
"XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 5";
"XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t";
"XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 5";
"XF86Calculator" = "exec ${pkgs.st}/bin/st -c floating -e ${pkgs.bc}/bin/bc";
"XF86AudioPause" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next";
"XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous";
"XF86AudioStop" = "exec ${pkgs.playerctl}/bin/playerctl stop";
"XF86ScreenSaver" = "exec ${niveumPackages.k-lock}/bin/k-lock";

# key names detected with xorg.xev:
# XF86WakeUp (fn twice)
# XF86Battery (fn f3)
# XF86Sleep (fn f4) - actually suspends
# XF86WLAN
# XF86WebCam (fn f6)
# XF86TouchpadToggle (fn f8)
# XF86Suspend (fn f12) - actually suspends to disk
# Num_Lock (fn Roll) - numlocks
# XF86Audio{Prev,Next,Mute,Play,Stop}
# XF86Forward
# XF86Back
# XF86Launch1 (thinkvantage)
# key names detected with xorg.xev:
# XF86WakeUp (fn twice)
# XF86Battery (fn f3)
# XF86Sleep (fn f4) - actually suspends
# XF86WLAN
# XF86WebCam (fn f6)
# XF86TouchpadToggle (fn f8)
# XF86Suspend (fn f12) - actually suspends to disk
# Num_Lock (fn Roll) - numlocks
# XF86Audio{Prev,Next,Mute,Play,Stop}
# XF86Forward
# XF86Back
# XF86Launch1 (thinkvantage)
};
in {
wayland.windowManager.sway = {
enable = true;
config = {
menu = "rofi -modi run,ssh,window -show run";
inherit modifier modes gaps bars floating window colors keybindings;
input = {
"*" = {
xkb_layout = "de";
xkb_variant = "T3";
};
};
terminal = (defaultApplications pkgs).terminal;
up = "k";
down = "j";
left = "h";
right = "l";
seat = {
"*" = {
hide_cursor = "when-typing enable";
};
};
startup = [
{command = "echo hello";}
];
};
};

xsession.windowManager.i3 = {
enable = true;
extraConfig = ''
bindsym --release ${modifier}+Shift+w exec /run/wrappers/bin/slock
'';
config = lib.mkMerge [
{
inherit modifier gaps modes bars floating window colors keybindings;
}
{
keybindings = let
new-workspace = pkgs.writers.writeDash "new-workspace" ''
i3-msg workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
'';
move-to-new-workspace = pkgs.writers.writeDash "new-workspace" ''
i3-msg move container to workspace $(($(i3-msg -t get_workspaces | tr , '\n' | grep '"num":' | cut -d : -f 2 | sort -rn | head -1) + 1))
'';
in {
"${modifier}+F6" = "exec ${pkgs.xorg.xkill}/bin/xkill";
"${modifier}+F9" = "exec ${pkgs.redshift}/bin/redshift -O 4000 -b 0.85";
"${modifier}+F10" = "exec ${pkgs.redshift}/bin/redshift -x";
"${modifier}+F11" = "exec ${pkgs.xcalib}/bin/xcalib -invert -alter";
"Print" = "exec flameshot gui";
"${modifier}+Shift+x" = "exec ${move-to-new-workspace}";
"${modifier}+x" = "exec ${new-workspace}";
"XF86Display" = "exec ${niveumPackages.dmenu-randr}/bin/dmenu-randr";
};
}
];
};
};
}

0 comments on commit 8c12edf

Please sign in to comment.