/* TODO: create helper scripts for sharing of a screen portion ``` # this will create a new output named HEADLESS-. increments by 1 with each invocation even if the output is `unplug`ged. swaymsg create_output # find the name and the workspace number swaymsg -t get_outputs | jq '.[] | select(.name | test("HEADLESS-.*")) | (.name, .current_workspace)' swaymsg output HEADLESS-1 mode 1920@108060Hz # mirror the headless workspace on the current one nix run nixpkgs\#wl-mirror -- HEADLESS-1 # shift windows to the workspace and switch the focus to it */ { pkgs, config, lib, # packages', ... }: let lockCmd = "${pkgs.swaylock}/bin/swaylock -efF --color '#000000'"; displayOffCmd = "${pkgs.sway}/bin/swaymsg 'output * power off'"; displayOnCmd = "${pkgs.sway}/bin/swaymsg 'output * power on'"; swapOutputWorkspaces = ../../../scripts/sway-swapoutputworkspaces.sh; in { imports = [ ../profiles/wayland-desktop.nix ../programs/waybar.nix ]; services.dunst = { enable = true; }; services.gpg-agent.pinentryPackage = pkgs.pinentry-gnome3; home.packages = [ pkgs.swayidle pkgs.swaylock ## themes pkgs.gnome.adwaita-icon-theme pkgs.hicolor-icon-theme pkgs.gnome-icon-theme ## fonts pkgs.dejavu_fonts # just a basic good fond pkgs.font-awesome_5 # needed by i3status-rust pkgs.nerdfonts pkgs.font-awesome pkgs.roboto pkgs.ttf_bitstream_vera pkgs.noto-fonts pkgs.noto-fonts-cjk-sans pkgs.noto-fonts-cjk-serif pkgs.noto-fonts-emoji pkgs.noto-fonts-emoji-blob-bin pkgs.noto-fonts-extra pkgs.noto-fonts-lgc-plus pkgs.liberation_ttf pkgs.fira-code pkgs.fira-code-symbols pkgs.mplus-outline-fonts.githubRelease pkgs.dina-font pkgs.monoid pkgs.hermit ### found on colemickens' repo pkgs.gelasio # metric-compatible with Georgia pkgs.powerline-symbols pkgs.iosevka-comfy.comfy-fixed ## experimental stuff pkgs.fuzzel ]; # TODO: configure kanshi to always set the 5K resolution # DP-1 "Philips Consumer Electronics Company PHL 499P9 AU02419010010 (DP-1 via DP)" # Make: Philips Consumer Electronics Company # Model: PHL 499P9 # Serial: AU02419010010 # Physical size: 1190x340 mm # Enabled: yes # Modes: # 3840x1080 px, 59.967999 Hz (preferred) # 5120x1440 px, 59.977001 Hz (current) wayland.windowManager.sway = { enable = true; systemd.enable = true; xwayland = false; config = let modifier = "Mod4"; inherit (config.wayland.windowManager.sway.config) left right up down ; in { inherit modifier; bars = [ ]; input = { "type:keyboard" = { xkb_layout = config.home.keyboard.layout; xkb_variant = config.home.keyboard.variant; } // lib.attrsets.optionalAttrs (builtins.length (config.home.keyboard.options or [ ]) > 0) { xkb_options = builtins.concatStringsSep "," config.home.keyboard.options; }; "type:touchpad" = { natural_scroll = "enabled"; }; # alternatively run this command # swaymsg input "1386:914:Wacom_Intuos_Pro_S_Pen" tool_mode "* relative" # and then switch to a different VT (alt+ctrl+f2) and back "1386:914:Wacom_Intuos_Pro_S_Pen" = { tool_mode = "* relative"; }; }; keybindings = lib.mkOptionDefault { # as of 2023-05-21 the `!!` arg parsing mode was broken for me on yofi # "${modifier}+d" = "exec ${packages'.yofi}/bin/yofi binapps"; "${modifier}+d" = "exec ${pkgs.fuzzel}/bin/fuzzel --show-actions"; # only 1-9 exist on the default config "${modifier}+0" = "workspace number 0"; "${modifier}+Shift+0" = "move container to workspace number 0"; # disable splitting for now as i sometimes trigger it accidentally and then get stuck with it "${modifier}+b" = "nop"; "${modifier}+v" = "nop"; # move workspace to output "${modifier}+Control+Shift+${left}" = "move workspace to output left"; "${modifier}+Control+Shift+${right}" = "move workspace to output right"; "${modifier}+Control+Shift+${up}" = "move workspace to output up"; "${modifier}+Control+Shift+${down}" = "move workspace to output down"; # move workspace to output with arrow keys "${modifier}+Control+Shift+Left" = "move workspace to output left"; "${modifier}+Control+Shift+Right" = "move workspace to output right"; "${modifier}+Control+Shift+Up" = "move workspace to output up"; "${modifier}+Control+Shift+Down" = "move workspace to output down"; # TODO: i've been hitting this one accidentally way too often. find a better place. # "${modifier}+Shift+e" = "exec ${pkgs.sway}/bin/swaymsg exit"; "${modifier}+q" = "kill"; "${modifier}+Shift+q" = "exec ${pkgs.sway}/bin/swaymsg -t get_tree | ${pkgs.jq}/bin/jq 'recurse(.nodes[], .floating_nodes[]) | select(.focused).pid' | ${pkgs.findutils}/bin/xargs -L1 kill -9"; "${modifier}+x" = "exec ${swapOutputWorkspaces}"; "${modifier}+Ctrl+l" = "exec ${lockCmd}"; "--locked XF86AudioPlay" = "exec ${pkgs.playerctl}/bin/playerctl play-pause"; "XF86AudioPrev" = "exec ${pkgs.playerctl}/bin/playerctl previous"; "XF86AudioNext" = "exec ${pkgs.playerctl}/bin/playerctl next"; "XF86AudioRaiseVolume" = "exec ${pkgs.pulsemixer}/bin/pulsemixer --change-volume +5"; "XF86AudioLowerVolume" = "exec ${pkgs.pulsemixer}/bin/pulsemixer --change-volume -5"; "--locked XF86AudioMute" = "exec ${pkgs.pulsemixer}/bin/pulsemixer --toggle-mute"; "Print" = "exec ${pkgs.shotman}/bin/shotman --capture region"; }; terminal = "alacritty"; startup = [ { command = builtins.toString ( pkgs.writeShellScript "ensure-graphical-session" '' ( ${pkgs.coreutils}/bin/sleep 0.2 ${pkgs.systemd}/bin/systemctl --user restart graphical-session.target ) & '' ); } ] ++ lib.optionals config.services.swayidle.enable [ { command = builtins.toString ( pkgs.writeShellScript "ensure-graphical-session" '' ( ${pkgs.coreutils}/bin/sleep 0.2 ${pkgs.systemd}/bin/systemctl --user restart swayidle ) & '' ); } ]; colors.focused = lib.mkOptionDefault { childBorder = lib.mkForce "#ffa500"; }; window.titlebar = false; window.border = 4; # this maps to focus_on_window_activation focus.newWindow = "urgent"; }; }; services.swayidle = { enable = true; timeouts = [ { timeout = 10; command = "if ${pkgs.procps}/bin/pgrep -x swaylock; then ${displayOffCmd}; fi"; resumeCommand = displayOnCmd; } { timeout = 60 * 5; command = lockCmd; } { timeout = 60 * 6; command = displayOffCmd; resumeCommand = displayOnCmd; } ]; events = [ { event = "before-sleep"; command = builtins.concatStringsSep "; " [ lockCmd "${pkgs.playerctl}/bin/playerctl pause" ]; } { event = "after-resume"; command = displayOnCmd; } { event = "lock"; command = lockCmd; } ]; }; }