nixos-config/profiles/workspace/sway/default.nix

248 lines
9.0 KiB
Nix
Raw Normal View History

2020-02-17 17:00:59 +04:00
{ pkgs, lib, config, ... }:
let
2021-06-10 19:58:51 +04:00
thm = pkgs.my-lib.thmHash;
2020-02-17 17:00:59 +04:00
apps = config.defaultApplications;
2020-11-09 23:43:06 +04:00
lock_fork =
pkgs.writeShellScript "lock_fork" "sudo /run/current-system/sw/bin/lock &";
lock = pkgs.writeShellScript "lock"
"swaymsg 'output * dpms off'; sudo /run/current-system/sw/bin/lock; swaymsg 'output * dpms on'";
2020-02-17 17:00:59 +04:00
in {
2021-01-21 22:13:53 +04:00
environment.sessionVariables = {
_JAVA_AWT_WM_NONREPARENTING = "1";
XDG_SESSION_TYPE = "wayland";
QT_QPA_PLATFORM = "wayland";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
};
programs.sway.enable = true;
2020-02-17 17:00:59 +04:00
2020-05-13 00:35:29 +04:00
programs.sway.wrapperFeatures.gtk = true;
programs.sway.extraPackages = lib.mkForce (with pkgs; [ swayidle xwayland ]);
2020-06-12 18:34:18 +04:00
2021-01-21 22:13:53 +04:00
users.users.balsoft.extraGroups = [ "sway" ];
environment.loginShellInit = lib.mkAfter ''
[[ "$(tty)" == /dev/tty1 ]] && {
pass unlock
sway
}
'';
2021-06-14 12:09:26 +04:00
home-manager.users.balsoft.wayland.windowManager.sway = {
2020-02-17 17:00:59 +04:00
enable = true;
config = rec {
assigns = {
2020-11-09 23:43:06 +04:00
"" = [
{ class = "Chromium"; }
{ app_id = "firefox"; }
{ class = "Firefox"; }
];
2020-02-17 17:00:59 +04:00
"" = [
2021-06-09 10:46:09 +04:00
{ app_id = "geary"; }
{ title = "nheko"; }
{ title = "Slack.*"; }
2020-02-17 17:00:59 +04:00
];
};
2021-05-10 04:04:18 +04:00
fonts = {
2021-06-10 19:58:51 +04:00
names = [ config.themes.fonts.main.family ];
2021-05-10 04:04:18 +04:00
style = "Regular";
size = 9.0;
};
2020-02-17 17:00:59 +04:00
colors = rec {
2021-06-10 19:58:51 +04:00
background = thm.base00;
2020-02-17 17:00:59 +04:00
unfocused = {
2021-06-10 19:58:51 +04:00
text = thm.base02;
border = thm.base01;
background = thm.base00;
childBorder = thm.base01;
indicator = thm.base07;
2020-02-17 17:00:59 +04:00
};
focusedInactive = unfocused;
urgent = unfocused // {
2021-06-10 19:58:51 +04:00
text = thm.base05;
border = thm.base09;
childBorder = thm.base09;
2020-02-17 17:00:59 +04:00
};
focused = unfocused // {
2021-06-10 19:58:51 +04:00
childBorder = thm.base03;
border = thm.base03;
background = thm.base01;
text = thm.base05;
2020-02-17 17:00:59 +04:00
};
};
gaps = {
inner = 6;
smartGaps = true;
smartBorders = "on";
};
focus.followMouse = false;
2020-05-12 23:38:45 +04:00
focus.forceWrapping = true;
2020-02-17 17:00:59 +04:00
modifier = "Mod4";
window = {
border = 1;
titlebar = true;
commands = [
{
command = "border pixel 2px";
criteria = { window_role = "popup"; };
}
{
command = "sticky enable";
criteria = { floating = ""; };
}
];
};
startup = (map (command: { inherit command; }) config.startupApplications) ++ [
2021-06-09 10:46:09 +04:00
{ command = toString (pkgs.writeShellScript "slack" ''
firefox https://tweag.slack.com &
2021-06-09 10:46:09 +04:00
sleep 10
swaymsg '[title=Slack.*] move to workspace '
swaymsg '[title=Slack.*] fullscreen disable'
''); }
{
2020-11-09 23:43:06 +04:00
command =
"swayidle -w before-sleep '${lock_fork}' lock '${lock_fork}' unlock 'pkill -9 swaylock'";
2020-05-13 00:35:29 +04:00
}
2020-02-17 17:00:59 +04:00
];
keybindings = let
script = name: content: "exec ${pkgs.writeScript name content}";
workspaces = (builtins.genList (x: [ (toString x) (toString x) ]) 10)
++ [ [ "c" "" ] [ "t" "" ] [ "m" "" ] ];
in ({
"${modifier}+q" = "kill";
"${modifier}+Shift+q" = "move container to workspace temp; [workspace=__focused__] kill; workspace temp; move container to workspace temp; workspace temp";
2020-02-17 17:00:59 +04:00
"${modifier}+Return" = "exec ${apps.term.cmd}";
"${modifier}+e" = "exec ${apps.editor.cmd}";
2020-05-25 16:44:06 +04:00
"${modifier}+o" = "layout toggle all";
2020-02-17 17:00:59 +04:00
"${modifier}+Left" = "focus child; focus left";
"${modifier}+Right" = "focus child; focus right";
"${modifier}+Up" = "focus child; focus up";
"${modifier}+Down" = "focus child; focus down";
"${modifier}+Control+Left" = "focus parent; focus left";
"${modifier}+Control+Right" = "focus parent; focus right";
"${modifier}+Control+Up" = "focus parent; focus up";
"${modifier}+Control+Down" = "focus parent; focus down";
2020-02-17 17:00:59 +04:00
"${modifier}+Shift+Up" = "move up";
"${modifier}+Shift+Down" = "move down";
"${modifier}+Shift+Right" = "move right";
"${modifier}+Shift+Left" = "move left";
2020-08-25 11:54:05 +04:00
"${modifier}+Comma" = "workspace prev";
"${modifier}+Period" = "workspace next";
"${modifier}+a" = "focus child; focus left";
"${modifier}+d" = "focus child; focus right";
"${modifier}+w" = "focus child; focus up";
"${modifier}+s" = "focus child; focus down";
"${modifier}+Control+a" = "focus parent; focus left";
"${modifier}+Control+d" = "focus parent; focus right";
"${modifier}+Control+w" = "focus parent; focus up";
"${modifier}+Control+s" = "focus parent; focus down";
2020-02-17 17:00:59 +04:00
"${modifier}+Shift+w" = "move up";
"${modifier}+Shift+s" = "move down";
"${modifier}+Shift+d" = "move right";
"${modifier}+Shift+a" = "move left";
"${modifier}+f" = "fullscreen toggle; floating toggle";
"${modifier}+r" = "mode resize";
"${modifier}+Shift+f" = "floating toggle";
"${modifier}+Escape" = "exec ${apps.monitor.cmd}";
2020-05-25 16:44:06 +04:00
"${modifier}+j" = "exec ${pkgs.playerctl}/bin/playerctl previous";
"${modifier}+k" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"${modifier}+l" = "exec ${pkgs.playerctl}/bin/playerctl next";
2021-04-05 17:14:36 +04:00
"${modifier}+i" = "exec ${pkgs.pavucontrol}/bin/pavucontrol";
2020-05-25 16:44:06 +04:00
2020-02-17 17:00:59 +04:00
"${modifier}+Print" = script "screenshot"
"${pkgs.grim}/bin/grim Pictures/$(date +'%Y-%m-%d+%H:%M:%S').png";
"${modifier}+Control+Print" = script "screenshot-copy"
"${pkgs.grim}/bin/grim - | ${pkgs.wl-clipboard}/bin/wl-copy";
"--release ${modifier}+Shift+Print" = script "screenshot-area" ''
${pkgs.grim}/bin/grim -g "$(${pkgs.slurp}/bin/slurp)" Pictures/$(date +'%Y-%m-%d+%H:%M:%S').png'';
"--release ${modifier}+Control+Shift+Print" =
script "screenshot-area-copy" ''
${pkgs.grim}/bin/grim -g "$(${pkgs.slurp}/bin/slurp)" - | ${pkgs.wl-clipboard}/bin/wl-copy'';
"${modifier}+x" = "focus output right";
"${modifier}+Shift+x" = "move workspace to output right";
2020-02-17 17:00:59 +04:00
"${modifier}+F5" = "reload";
"${modifier}+Shift+F5" = "exit";
"${modifier}+Shift+h" = "layout splith";
"${modifier}+Shift+v" = "layout splitv";
"${modifier}+h" = "split h";
"${modifier}+v" = "split v";
"${modifier}+F1" = "move to scratchpad";
"${modifier}+F2" = "scratchpad show";
"${modifier}+F11" = "output * dpms off";
2020-02-17 17:00:59 +04:00
"${modifier}+F12" = "output * dpms on";
"${modifier}+End" = "exec ${lock}";
2020-02-17 17:00:59 +04:00
"${modifier}+p" = "sticky toggle";
"${modifier}+backslash" =
2020-02-17 17:00:59 +04:00
script "0x0" ''wl-paste | curl -F"file=@-" https://0x0.st | wl-copy'';
"${modifier}+b" = "focus mode_toggle";
2020-05-25 16:44:06 +04:00
"${modifier}+Space" = script "lambda-launcher"
2020-02-17 17:00:59 +04:00
"${pkgs.lambda-launcher}/bin/lambda-launcher";
"XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause";
"XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next";
"XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous";
2020-08-06 12:31:36 +04:00
"XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer -d 2";
"XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer -i 2";
"XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer -t";
2020-11-09 23:43:06 +04:00
"${modifier}+XF86AudioLowerVolume" =
"exec ${pkgs.pamixer}/bin/pamixer -d 1";
"${modifier}+XF86AudioRaiseVolume" =
"exec ${pkgs.pamixer}/bin/pamixer -i 1";
2020-02-17 17:00:59 +04:00
"button2" = "kill";
"--whole-window ${modifier}+button2" = "kill";
} // builtins.listToAttrs (builtins.map (x: {
name = "${modifier}+${builtins.elemAt x 0}";
value = "workspace ${builtins.elemAt x 1}";
}) workspaces) // builtins.listToAttrs (builtins.map (x: {
name = "${modifier}+Shift+${builtins.elemAt x 0}";
value = "move container to workspace ${builtins.elemAt x 1}";
}) workspaces));
2020-11-09 23:43:06 +04:00
keycodebindings = { };
2020-02-17 17:00:59 +04:00
workspaceLayout = "tabbed";
workspaceAutoBackAndForth = true;
2020-05-12 23:38:45 +04:00
input = {
"2:14:ETPS/2_Elantech_Touchpad" = {
tap = "enabled";
natural_scroll = "enabled";
dwt = "enabled";
};
2020-11-09 23:43:06 +04:00
"2:14:ETPS/2_Elantech_TrackPoint" = { pointer_accel = "-0.7"; };
"2:10:TPPS/2_IBM_TrackPoint" = {
pointer_accel = "0.4";
accel_profile = "adaptive";
2020-05-12 23:38:45 +04:00
};
};
output = {
2021-06-10 19:58:51 +04:00
"*".bg = "${thm.base00} solid_color";
2020-06-24 10:39:24 +04:00
} // lib.optionalAttrs (config.device == "AMD-Workstation") {
DP-1.position = "0 400";
2020-11-09 23:43:06 +04:00
HDMI-A-1 = {
transform = "90";
position = "2560 0";
};
2020-11-10 15:24:32 +04:00
} // lib.optionalAttrs (config.device == "X2100-Laptop") {
2020-11-09 23:43:06 +04:00
"Unknown 0x0000 0x00000000".scale = "2";
2020-05-12 23:38:45 +04:00
};
};
2020-11-09 23:43:06 +04:00
wrapperFeatures = { gtk = true; };
2020-02-17 17:00:59 +04:00
extraConfig = ''
default_border pixel 1
mouse_warping container
hide_edge_borders --i3 smart
exec pkill swaynag
'';
};
}