declarative waybar, update some stuff

This commit is contained in:
LordGrimmauld 2024-03-26 14:18:33 +01:00
parent 63842202cb
commit 284a9e5c36
12 changed files with 466 additions and 35 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
result

View File

@ -5,12 +5,23 @@ in {
build_definition_lines = lib.mapAttrsToList (name: value: "set \$${name} ${value}");
build_keybind_lines = lib.mapAttrsToList (key: value: "bindsym ${key} ${value}");
build_exec_lines = map (item: "exec " + item);
waybar_full = pkgs.writeShellScriptBin "waybar-full" (
"${config.programs.waybar.package}/bin/waybar"
+ (if isNull cfg.sway.barConfig then "" else " -c ${cfg.sway.barConfig}")
+ (if isNull cfg.sway.barStyle then "" else " -s ${cfg.sway.barStyle}")
);
bar_config = ''
bar {
swaybar_command ${waybar_full}/bin/waybar-full
}
'';
text = lib.strings.concatLines [
(lib.strings.concatLines (build_definition_lines cfg.sway.definitions))
(lib.strings.concatLines (build_keybind_lines cfg.sway.keybinds))
(lib.strings.concatLines (build_exec_lines cfg.sway.autolaunch))
cfg.sway.extraConfig
bar_config
];
sway_conf = pkgs.writeText "sway.conf" text;
@ -19,11 +30,13 @@ in {
source = sway_conf;
};
environment.systemPackages = with pkgs; [
environment.systemPackages = [
waybar_full
] ++ (with pkgs; [
procps
slurp
libnotify
];
]);
systemd.services.reload-sway = {
description = "Reload all running sway instances";
@ -60,6 +73,7 @@ done
wf-recorder
dmenu
wmenu
waybar-mpris
];
extraOptions = [
"--unsupported-gpu"

View File

@ -8,6 +8,7 @@
[ # Include the results of the hardware scan.
./modules/fonts.nix
./modules/tabletdriver.nix
./sway/sway-conf.nix
];
# Bootloader.
@ -50,11 +51,6 @@
"{1526fba1-ac33-4dfc-99d8-163e6129f7b9}" = "reveye-ris";
};
};
sway = {
enable = true;
populateDefaultConfig = true;
};
cloudSync = {
enable = true;
username = "Grimmauld";

View File

@ -78,11 +78,11 @@
"yafas": "yafas"
},
"locked": {
"lastModified": 1711229481,
"narHash": "sha256-mugLPd8wlCx1s1PDv/sIFJq5xK3sycf+fROFHvE8boE=",
"lastModified": 1711410101,
"narHash": "sha256-HEOyOUg+rRelnhsmXJ9ht0cUok94s2oCw6TtHhMPC+8=",
"owner": "chaotic-cx",
"repo": "nyx",
"rev": "1520b69fa40d96c5e95b6e0da65831d3c7130fb0",
"rev": "0d2b028bcf1a9c8d0d8bb987edec8d56a2075922",
"type": "github"
},
"original": {
@ -138,11 +138,11 @@
]
},
"locked": {
"lastModified": 1710821861,
"narHash": "sha256-Y+x3q7VkPpRok7Om2bwB2v1JDK/OCZmiFaBrIOJRojY=",
"lastModified": 1711172967,
"narHash": "sha256-HBkYzSfFM0oMnRSjquI1CJ7a4jtIv9eRbAeJZDE8H3M=",
"owner": "girlbossceo",
"repo": "conduwuit",
"rev": "7809f0a6aee6900de59b720bf966d4a0315276bc",
"rev": "101cb34f9a1b94b91717af3581f35386f20d4601",
"type": "github"
},
"original": {
@ -331,11 +331,11 @@
]
},
"locked": {
"lastModified": 1710915975,
"narHash": "sha256-yOc0AD6ba7mbialNciZGzuSQLMo4CopoZGEfcUugA4I=",
"lastModified": 1711231487,
"narHash": "sha256-dRdFjStMA7GeuD/V4vzKblzuHwxMPgzEboRleVdZlUM=",
"owner": "Jovian-Experiments",
"repo": "Jovian-NixOS",
"rev": "179d73fbe14c5bdb835d10bcc1c783466112bfa6",
"rev": "1171169117f63f1de9ef2ea36efd8dcf377c6d5a",
"type": "github"
},
"original": {
@ -357,11 +357,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1710898409,
"narHash": "sha256-vk+NUeKBb8pyTkZvHVq7+or25fpnSeaaSBGHSGKXL44=",
"lastModified": 1711332928,
"narHash": "sha256-VSqMvQR22wn0ySB4mvDqNnrOl43cBJc4vkPAk9YEPoQ=",
"owner": "martinvonz",
"repo": "jj",
"rev": "4fbe6aecc95152eda44cb4b185ab369e23e1393f",
"rev": "15ff7dfd4836d1d6d9fad0a91e06dea2b3dea58d",
"type": "github"
},
"original": {
@ -394,11 +394,11 @@
]
},
"locked": {
"lastModified": 1710858553,
"narHash": "sha256-CHSkAhNaWIMXlJX7skC2t5wr/qaNlMgWQsezNqr15mw=",
"lastModified": 1711266147,
"narHash": "sha256-oNAcVJ0oNwq0JTw9ZmopJREiT4NZ+1VMs5vY85eidnQ=",
"owner": "YaLTeR",
"repo": "niri",
"rev": "db49deb7fd2fbe805ceec060aa4dec65009ad7a7",
"rev": "e5bd1113ba293bed1b80f04e8683d1aa847a5dc8",
"type": "github"
},
"original": {

View File

@ -37,7 +37,6 @@
./load_common.nix
./specific/grimm-nixos-laptop.nix
# ./kernel.nix
./configuration.nix
./modules/users.nix
# ./modules/tlp.nix

View File

@ -113,10 +113,16 @@ in {
description = "additional sway config to be included";
};
populateDefaultConfig = mkOption {
type = types.bool;
default = false;
description = "puts my personal config in place using above methods";
barStyle = mkOption {
type = types.nullOr types.path;
default = null;
description = "waybar style sheet to use";
};
barConfig = mkOption {
type = types.nullOr types.path;
default = null;
description = "waybar config to use";
};
};
@ -173,7 +179,6 @@ in {
./common/firefox.nix
./common/pass.nix
./common/sway.nix
./common/sway-defaults.nix
./common/cloudsync.nix
];
}

View File

@ -18,6 +18,7 @@
prusa-slicer
freecad
openscad
jetbrains.clion
# blender
];
};

121
sway/bar/config Normal file
View File

@ -0,0 +1,121 @@
{
// "layer": "top", // Waybar at top layer
"position": "top",
"height": 30, // Waybar height (to be removed for auto height)
// "width": 1280, // Waybar width
"spacing": 4, // Gaps between modules (4px)
// Choose the order of the modules
"modules-left": ["sway/workspaces", "sway/mode", "sway/scratchpad"],
"modules-center": [], // "sway/window"],
"modules-right": ["custom/media", "idle_inhibitor", "pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "keyboard-state", "battery", "clock", "tray"],
"keyboard-state": {
"numlock": true,
"capslock": true,
"format": "{name} {icon}",
"format-icons": {
"locked": "",
"unlocked": ""
}
},
"sway/mode": {
"format": "<span style=\"italic\">{}</span>"
},
"sway/scratchpad": {
"format": "{icon} {count}",
"show-empty": false,
"format-icons": ["", ""],
"tooltip": true,
"tooltip-format": "{app}: {title}"
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "",
"deactivated": ""
}
},
"tray": {
// "icon-size": 21,
"spacing": 10
},
"clock": {
// "timezone": "America/New_York",
"tooltip-format": "<big>{:%Y %B}</big>\n<tt><small>{calendar}</small></tt>",
"format-alt": "{:%d.%m.%Y}"
},
"cpu": {
"format": "{usage}% ",
"tooltip": false
},
"memory": {
"format": "{}% "
},
"temperature": {
// "thermal-zone": 2,
// "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input",
"critical-threshold": 80,
// "format-critical": "{temperatureC}°C {icon}",
"format": "{temperatureC}°C {icon}",
"format-icons": ["", "", ""]
},
"backlight": {
// "device": "acpi_video1",
"format": "{percent}%",
"format-icons": ["", "", "", "", "", "", "", "", ""]
},
"battery": {
"states": {
// "good": 95,
"warning": 30,
"critical": 15
},
"format": "{capacity}% {icon}",
"format-charging": "{capacity}% ",
"format-plugged": "{capacity}% ",
"format-alt": "{time} {icon}",
// "format-good": "", // An empty format will hide the module
// "format-full": "",
"format-icons": ["", "", "", "", ""]
},
"battery#bat2": {
"bat": "BAT2"
},
"network": {
// "interface": "wlp2*", // (Optional) To force the use of this interface
"format-wifi": "{essid} ({signalStrength}%) ",
"format-ethernet": "{ipaddr}/{cidr} ",
"tooltip-format": "{ifname} via {gwaddr} ",
"format-linked": "{ifname} (No IP) ",
"format-disconnected": "Disconnected ⚠",
"format-alt": "{ifname}: {ipaddr}/{cidr}"
},
"pulseaudio": {
// "scroll-step": 1, // %, can be a float
"format": "{volume}% {icon} {format_source}",
"format-bluetooth": "{volume}% {icon} {format_source}",
"format-bluetooth-muted": " {icon} {format_source}",
"format-muted": " {format_source}",
"format-source": "{volume}% ",
"format-source-muted": "",
"format-icons": {
"headphone": "",
"hands-free": "",
"headset": "",
"phone": "",
"portable": "",
"car": "",
"default": ["", "", ""]
},
"on-click": "pavucontrol"
},
"custom/media": {
"return-type": "json",
"on-click": "waybar-mpris --send toggle",
"exec": "waybar-mpris --position --autofocus --pause ⏵ --play ⏸ --order SYMBOL:TITLE:ARTIST:ALBUM:POSITION ",
"on-scroll-up": "waybar-mpris --send next",
"on-scroll-down": "waybar-mpris --send prev",
"max-length": 40,
"escape": true
}
}

296
sway/bar/style.css Normal file
View File

@ -0,0 +1,296 @@
* {
/* `otf-font-awesome` is required to be installed for icons */
font-family: FontAwesome, Roboto, Helvetica, Arial, sans-serif;
font-size: 14px;
border-radius: 5px;
margin: 1px 0;
}
window#waybar {
background-color: rgba(35,38,41, 0);
/* border-bottom: 3px solid rgba(100, 114, 125, 0.5); */
color: #ffffff;
transition-property: background-color;
transition-duration: .5s;
margin: 2px 0;
padding: 1px 1px;
}
window#waybar.hidden {
opacity: 0.2;
}
/*
window#waybar.empty {
background-color: transparent;
}
window#waybar.solo {
background-color: #FFFFFF;
}
*/
window#waybar.termite {
background-color: #3F3F3F;
}
window#waybar.chromium {
background-color: #000000;
border: none;
}
button {
/* Use box-shadow instead of border so the text isn't offset */
box-shadow: inset 0 -3px transparent;
/* Avoid rounded borders under each button name */
border: none;
}
/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */
button:hover {
background: inherit;
box-shadow: inset 0 -3px #ffffff;
}
#workspaces button {
padding: 0 2px;
margin: 0 3px;
background-color: #3F3F3F;
}
#workspaces button:hover {
background: rgba(0, 0, 0, 0.2);
}
#workspaces button.focused {
background-color: #232629;
/* box-shadow: inset 0 -3px #ffffff; */
}
#workspaces button.urgent {
background-color: #eb4d4b;
}
#mode {
background-color: #3F3F3F;
border-bottom: 3px solid #ffffff;
}
#clock,
#battery,
#cpu,
#memory,
#disk,
#temperature,
#backlight,
#network,
#pulseaudio,
#wireplumber,
#custom-media,
#tray,
#mode,
#idle_inhibitor,
#scratchpad,
#mpd {
padding: 0 10px;
color: #ffffff;
}
#window,
#workspaces {
margin: 0 4px;
}
/*
.modules-left > widget:first-child > #workspaces {
margin-left: 0;
}
.modules-right > widget:last-child > #workspaces {
margin-right: 0;
}
*/
@keyframes blink {
to {
background-color: #ffffff;
color: #000000;
}
}
#battery.critical:not(.charging) {
background-color: #f53c3c;
color: #ffffff;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
label:focus {
background-color: #31363b;
}
#clock {
background-color: #31363b;
}
#battery {
background-color: #31363b;
}
#battery.charging, #battery.plugged {
background-color: #31363b;
}
#cpu {
background-color: #31363b;
}
#memory {
background-color: #31363b;
}
#disk {
background-color: #31363b;
}
#backlight {
background-color: #31363b;
}
#network {
background-color: #31363b;
}
#network.disconnected {
background-color: #31363b;
}
#pulseaudio {
background-color: #31363b;
}
#pulseaudio.muted {
background-color: #31363b;
}
#wireplumber {
background-color: #31363b;
}
#wireplumber.muted {
background-color: #31363b;
}
#custom-media {
background-color: #31363b;
min-width: 100px;
}
#custom-media.custom-spotify {
background-color: #31363b;
}
#custom-media.custom-vlc {
background-color: #31363b;
}
#temperature {
background-color: #31363b;
}
#temperature.critical {
background-color: #31363b;
}
#tray {
background-color: #31363b;
}
#idle_inhibitor {
background-color: #31363b;
}
#idle_inhibitor.activated {
background-color: #31363b;
}
#mpd {
background-color: #31363b;
}
#mpd.disconnected {
background-color: #31363b;
}
#mpd.stopped {
background-color: #31363b;
}
#mpd.paused {
background-color: #31363b;
}
#privacy-item {
color: white;
}
#privacy-item.screenshare {
background-color: #31363b;
}
#privacy-item.audio-in {
background-color: #31363b;
}
#privacy-item.audio-out {
background-color: #31363b;
}
#tray > .passive {
-gtk-icon-effect: dim;
}
#tray > .needs-attention {
-gtk-icon-effect: highlight;
background-color: #31363b;
}
#language {
min-width: 16px;
}
#keyboard-state {
background: #31363b;
padding: 0 0px;
min-width: 16px;
}
#keyboard-state > label {
padding: 0 5px;
}
#keyboard-state > label.locked {
background: #232629;
}
#scratchpad {
background: rgba(0, 0, 0, 0.2);
}
#scratchpad.empty {
background-color: transparent;
}
#privacy {
padding: 0;
}

View File

@ -1,8 +1,6 @@
{ inputs, system, pkgs, config, lib, ... }: let
cfg = config.grimmShared;
swaymux_pkg = inputs.swaymux.packages."${system}".default;
in {
config = with cfg; lib.mkIf (enable && sway.enable && sway.populateDefaultConfig ) {
environment.systemPackages = (with pkgs; [
alacritty
wmenu
@ -13,6 +11,11 @@ in {
++ [ swaymux_pkg ];
grimmShared.sway = {
enable = true;
barConfig = ./bar/config;
barStyle = ./bar/style.css;
definitions = {
mod = "Mod4";
left = "h";
@ -139,9 +142,6 @@ output HDMI-A-1 mode 1920x1080@60Hz position 0,0
for_window [app_id="lxqt-policykit-agent"] floating enable;
floating_modifier $mod normal
bar {
swaybar_command waybar
}
input type:keyboard xkb_numlock enabled
include /etc/sway/config.d/*
@ -182,9 +182,7 @@ mode "resize" {
bindsym Return mode "default"
bindsym Escape mode "default"
}
# test
'';
};
};
}

View File

Before

Width:  |  Height:  |  Size: 6.7 MiB

After

Width:  |  Height:  |  Size: 6.7 MiB

View File

Before

Width:  |  Height:  |  Size: 6.9 MiB

After

Width:  |  Height:  |  Size: 6.9 MiB