Waybar : Add basic config.

This commit is contained in:
Dmitry Voronin 2024-05-02 04:47:21 +03:00
parent c3caeb7abf
commit 42c8679067
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
20 changed files with 237 additions and 3 deletions

View file

@ -12,6 +12,7 @@ in {
./desktop/Portal.nix ./desktop/Portal.nix
./desktop/Realtime.nix ./desktop/Realtime.nix
./desktop/Sound.nix ./desktop/Sound.nix
./desktop/Waybar.nix
]; ];
services.gnome.gnome-keyring.enable = lib.mkForce false; services.gnome.gnome-keyring.enable = lib.mkForce false;

View file

@ -21,7 +21,7 @@
applications = 12; applications = 12;
terminal = 12; terminal = 12;
popups = 12; popups = 12;
desktop = 12; desktop = 14;
}; };
serif = { serif = {
package = (pkgs.callPackage ./applefont {}); package = (pkgs.callPackage ./applefont {});

View file

@ -0,0 +1,7 @@
{ pkgs, ... } @args: let
waybar = import ./waybar args;
in {
programs.waybar.enable = true;
environment.variables.WAYBAR_CONFIG = pkgs.writeText "waybarConfig" waybar.config;
environment.variables.WAYBAR_STYLE = pkgs.writeText "waybarStyle" waybar.style;
}

View file

@ -0,0 +1,62 @@
{ ... }: {
text = ''
// -*- mode: jsonc -*-
{
"layer": "top", // Waybar at top layer
"position": "top", // Waybar position (top|bottom|left|right)
"height": 30, // Waybar height (to be removed for auto height)
"spacing": 4, // Gaps between modules (4px)
"mode": "dock",
"start_hidden": true,
"modules-left": [
"sway/workspaces",
"sway/mode",
"sway/scratchpad",
],
"modules-right": [
"sway/language",
"pulseaudio",
"battery",
"clock",
"tray"
],
"sway/scratchpad": {
"format": "{icon} {count}",
"show-empty": false,
"format-icons": ["", ""],
"tooltip": true,
"tooltip-format": "{app}: {title}"
},
"tray": {
// "icon-size": 21,
"spacing": 10
},
"clock": {
// "timezone": "America/New_York",
"tooltip-format": "<big><tt>{calendar}</tt></big>",
"format-alt": "{:%d %a %H:%M}"
},
"battery": {
"states": {
"good": 60,
"warning": 40,
"critical": 20
},
"format": "{capacity}% {icon}",
"format-charging": "{capacity}% ",
"format-plugged": "{capacity}% ",
"format-alt": "{time} {icon}",
"format-icons": ["󰂎", "󱊡", "󱊢", "󱊣", "󱊣"]
},
"pulseaudio": {
"scroll-step": 0,
"format": "{volume}% {icon}",
"format-muted": "󰸈",
"format-icons": {
"default": ["", "", ""]
},
"on-click": "pavucontrol"
}
}
'';
}

View file

@ -0,0 +1,4 @@
{ util, ... } @args: {
config = (import ./config args).text;
style = util.catAllText ./style args;
}

View file

@ -0,0 +1,17 @@
{ ... }: {
text = ''
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;
border-radius: 0;
}
/* 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;
}
'';
}

View file

@ -0,0 +1,9 @@
{ style, ... }: {
text = ''
* {
/* `otf-font-awesome` is required to be installed for icons */
font-family: "${style.font.serif.name}", FontAwesome, Roboto, Helvetica, Arial, sans-serif;
font-size: ${toString(style.font.size.desktop)}px;
}
'';
}

View file

@ -0,0 +1,18 @@
{ ... }: {
text = ''
#window,
#workspaces {
margin: 0 4px;
}
/* If workspaces is the leftmost module, omit left margin */
.modules-left > widget:first-child > #workspaces {
margin-left: 0;
}
/* If workspaces is the rightmost module, omit right margin */
.modules-right > widget:last-child > #workspaces {
margin-right: 0;
}
'';
}

View file

@ -0,0 +1,28 @@
{ style, ... }: {
text = ''
#clock,
#battery,
#cpu,
#memory,
#disk,
#temperature,
#backlight,
#network,
#pulseaudio,
#wireplumber,
#custom-media,
#tray,
#mode,
#idle_inhibitor,
#scratchpad,
#mpd {
margin: 2px;
padding-left: 4px;
padding-right: 4px;
}
#clock {
font-weight: bold;
}
'';
}

View file

@ -0,0 +1,33 @@
{ ... }: {
text = ''
/* Using steps() instead of linear as a timing function to limit cpu usage */
#battery.critical:not(.charging) {
background-color: #f53c3c;
color: #ffffff;
animation-name: blink;
animation-duration: 0.5s;
animation-timing-function: steps(12);
animation-iteration-count: infinite;
animation-direction: alternate;
}
#power-profiles-daemon {
padding-right: 15px;
}
#power-profiles-daemon.performance {
background-color: #f53c3c;
color: #ffffff;
}
#power-profiles-daemon.balanced {
background-color: #2980b9;
color: #ffffff;
}
#power-profiles-daemon.power-saver {
background-color: #2ecc71;
color: #000000;
}
'';
}

View file

@ -0,0 +1,12 @@
{ ... }: {
text = ''
#tray > .passive {
-gtk-icon-effect: dim;
}
#tray > .needs-attention {
-gtk-icon-effect: highlight;
background-color: #eb4d4b;
}
'';
}

View file

@ -0,0 +1,8 @@
{ style, ... }: {
text = ''
window#waybar {
background-color: rgba(${style.color.bg-r},${style.color.bg-g},${style.color.bg-b},${toString(style.opacity.desktop)});
color: #${style.color.fg.light}
}
'';
}

View file

@ -0,0 +1,14 @@
{ style, ... }: {
text = ''
#workspaces button {
padding: 0 5px;
color: #${style.color.fg.light};
background-color: transparent;
}
#workspaces button.focused {
background-color: rgba(${style.color.bg-r},${style.color.bg-g},${style.color.bg-b},${toString(style.opacity.desktop)});
border-top: 2px solid #${style.color.accent};
}
'';
}

View file

@ -24,6 +24,7 @@
./module/Workspace.nix ./module/Workspace.nix
./module/Session.nix ./module/Session.nix
./module/Keyd.nix ./module/Keyd.nix
./module/Waybar.nix
]; ];
}; };
in { in {

View file

@ -1,6 +1,6 @@
{ style, key, ... }: let { style, key, ... }: let
fontName = style.font.serif.name; fontName = style.font.serif.name;
fontSize = toString(style.font.size.popup); fontSize = toString(style.font.size.desktop);
accent = style.color.accent; accent = style.color.accent;
bg = style.color.bg.dark; bg = style.color.bg.dark;
@ -10,7 +10,7 @@ in {
# Application launcher. # Application launcher.
# Note: pass the final command to swaymsg so that the resulting window can be opened # Note: pass the final command to swaymsg so that the resulting window can be opened
# on the original workspace that the command was run on. # on the original workspace that the command was run on.
set $menu _dmenu_path_wrapped | wmenu -b -p 'Run:' -i -f "${fontName} ${fontSize}" -M ${bg} -S ${bg} -N ${bg} -m ${accent} -s ${accent} -n ${fg} | xargs swaymsg exec -- set $menu _dmenu_path_wrapped | wmenu -b -p 'Run:' -i -f "${fontName} ${fontSize}" -M ${bg}D9 -S ${bg}D9 -N ${bg}D9 -m ${accent} -s ${accent} -n ${fg} | xargs swaymsg exec --
bindsym $mod+${key.action.launch} exec $menu bindsym $mod+${key.action.launch} exec $menu
''; '';

View file

@ -0,0 +1,6 @@
{ key, ... }: {
text = ''
bindsym $mod+${key.sway.bar} exec pkill -SIGUSR1 waybar
exec waybar -c ''${WAYBAR_CONFIG} -s ''${WAYBAR_STYLE}
'';
}

View file

@ -104,6 +104,7 @@
sway = { sway = {
launch.terminal = "Escape"; launch.terminal = "Escape";
mod = "Mod4"; mod = "Mod4";
bar = "r";
notification = { notification = {
dismiss = "shift+N"; dismiss = "shift+N";
restore = "n"; restore = "n";

View file

@ -34,6 +34,12 @@
positive-b = config.lib.stylix.colors.base0B-rgb-b; positive-b = config.lib.stylix.colors.base0B-rgb-b;
positive-g = config.lib.stylix.colors.base0B-rgb-g; positive-g = config.lib.stylix.colors.base0B-rgb-g;
positive-r = config.lib.stylix.colors.base0B-rgb-r; positive-r = config.lib.stylix.colors.base0B-rgb-r;
bg-b = config.lib.stylix.colors.base00-rgb-b;
bg-g = config.lib.stylix.colors.base00-rgb-g;
bg-r = config.lib.stylix.colors.base00-rgb-r;
fg-b = config.lib.stylix.colors.base06-rgb-b;
fg-g = config.lib.stylix.colors.base06-rgb-g;
fg-r = config.lib.stylix.colors.base06-rgb-r;
}; };
font = { font = {

View file

@ -29,6 +29,12 @@
base0B-rgb-b = "135"; base0B-rgb-b = "135";
base0B-rgb-g = "175"; base0B-rgb-g = "175";
base0B-rgb-r = "135"; base0B-rgb-r = "135";
base00-rgb-b = "33";
base00-rgb-g = "32";
base00-rgb-r = "29";
base06-rgb-b = "199";
base06-rgb-g = "241";
base06-rgb-r = "251";
}; };
stylix = { stylix = {
fonts = { fonts = {

View file

@ -16,6 +16,7 @@
"keyd" "keyd"
"networkmanager" "networkmanager"
"video" "video"
"input"
]; ];
}; };
} }