1
1
Fork 0

sway: disable and modify config

Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
Myned 2024-11-08 11:41:09 -06:00
parent a94d463cc4
commit 31ea9ec987
Signed by: myned
GPG key ID: C7224454F7881A34
8 changed files with 178 additions and 249 deletions

View file

@ -75,7 +75,7 @@
};
### Sway
#// sway = unstable.swayfx;
sway = unstable.swayfx;
### Development
#// ciscoPacketTracer8 = local.ciscoPacketTracer8;

View file

@ -5,7 +5,9 @@
}:
with lib; {
config.custom.desktops = mkIf config.custom.full {
#// gnome.enable = true;
hyprland.enable = true;
sway.enable = true;
#// kde.enable = true;
#// sway.enable = true;
};
}

View file

@ -73,9 +73,9 @@ in {
keybindings = let
# Keyboard modifiers
super = cfg.modifier;
ctrl = "Control";
shift = "Shift";
alt = "Mod1";
ctrl = "control";
shift = "shift";
alt = "mod1";
# Mouse bindings
left = "button1";
@ -97,9 +97,8 @@ in {
})
keys;
in
# Repeat keybindings
# Repeat binds
{
### Media
# https://github.com/xkbcommon/libxkbcommon/blob/master/include/xkbcommon/xkbcommon-keysyms.h
XF86AudioMute = "exec ${swayosd-client} --output-volume mute-toggle";
XF86AudioLowerVolume = "exec ${swayosd-client} --output-volume lower";
@ -113,165 +112,126 @@ in {
# TODO: Unused media key
#// XF86AudioMedia = "exec null";
}
# Press keybindings
# Press binds
// flags "--no-repeat"
{
# TODO: Toggle left handed trackball
### Scripts
"${super}+delete" = "exec inhibit";
"${super}+${shift}+delete" = "exec vrr";
"${super}+minus" = "exec audio Flat";
"${super}+equal" = "exec audio Normalizer";
"${super}+${shift}+${ctrl}+q" = "exec close";
### Messages
"${ctrl}+delete" = "reload";
"${ctrl}+${alt}+delete" = "exec ${loginctl} terminate-user ''";
# Windows
"${super}+q" = "kill";
"${super}+${shift}+q" = "exec ${kill} -9 $(${swaymsg} -t get_tree | ${jq} '.. | select(.focused?==true).pid')";
"${super}+grave" = "sticky toggle";
"${super}+return" = "fullscreen toggle";
"${super}+tab" = "focus next";
"${super}+${shift}+tab" = "focus prev";
# Containers
"${super}+up" = "move up";
"${super}+down" = "move down";
"${super}+left" = "move left";
"${super}+right" = "move right";
"${super}+backslash" = "split toggle";
"${super}+${shift}+backslash" = "split none";
"${super}+backspace" = "focus mode_toggle";
"${super}+${shift}+backspace" = "floating toggle";
"${super}+bracketleft" = "layout toggle tabbed stacking";
"${super}+bracketright" = "layout toggle split";
"${super}+escape" = "focus parent";
"${super}+${shift}+escape" = "focus child";
# Workspaces
"${super}+1" = "workspace 1";
"${super}+${shift}+1" = "move to workspace 1";
"${super}+2" = "workspace 2";
"${super}+${shift}+2" = "move to workspace 2";
"${super}+3" = "workspace 3";
"${super}+${shift}+3" = "move to workspace 3";
"${super}+4" = "workspace 4";
"${super}+${shift}+4" = "move to workspace 4";
"${super}+5" = "workspace 5";
"${super}+${shift}+5" = "move to workspace 5";
"${super}+6" = "workspace 6";
"${super}+${shift}+6" = "move to workspace 6";
"${super}+7" = "workspace 7";
"${super}+${shift}+7" = "move to workspace 7";
"${super}+8" = "workspace 8";
"${super}+${shift}+8" = "move to workspace 8";
"${super}+9" = "workspace 9";
"${super}+${shift}+9" = "move to workspace 9";
"${super}+0" = "workspace 10";
"${super}+${shift}+0" = "move to workspace 0";
"${super}+g" = "workspace game";
"${super}+${shift}+g" = "move to workspace game";
"${super}+${ctrl}+g" = "workspace gamescope";
"${super}+z" = "exec workspace prev";
"${super}+${shift}+z" = "move to workspace prev";
"${super}+x" = "exec workspace next";
"${super}+${shift}+x" = "move to workspace next";
# Scratchpads
"${super}+a" = "[con_mark=android] scratchpad show";
"${super}+s" = "[con_mark=steam] scratchpad show";
"${super}+w" = "[con_mark=vm] scratchpad show";
"${super}+space" = "scratchpad show";
"${super}+${shift}+space" = "move to scratchpad";
"${super}+${middle}" = "move window to scratchpad";
"${super}+${shift}+${middle}" = "move container to scratchpad";
"${ctrl}+space" = "exec scratchpad dropdown ${foot} --app-id dropdown";
### Commands
# Clipboard
"${super}+v" = "exec clipboard";
"${super}+${shift}+v" = "exec ${cliphist} wipe && ${notify-send} cliphist 'Clipboard cleared' --urgency low";
# Color picker
"${super}+p" = "exec {hyprpicker} --autocopy";
"${super}+${shift}+p" = "exec {hyprpicker} --autocopy --format rgb";
# Screenshot
print = "exec {grimblast} --freeze copysave area \"$XDG_SCREENSHOTS_DIR/$(date +'%F %H.%M.%S')\"";
"${super}+print" = "exec {grimblast} --freeze save area - | ${satty} --filename -";
"${shift}+print" = "exec {grimblast} --freeze copysave output \"$XDG_SCREENSHOTS_DIR/$(date +'%F %H.%M.%S')\"";
"${super}+${shift}+print" = "exec {grimblast} --freeze save output - | ${satty} --filename -";
# Smart home
"${super}+${alt}+escape" = "exec lifx state --color red";
"${super}+${alt}+1" = "exec lifx state --kelvin 1500";
"${super}+${alt}+2" = "exec lifx state --kelvin 2500";
"${super}+${alt}+3" = "exec lifx state --kelvin 3000";
"${super}+${alt}+4" = "exec lifx state --kelvin 4000";
"${super}+${alt}+5" = "exec lifx state --kelvin 5000";
"${ctrl}+${alt}+space" = "exec lifx toggle";
"${ctrl}+${alt}+1" = "exec lifx state --brightness 0.01";
"${ctrl}+${alt}+2" = "exec lifx state --brightness 0.25";
"${ctrl}+${alt}+3" = "exec lifx state --brightness 0.50";
"${ctrl}+${alt}+4" = "exec lifx state --brightness 0.75";
"${ctrl}+${alt}+5" = "exec lifx state --brightness 1.00";
### Applications
"${super}+b" = "exec ${firefox-esr}";
"${super}+c" = "exec ${codium}";
"${super}+e" = "exec ${gnome-text-editor}";
"${super}+f" = "exec ${nautilus}";
"${super}+k" = "exec ${obsidian}";
# "${super}+t" = "workspace terminal; exec launch terminal ${foot} --app-id terminal";
"${super}+t" = "workspace terminal; exec ${kitty}";
"${super}+${shift}+t" = "exec ${foot}";
# Kill applications
"${super}+${shift}+a" = "exec ${waydroid} session stop";
"${super}+${shift}+s" = "exec ${pkill} steam";
"${super}+${ctrl}+${shift}+g" = "exec ${pkill} gamescope";
# Remote desktop
# https://forum.level1techs.com/t/how-to-seamlessly-run-windows-10-apps-in-a-vm-in-linux/170417
"${super}+${shift}+w" = "exec vm ${wlfreerdp} /cert:ignore /u:Myned /p:password /v:myndows /dynamic-resolution +gfx-progressive -grab-keyboard";
"${super}+${ctrl}+${shift}+w" = "exec vm ${xfreerdp} /cert:ignore /u:Myned /p:password /app:explorer.exe /v:myndows +gfx-progressive -grab-keyboard";
"${middle}+${super}" = "move window to scratchpad";
"${middle}+${super}+${shift}" = "move container to scratchpad";
"1+${ctrl}+${alt}" = "exec lifx state --brightness 0.01";
"1+${super}" = "workspace 1";
"1+${super}+${alt}" = "exec lifx state --kelvin 1500";
"1+${super}+${shift}" = "move to workspace 1";
"2+${ctrl}+${alt}" = "exec lifx state --brightness 0.25";
"2+${super}" = "workspace 2";
"2+${super}+${alt}" = "exec lifx state --kelvin 2500";
"2+${super}+${shift}" = "move to workspace 2";
"3+${ctrl}+${alt}" = "exec lifx state --brightness 0.50";
"3+${super}" = "workspace 3";
"3+${super}+${alt}" = "exec lifx state --kelvin 3000";
"3+${super}+${shift}" = "move to workspace 3";
"4+${ctrl}+${alt}" = "exec lifx state --brightness 0.75";
"4+${super}" = "workspace 4";
"4+${super}+${alt}" = "exec lifx state --kelvin 4000";
"4+${super}+${shift}" = "move to workspace 4";
"5+${ctrl}+${alt}" = "exec lifx state --brightness 1.00";
"5+${super}" = "workspace 5";
"5+${super}+${alt}" = "exec lifx state --kelvin 5000";
"5+${super}+${shift}" = "move to workspace 5";
"6+${super}" = "workspace 6";
"6+${super}+${shift}" = "move to workspace 6";
"7+${super}" = "workspace 7";
"7+${super}+${shift}" = "move to workspace 7";
"8+${super}" = "workspace 8";
"8+${super}+${shift}" = "move to workspace 8";
"9+${super}" = "workspace 9";
"9+${super}+${shift}" = "move to workspace 9";
"a+${super}" = "[con_mark=android] scratchpad show";
"a+${super}+${shift}" = "exec ${waydroid} session stop";
"b+${super}" = "exec ${firefox-esr}";
"backslash+${super}" = "split toggle";
"backslash+${super}+${shift}" = "split none";
"backspace+${super}" = "focus mode_toggle";
"backspace+${super}+${shift}" = "floating toggle";
"bracketleft+${super}" = "layout toggle tabbed stacking";
"bracketright+${super}" = "layout toggle split";
"c+${super}" = "exec ${codium}";
"delete+${super}" = "exec inhibit";
"delete+${super}+${shift}" = "exec vrr";
"down+${super}" = "move down";
"e+${super}" = "exec ${gnome-text-editor}";
"equal+${super}" = "exec audio Normalizer";
"escape+${super}" = "focus parent";
"escape+${super}+${alt}" = "exec lifx state --color red";
"escape+${super}+${shift}" = "focus child";
"f+${super}" = "exec ${nautilus}";
"g+${super}" = "workspace game";
"g+${super}+${ctrl}" = "workspace gamescope";
"g+${super}+${ctrl}+${shift}" = "exec ${pkill} gamescope";
"g+${super}+${shift}" = "move to workspace game";
"grave+${super}" = "sticky toggle";
"k+${super}" = "exec ${obsidian}";
"left+${super}" = "move left";
"minus+${super}" = "exec audio Flat";
"p+${super}" = "exec ${hyprpicker} --autocopy";
"p+${super}+${shift}" = "exec ${hyprpicker} --autocopy --format rgb";
"print+${shift}" = "exec {grimblast} --freeze copysave output \"$XDG_SCREENSHOTS_DIR/$(date +'%F %H.%M.%S')\"";
"q+${super}" = "kill";
"q+${super}+${shift}" = "exec ${kill} -9 $(${swaymsg} -t get_tree | ${jq} '.. | select(.focused?==true).pid')";
"q+${super}+${shift}+${ctrl}" = "exec close";
"return+${super}" = "fullscreen toggle";
"right+${super}" = "move right";
"s+${super}" = "[con_mark=steam] scratchpad show";
"s+${super}+${shift}" = "exec ${pkill} steam";
"space+${ctrl}" = "exec scratchpad dropdown ${kitty} --app-id dropdown";
"space+${ctrl}+${alt}" = "exec lifx toggle";
"space+${super}" = "scratchpad show";
"space+${super}+${shift}" = "move to scratchpad";
"t+${super}" = "workspace terminal; exec ${kitty} --app-id terminal";
"t+${super}+${shift}" = "exec ${kitty}";
"tab+${super}" = "focus next";
"tab+${super}+${shift}" = "focus prev";
"up+${super}" = "move up";
"v+${super}" = "exec clipboard";
"v+${super}+${shift}" = "exec ${cliphist} wipe && ${notify-send} cliphist 'Clipboard cleared' --urgency low";
"w+${super}" = "[con_mark=vm] scratchpad show";
"w+${super}+${ctrl}+${shift}" = "exec vm ${xfreerdp} /cert:ignore /u:Myned /p:password /app:explorer.exe /v:myndows +gfx-progressive -grab-keyboard";
"w+${super}+${shift}" = "exec vm ${wlfreerdp} /cert:ignore /u:Myned /p:password /v:myndows /dynamic-resolution +gfx-progressive -grab-keyboard";
"x+${super}" = "exec workspace next";
"x+${super}+${shift}" = "move to workspace next";
"z+${super}" = "exec workspace prev";
"z+${super}+${shift}" = "move to workspace prev";
}
# Release keybindings
# Release binds
// flags "--no-repeat --release"
{
# Menus
super_l = "exec ${pkill} wofi || ${wofi} --show drun";
"${ctrl}+super_l" = "exec ${pkill} wofi || calc";
"${shift}+super_l" = "exec ${pkill} wofi || ${wofi} --show run";
"${alt}+super_l" = "exec ${pkill} wofi || ${rofi-rbw}";
"${ctrl}+${shift}+super_l" = "exec ${pkill} || ${networkmanager_dmenu}";
# Workspaces
"${super}+control_l" = "workspace music";
"${super}+shift_l" = "workspace back_and_forth";
"${super}+alt_l" = "workspace wallpaper";
# Scratchpad
"${super}+${shift}+control_l" = "exec hide Picture-in-Picture special:pip";
"alt_l+${super}" = "workspace wallpaper";
"control_l+${super}" = "workspace music";
"control_l+${super}+${shift}" = "exec hide Picture-in-Picture special:pip";
"shift_l+${super}" = "workspace back_and_forth";
"super_l" = "exec ${pkill} wofi || ${wofi} --show drun";
"super_l+${alt}" = "exec ${pkill} wofi || ${rofi-rbw}";
"super_l+${ctrl}" = "exec ${pkill} wofi || calc";
"super_l+${ctrl}+${shift}" = "exec ${pkill} || ${networkmanager_dmenu}";
"super_l+${shift}" = "exec ${pkill} wofi || ${wofi} --show run";
}
# Lockscreen keybindings
# Lockscreen binds
// flags "--no-repeat --release --locked"
{
"${super}+l" = "exec ${loginctl} lock-session";
"delete+${ctrl}" = "reload";
"delete+${ctrl}+${alt}" = "exec ${loginctl} terminate-user ''";
"l+${super}" = "exec ${loginctl} lock-session";
};
};
#// modes = { };
# Keybindings that are not supported by options
# Binds not supported by options
extraConfig = ''
# Gesture keybindings
# Gesture binds
bindgesture swipe:left workspace prev
bindgesture swipe:right workspace next
# Switch keybindings
# Switch binds
bindswitch lid:on exec ${loginctl} lock-session
#// bindswitch lid:on output '*' power off
#// bindswitch lid:off output '*' power on

View file

@ -13,9 +13,9 @@ in {
binds.enable = true;
input.enable = true;
output.enable = true;
# TODO: rules.enable = true;
rules.enable = true;
settings.enable = true;
#// swayfx.enable = true;
swayfx.enable = true;
};
# https://wiki.nixos.org/wiki/Sway

View file

@ -16,7 +16,7 @@ in {
wayland.windowManager.sway.config.output = {
# Default
"*" = {
adaptive_sync = "off"; # Explicitly use script/keybindings to toggle vrr
adaptive_sync = "off"; # Explicitly use script/binds to toggle vrr
background = "#073642 solid_color"; # Fallback color
resolution = "${toString config.custom.width}x${toString config.custom.height}@${toString config.custom.refresh}Hz";
scale = toString config.custom.scale;

View file

@ -0,0 +1,63 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.custom.desktops.sway.rules;
in {
options.custom.desktops.sway.rules.enable = mkOption {default = false;};
config.home-manager.users.${config.custom.username} = mkIf cfg.enable {
# https://i3wm.org/docs/
wayland.windowManager.sway.config.window.commands = let
command = command: {inherit command;};
# Boilerplate criteria
#?? criteria = <"ATTR"|{ATTRS = "EXPR"}> <"EXPR"|null>
criteria = attr: expr: {
criteria = with builtins;
if isAttrs attr
then (mapAttrs (a: e: "^${e}$") attr)
else {
${attr} =
if isNull expr
then true
else "^${expr}$";
};
};
class = expr: criteria "app_id" expr;
floating = criteria "floating" null;
mark = expr: criteria "con_mark" expr;
title = expr: criteria "title" expr;
attrs = attrs: criteria attrs null;
in [
### Defaults
# HACK: Prefer default_floating_border when fixed upstream
# https://github.com/swaywm/sway/issues/7360
(floating // command "border normal 0")
### Marks
(mark "browser" // command "move to workspace 1")
(mark "dropdown" // command "move to scratchpad")
(mark "pip" // command "border none, floating enable, sticky enable")
(mark "terminal" // command "move to workspace terminal")
(title "Picture.in.[Pp]icture" // command "mark pip")
### Overrides
(attrs {
app_id = "firefox";
title = ".*Firefox.*";
}
// command "layout tabbed")
(attrs {
app_id = "firefox";
title = "Extension.*";
}
// command "floating enable")
];
};
}

View file

@ -1,52 +1,9 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
audio = "~/.local/bin/audio";
clipse = "${pkgs.clipse}/bin/clipse";
codium = "${config.home-manager.users.${config.custom.username}.programs.vscode.package}/bin/codium";
firefox-esr = "${config.home-manager.users.${config.custom.username}.programs.firefox.finalPackage}/bin/firefox-esr";
gnome-text-editor = "${pkgs.gnome-text-editor}/bin/gnome-text-editor";
hyprctl = "${config.programs.hyprland.package}/bin/hyprctl";
hyprlock = "${config.home-manager.users.${config.custom.username}.programs.hyprlock.package}/bin/hyprlock";
hyprpicker = "${pkgs.hyprpicker}/bin/hyprpicker";
inhibit = config.home-manager.users.${config.custom.username}.home.file.".local/bin/inhibit".source;
jq = "${pkgs.jq}/bin/jq";
kill = "${pkgs.procps}/bin/kill";
kitty = "${config.home-manager.users.${config.custom.username}.programs.kitty.package}/bin/kitty";
left = config.home-manager.users.${config.custom.username}.home.file.".local/bin/left".source;
loginctl = "${pkgs.systemd}/bin/loginctl";
menu = config.home-manager.users.${config.custom.username}.home.file.".local/bin/menu".source;
nautilus = "${pkgs.nautilus}/bin/nautilus";
networkmanager_dmenu = "${pkgs.networkmanager_dmenu}/bin/networkmanager_dmenu";
notify-send = "${pkgs.libnotify}/bin/notify-send";
obsidian = "${pkgs.obsidian}/bin/obsidian";
onlyoffice = "${pkgs.onlyoffice-bin}/bin/onlyoffice-desktopeditors --system-title-bar --xdg-desktop-portal";
pkill = "${pkgs.procps}/bin/pkill";
playerctl = "${pkgs.playerctl}/bin/playerctl";
rofi-rbw = "${pkgs.rofi-rbw}/bin/rofi-rbw";
rm = "${pkgs.coreutils}/bin/rm";
screenshot = "~/.local/bin/screenshot";
sleep = "${pkgs.coreutils}/bin/sleep";
smile = "${pkgs.smile}/bin/smile";
steam = "${config.programs.steam.package}/bin/steam";
swayosd-client = "${pkgs.swayosd}/bin/swayosd-client";
systemctl = "${pkgs.systemd}/bin/systemctl";
toggle = "~/.local/bin/toggle";
virt-manager = "${config.programs.virt-manager.package}/bin/virt-manager";
vm = config.home-manager.users.${config.custom.username}.home.file.".local/bin/vm".source;
vrr = config.home-manager.users.${config.custom.username}.home.file.".local/bin/vrr".source;
walker = "${config.home-manager.users.${config.custom.username}.programs.walker.package}/bin/walker";
waydroid = "${pkgs.waydroid}/bin/waydroid";
window = config.home-manager.users.${config.custom.username}.home.file.".local/bin/window".source;
workspace = config.home-manager.users.${config.custom.username}.home.file.".local/bin/workspace".source;
zoom = config.home-manager.users.${config.custom.username}.home.file.".local/bin/zoom".source;
sway-audio-idle-inhibit = "${pkgs.sway-audio-idle-inhibit}/bin/sway-audio-idle-inhibit";
waybar = "${config.home-manager.users.${config.custom.username}.programs.waybar.package}/bin/waybar";
cfg = config.custom.desktops.sway.settings;
in {
options.custom.desktops.sway.settings.enable = mkOption {default = false;};
@ -144,59 +101,6 @@ in {
# (once "${rm} ~/.cache/cliphist/db") # Clear clipboard database
# (once firefox-esr)
];
window.commands = let
command = command: {inherit command;};
# Boilerplate criteria
#?? criteria = <"ATTR"|{ATTRS = "EXPR"}> <"EXPR"|null>
criteria = attr: expr: {
criteria = with builtins;
if isAttrs attr
then (mapAttrs (a: e: "^${e}$") attr)
else {
${attr} =
if isNull expr
then true
else "^${expr}$";
};
};
app = expr: criteria "app_id" expr;
floating = criteria "floating" null;
mark = expr: criteria "con_mark" expr;
title = expr: criteria "title" expr;
attrs = attrs: criteria attrs null;
in [
### Defaults
# HACK: Prefer default_floating_border when fixed upstream
# https://github.com/swaywm/sway/issues/7360
(floating // command "border normal 0")
### Workspaces
# 1
(attrs {
app_id = "firefox";
title = ".*Firefox.*";
}
// command "layout tabbed")
(attrs {
app_id = "firefox";
title = "Extension.*";
}
// command "floating enable")
(mark "browser" // command "move to workspace 1")
# terminal
(mark "terminal" // command "move to workspace terminal")
### Scratchpads
(mark "dropdown" // command "move to scratchpad")
### Sticky
(mark "pip" // command "border none, floating enable, sticky enable")
];
};
#!! Applies to every move/workspace invocation

View file

@ -18,7 +18,7 @@ in {
# Polyfill home-manager wrappers
# https://github.com/nix-community/home-manager/blob/master/modules/services/window-managers/i3-sway/sway.nix#L334
package = with config.wayland.windowManager.sway;
package = with config.home-manager.users.${config.custom.username}.wayland.windowManager.sway;
pkgs.sway.override {
extraSessionCommands = extraSessionCommands;
extraOptions = extraOptions;