diff options
Diffstat (limited to 'modules/workstation/windowing/sway')
-rw-r--r-- | modules/workstation/windowing/sway/choose_workspace.in | 6 | ||||
-rw-r--r-- | modules/workstation/windowing/sway/config.in | 97 | ||||
-rw-r--r-- | modules/workstation/windowing/sway/default.nix | 29 | ||||
-rw-r--r-- | modules/workstation/windowing/sway/status_command.in | 32 |
4 files changed, 164 insertions, 0 deletions
diff --git a/modules/workstation/windowing/sway/choose_workspace.in b/modules/workstation/windowing/sway/choose_workspace.in new file mode 100644 index 000000000000..8b36b66b2e77 --- /dev/null +++ b/modules/workstation/windowing/sway/choose_workspace.in @@ -0,0 +1,6 @@ +#! @execline@/bin/execlineb + +pipeline { swaymsg -t get_workspaces } +pipeline { @jq@/bin/jq -r .[].name } + +choose --bind alt-enter:print-query diff --git a/modules/workstation/windowing/sway/config.in b/modules/workstation/windowing/sway/config.in new file mode 100644 index 000000000000..c3fbd859a171 --- /dev/null +++ b/modules/workstation/windowing/sway/config.in @@ -0,0 +1,97 @@ +set $mod Mod4 +set $left h +set $down j +set $up k +set $right l + +default_border pixel +default_floating_border pixel +font monospace 12 +gaps inner 20 + +for_window '[app_id="float"]' { + floating enable +} + +input * natural_scroll enabled +output * bg #191919 solid_color + +client.focused #4c7899 #4d7b3a #ffffff #83d0a2 #4d7b3a + +bindsym $mod+Return exec alacritty +bindsym $mod+backslash exec firefox +bindsym $mod+Shift+q kill +bindsym $mod+d exec swaymsg exec "$(choosebin --tiebreak=begin,length,index)" + +# Drag floating windows by holding down $mod and left mouse button. +# Resize them with right mouse button + $mod. +# Despite the name, also works for non-floating windows. +# Change normal to inverse to use left mouse button for resizing and right +# mouse button for dragging. +floating_modifier $mod normal + +# reload the configuration file +bindsym $mod+Shift+c reload + +# exit sway (logs you out of your Wayland session) +bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit' + +bindsym $mod+$left focus left +bindsym $mod+$down focus down +bindsym $mod+$up focus up +bindsym $mod+$right focus right + +bindsym $mod+Shift+$left move left +bindsym $mod+Shift+$down move down +bindsym $mod+Shift+$up move up +bindsym $mod+Shift+$right move right + +bindsym $mod+g exec swaymsg workspace "$(@choose_workspace@ | sed 's/\$/$$/g')" +bindsym $mod+Shift+g exec swaymsg move container to workspace "$(@choose_workspace@ | sed 's/\$/$$/g')" + +bindsym $mod+b splith +bindsym $mod+v splitv + +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout toggle split + +bindsym $mod+f fullscreen + +bindsym $mod+Shift+space floating toggle +bindsym $mod+space focus mode_toggle + +bindsym $mod+a focus parent + +bindsym $mod+Shift+minus move scratchpad +bindsym $mod+minus scratchpad show + +mode "resize" { + bindsym $left resize shrink width 10px + bindsym $down resize grow height 10px + bindsym $up resize shrink height 10px + bindsym $right resize grow width 10px + + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +bar { + position top + + font monospace 12 + + status_command @status_command@ + + colors { + statusline #ffffff + background #191919 + } +} + +exec swayidle \ + timeout 300 'swaylock -c 000000' \ + timeout 600 'swaymsg "output * dpms off"' \ + resume 'swaymsg "output * dpms on"' \ + before-sleep 'swaylock -c 000000' diff --git a/modules/workstation/windowing/sway/default.nix b/modules/workstation/windowing/sway/default.nix new file mode 100644 index 000000000000..23076c475001 --- /dev/null +++ b/modules/workstation/windowing/sway/default.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: + +let + config = pkgs.substituteAll { + src = ./config.in; + inherit status_command choose_workspace; + }; + + status_command = pkgs.substituteAll { + src = ./status_command.in; + isExecutable = true; + inherit (pkgs) execline; + }; + + choose_workspace = pkgs.substituteAll { + src = ./choose_workspace.in; + isExecutable = true; + inherit (pkgs) execline jq; + }; + +in + +{ + environment.systemPackages = with pkgs; [ choose ]; + + programs.sway.enable = true; + + xdg.config.users.qyliss.paths."sway/config" = config; +} diff --git a/modules/workstation/windowing/sway/status_command.in b/modules/workstation/windowing/sway/status_command.in new file mode 100644 index 000000000000..15c1142cac37 --- /dev/null +++ b/modules/workstation/windowing/sway/status_command.in @@ -0,0 +1,32 @@ +#! @execline@/bin/execlineb + +loopwhilex + +# We need to capture the whole status line, and then echo it all at +# once, to work around https://github.com/swaywm/sway/issues/3857. +backtick -i -n line { + foreground { + backtick -i -n status { cat /sys/class/power_supply/BAT0/status } + importas -i -u status status + + ifelse { test $status = Charging } + { printf "↑" } + + if { test $status = Discharging } + printf "↓" + } + + foreground { + redirfd -r 0 /sys/class/power_supply/BAT0/capacity + tr -d "\n" + } + + foreground { printf "%% " } + + foreground { date "+%Y-%m-%d %H:%M:%S" } +} +importas -i -u line line + +foreground { echo $line } + +sleep 1 |