add waybar config

This commit is contained in:
ulic-youthlic 2025-01-24 20:22:12 +08:00
parent b05c27b11e
commit 5ced8dea66
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
5 changed files with 154 additions and 233 deletions

View file

@ -10,7 +10,6 @@
imports = [
./niri
./wluma
./waybar
];
youthlic.programs = {

View file

@ -1,215 +0,0 @@
// -*- mode: jsonc -*-
{
// "layer": "top", // Waybar at top layer
// "position": "bottom", // Waybar position (top|bottom|left|right)
"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",
"custom/media"
],
"modules-center": [
"sway/window"
],
"modules-right": [
"mpd",
"idle_inhibitor",
"pulseaudio",
"network",
"power-profiles-daemon",
"cpu",
"memory",
"temperature",
"backlight",
"keyboard-state",
"sway/language",
"battery",
"battery#bat2",
"clock",
"tray",
"custom/power"
],
// Modules configuration
// "sway/workspaces": {
// "disable-scroll": true,
// "all-outputs": true,
// "warp-on-scroll": false,
// "format": "{name}: {icon}",
// "format-icons": {
// "1": "",
// "2": "",
// "3": "",
// "4": "",
// "5": "",
// "urgent": "",
// "focused": "",
// "default": ""
// }
// },
"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}"
},
"mpd": {
"format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ",
"format-disconnected": "Disconnected ",
"format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ",
"unknown-tag": "N/A",
"interval": 5,
"consume-icons": {
"on": " "
},
"random-icons": {
"off": "<span color=\"#f53c3c\"></span> ",
"on": " "
},
"repeat-icons": {
"on": " "
},
"single-icons": {
"on": "1 "
},
"state-icons": {
"paused": "",
"playing": ""
},
"tooltip-format": "MPD (connected)",
"tooltip-format-disconnected": "MPD (disconnected)"
},
"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": "{:%Y-%m-%d}"
},
"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}% {icon}",
"format-icons": ["", "", "", "", "", "", "", "", ""]
},
"battery": {
"states": {
// "good": 95,
"warning": 30,
"critical": 15
},
"format": "{capacity}% {icon}",
"format-full": "{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"
},
"power-profiles-daemon": {
"format": "{icon}",
"tooltip-format": "Power profile: {profile}\nDriver: {driver}",
"tooltip": true,
"format-icons": {
"default": "",
"performance": "",
"balanced": "",
"power-saver": ""
}
},
"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": {
"format": "{icon} {text}",
"return-type": "json",
"max-length": 40,
"format-icons": {
"spotify": "",
"default": "🎜"
},
"escape": true,
"exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder
// "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name
},
"custom/power": {
"format": "⏻ ",
"tooltip": false,
"menu": "on-click",
"menu-file": "$HOME/.config/waybar/power_menu.xml", // Menu file in resources folder
"menu-actions": {
"shutdown": "shutdown",
"reboot": "reboot",
"suspend": "systemctl suspend",
"hibernate": "systemctl hibernate"
}
}
}

View file

@ -1,4 +0,0 @@
{ ... }:
{
youthlic.programs.waybar.configDir = ./config;
}

View file

@ -25,6 +25,7 @@ in
swaynotificationcenter
swaybg
xwayland-satellite
niri-unstable
];
youthlic.programs = {
fuzzel.enable = true;
@ -33,6 +34,7 @@ in
};
programs.niri = {
config = builtins.readFile cfg.config;
package = pkgs.niri-unstable;
};
};
}

View file

@ -11,23 +11,162 @@ in
options = {
youthlic.programs.waybar = {
enable = lib.mkEnableOption "waybar";
configDir = lib.mkOption {
type = lib.types.path;
example = ./config;
description = ''
path to waybar config dir
'';
};
};
};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
waybar
];
xdg.configFile."waybar" = {
programs.waybar = {
enable = true;
source = cfg.configDir;
recursive = true;
systemd.enable = false;
settings = [
{
layer = "top";
position = "top";
modules-left = [
"niri/workspaces"
"wlr/taskbar"
];
modules-center = [ "clock" ];
modules-right = [
"tray"
"idle_inhibitor"
"memory"
"backlight"
"pulseaudio"
"battery"
];
"niri/worksapces" = { };
"niri/taskbar" = {
icon-size = 15;
on-click = "activate";
on-click-middle = "close";
};
"tray" = {
icon-size = 15;
spacing = 10;
};
idle_inhibitor = {
format = "{icon}";
format-icons = {
activated = " ";
deactivated = " ";
};
};
memory = {
format = " {percentage}%";
on-click = lib.getExe pkgs.resources;
};
backlight = {
format = "{icon}{percent}%";
format-icons = " ";
on-scroll-up = "${lib.getExe pkgs.brightnessctl} set +1%";
on-scroll-down = "${lib.getExe pkgs.brightnessctl} set 1%-";
};
pulseaudio = {
format = "{icon}{volume}%";
format-bluetooth = " {volume}%";
format-muted = " -%";
format-source = " {volume}%";
format-source-muted = " ";
format-icons = {
default = [
" "
" "
" "
];
headphone = " ";
headset = " ";
hands-free = " ";
};
on-click = "${lib.getExe' pkgs.wireplumber "wpctl"} set-mute @DEFAULT_AUDIO_SINK@ toggle";
on-click-right = lib.getExe pkgs.pwvucontrol;
tooltip-format = "{icon}{desc} {volume}%";
};
battery = {
states = {
warning = 30;
critical = 15;
};
format = "{icon}{capacity}%";
format-charging = " {capacity}%";
format-icons = [
" "
" "
" "
" "
" "
];
tooltip-format = ''
{power}W
{timeTo}'';
};
clock = {
format = "{:%a %b %d %R}";
calendar.format = {
months = "<span color='#ff7b63'>{}</span>";
days = "<span color='#ffffff'>{}</span>";
weeks = "<span color='#8ff0a4'>W{}</span>";
weekdays = "<span color='#f8e45c'>{}</span>";
today = "<span color='#78aeed'><u>{}</u></span>";
};
actions = {
on-scroll-up = "shift_up";
on-scroll-down = "shift_down";
};
tooltip-format = "{calendar}";
};
}
];
style = ''
* {
font-family: Noto Sans Mono, Noto Sans Mono CJK SC, FiraCode Nerd Font;
font-weight: bold;
font-size: 14px;
}
window#waybar {
background: alpha(@theme_base_color, 0.9);
color: @theme_text_color;
}
#workspaces,
#taskbar button,
#mode,
#clock,
#tray,
#mpris,
#idle_inhibitor,
#backlight,
#cpu,
#memory,
#pulseaudio,
#battery {
padding: 0 6px;
}
#workspaces button {
padding: 3px 6px;
}
#workspaces button.focused,
#workspaces button.active {
color: #78aeed;
}
#battery.warning {
color: #f8e45c;
}
#battery.critical {
color: #ff7b63;
}
#battery.charging {
color: #8ff0a4;
}
'';
};
};
}