From 592960095594cb578b25687f32fdd259d0a167ab Mon Sep 17 00:00:00 2001 From: Daniel Patterson Date: Sun, 2 Jun 2024 20:54:00 +0100 Subject: [PATCH] sway stuff --- scripts/swayutils | 25 ++++++++++++ users/configs/desktop/sway/default.nix | 53 ++++++++++++++++++++++++-- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/scripts/swayutils b/scripts/swayutils index c665d47..1ed218a 100755 --- a/scripts/swayutils +++ b/scripts/swayutils @@ -1,3 +1,5 @@ +#!/bin/sh + function move { CURR_WORKSPACE=$(swaymsg -t get_workspaces | jq -r '. | map(select(.focused == true)) | .[0].name') @@ -8,6 +10,7 @@ function move { NEW_WORKSPACE=$(expr ${CURR_WORKSPACE} + 1) ;; "prev") + [ ${CURR_WORKSPACE} -eq 1 ] && exit 0 NEW_WORKSPACE=$(expr ${CURR_WORKSPACE} - 1) ;; esac @@ -16,8 +19,30 @@ function move { swaymsg "workspace ${NEW_WORKSPACE}" } +function focus { + CURR_WORKSPACE=$(swaymsg -t get_workspaces | jq -r '. | map(select(.focused == true)) | .[0].name') + + echo $CURR_WORKSPACE + + case $1 in + "next") + NEW_WORKSPACE=$(expr ${CURR_WORKSPACE} + 1) + ;; + "prev") + [ ${CURR_WORKSPACE} -eq 1 ] && exit 0 + NEW_WORKSPACE=$(expr ${CURR_WORKSPACE} - 1) + ;; + esac + + swaymsg "workspace ${NEW_WORKSPACE}" +} + case $1 in "move") move $2 ;; + + "focus") + focus $2 + ;; esac diff --git a/users/configs/desktop/sway/default.nix b/users/configs/desktop/sway/default.nix index 126fada..e8b9dce 100644 --- a/users/configs/desktop/sway/default.nix +++ b/users/configs/desktop/sway/default.nix @@ -31,6 +31,51 @@ in { wayland.windowManager.sway = { enable = true; config = { + bars = [ + { + mode = "dock"; + hiddenState = "hide"; + position = "bottom"; + workspaceButtons = true; + workspaceNumbers = true; + statusCommand = "${pkgs.i3status}/bin/i3status"; + fonts = { + names = ["monospace"]; + size = 12.0; + }; + trayOutput = "primary"; + colors = { + background = "#000000"; + statusline = "#ffffff"; + separator = "#666666"; + focusedWorkspace = { + border = "#4c7899"; + background = "#285577"; + text = "#ffffff"; + }; + activeWorkspace = { + border = "#333333"; + background = "#5f676a"; + text = "#ffffff"; + }; + inactiveWorkspace = { + border = "#333333"; + background = "#222222"; + text = "#888888"; + }; + urgentWorkspace = { + border = "#2f343a"; + background = "#900000"; + text = "#ffffff"; + }; + bindingMode = { + border = "#2f343a"; + background = "#900000"; + text = "#ffffff"; + }; + }; + } + ]; input = { "*" = { xkb_layout = "gb"; @@ -57,11 +102,11 @@ in { "${mod}+Down" = "movewindow down"; "${mod}+Right" = "movewindow right"; - "${mod}+Shift+h" = "swayutils move prev"; - "${mod}+Shift+l" = "swayutils move next"; + "${mod}+Shift+h" = "exec ${config.home.homeDirectory}/bin/swayutils move prev"; + "${mod}+Shift+l" = "exec ${config.home.homeDirectory}/bin/swayutils move next"; - "${mod}+Control+h" = "workspace prev"; - "${mod}+Control+l" = "workspace next"; + "${mod}+Control+h" = "exec ${config.home.homeDirectory}/bin/swayutils focus prev"; + "${mod}+Control+l" = "exec ${config.home.homeDirectory}/bin/swayutils focus next"; "${hyper}+y" = "move left"; "${hyper}+o" = "move right";