From 0636d7ac99e6b25a0f9df986333a3cb4395bc112 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Mon, 21 Feb 2022 08:33:52 -0800 Subject: sway: switch to i3status and set keybindings Replace waybar with i3status. I keep running into issues with waybar (does not start, for example), and i3 status is a bit easier to configure. Set some keybindings so I can adjust volume and brightness. --- users/fcuny/desktop/sway/default.nix | 62 ++++++++++++++++++++- users/fcuny/desktop/sway/i3status.nix | 36 ++++++++++++ users/fcuny/desktop/sway/waybar.nix | 102 ---------------------------------- 3 files changed, 96 insertions(+), 104 deletions(-) create mode 100644 users/fcuny/desktop/sway/i3status.nix delete mode 100644 users/fcuny/desktop/sway/waybar.nix (limited to 'users/fcuny/desktop') diff --git a/users/fcuny/desktop/sway/default.nix b/users/fcuny/desktop/sway/default.nix index 5640664..7c18f66 100644 --- a/users/fcuny/desktop/sway/default.nix +++ b/users/fcuny/desktop/sway/default.nix @@ -2,7 +2,7 @@ { imports = [ - ./waybar.nix + ./i3status.nix ./sway-idle.nix ./wofi.nix ./gammastep.nix @@ -34,15 +34,73 @@ wayland.windowManager.sway = { enable = true; systemdIntegration = true; + extraSessionCommands = '' + export XDG_SESSION_TYPE=wayland + export XDG_CURRENT_DESKTOP=sway + export MOZ_ENABLE_WAYLAND=1 + ''; config = rec { modifier = "Mod4"; terminal = "${config.programs.alacritty.package}/bin/alacritty"; menu = "${pkgs.wofi}/bin/wofi -S run"; - bars = [ ]; + bars = [ + { + fonts = { + names = [ + "Source Code Pro" + "Font Awesome 5 Free" + ]; + size = 9.0; + style = "Bold"; + }; + extraConfig = '' + position top + ''; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; + colors = { + background = "#000000"; + statusline = "#88C0D0"; + separator = "#3B4252"; + focusedWorkspace = { + border = "#88C0D0"; + background = "#88C0D0"; + text = "#2E3440"; + }; + activeWorkspace = { + border = "#4C566ADD"; + background = "#4C566ADD"; + text = "#D8DEE9"; + }; + inactiveWorkspace = { + border = "#000000"; + background = "#000000"; + text = "#E5E9F0"; + }; + urgentWorkspace = { + border = "#B48EAD"; + background = "#B48EAD"; + text = "#ECEFF4"; + }; + bindingMode = { + border = "#BF616A"; + background = "#BF616A"; + text = "#E5E9F0"; + }; + }; + } + ]; fonts = { names = [ "Source Code Pro" ]; size = 10.0; }; + keybindings = lib.mkOptionDefault { + "XF86AudioRaiseVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ +5%"; + "XF86AudioLowerVolume" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-volume @DEFAULT_SINK@ -5%"; + "XF86AudioMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-sink-mute @DEFAULT_SINK@ toggle"; + "XF86AudioMicMute" = "exec ${pkgs.pulseaudio}/bin/pactl set-source-mute @DEFAULT_SOURCE@ toggle"; + "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"; + "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%"; + }; input = { "*" = { "xkb_layout" = "us,fr"; diff --git a/users/fcuny/desktop/sway/i3status.nix b/users/fcuny/desktop/sway/i3status.nix new file mode 100644 index 0000000..9eb5733 --- /dev/null +++ b/users/fcuny/desktop/sway/i3status.nix @@ -0,0 +1,36 @@ +{ pkgs, ... }: + +{ + programs.i3status-rust = { + enable = true; + bars.default = { + settings.theme.name = "plain"; + icons = "awesome5"; + blocks = [ + { + block = "net"; + format = "{ssid} {signal_strength} {ip}"; + interval = 5; + } + { + block = "battery"; + interval = 30; + format = "{percentage} {time}"; + } + { + block = "backlight"; + } + { + block = "sound"; + on_click = "${pkgs.pavucontrol}/bin/pavucontrol"; + } + { + block = "time"; + interval = 1; + format = "%b-%d %H:%M:%S"; + icons_format = ""; + } + ]; + }; + }; +} diff --git a/users/fcuny/desktop/sway/waybar.nix b/users/fcuny/desktop/sway/waybar.nix deleted file mode 100644 index eeabe14..0000000 --- a/users/fcuny/desktop/sway/waybar.nix +++ /dev/null @@ -1,102 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - programs.waybar = { - enable = true; - systemd.enable = true; - settings = [{ - layer = "top"; - position = "top"; - height = 20; - modules-left = ["sway/workspaces" "sway/mode"]; - modules-center = ["sway/window"]; - modules-right = [ "mpd" "network" "pulseaudio" "battery" "clock" ]; - modules = { - "network" = { - format-wifi = "{essid}:{signalStrength}%"; - format-ethernet = "{ifname}: {ipaddr}"; - format-disconnected = "Disconnected"; - }; - "pulseaudio" = { - format = "{volume}%"; - "on-click" = "${pkgs.pavucontrol}/bin/pavucontrol"; - }; - "clock" = { - format = "{:%a %d %b %H:%M}"; - }; - }; - }]; - - style = '' - * { - border: none; - border-radius: 0; - min-height: 0; - margin: 0; - padding: 0; - } - - #waybar { - background: #000000; - color: white; - font-family: Source Code Pro; - font-size: 12px; - } - - #clock, - #mode, - #network, - #pulseaudio { - padding-left: 10px; - padding-right: 10px; - } - - #clock { - font-weight: bold; - } - - #mode { - background: #64727D; - border-top: 2px solid white; - padding-bottom: 2px; - } - - #network { - } - - #network.disconnected { - color: orange; - } - - #pulseaudio { - } - - #pulseaudio.muted { - } - - #window { - font-weight: bold; - } - - #workspaces button { - border-top: 2px solid transparent; - /* To compensate for the top border and still have vertical centering */ - padding-bottom: 2px; - padding-left: 10px; - padding-right: 10px; - color: #888888; - } - - #workspaces button.focused { - border-color: #4c7899; - color: white; - background-color: #285577; - } - - #workspaces button.urgent { - border-color: #c9545d; - color: #c9545d; - } - ''; - }; -} -- cgit 1.4.1