This repository has been archived on 2024-04-14. You can view files and clone it, but cannot push or open issues or pull requests.
nixos-dotfiles/user/configs/wayland/waybar.nix

199 lines
4.7 KiB
Nix
Raw Normal View History

2023-03-14 15:23:24 +00:00
{ config, pkgs, lib, nix-colors, ... }:
2022-08-07 16:37:11 +01:00
let
2023-03-14 15:23:24 +00:00
wobsock = "/tmp/wob-vol.fifo";
2022-12-16 08:10:28 +00:00
colors = config.colorScheme.colors;
2023-03-14 15:23:24 +00:00
backgroundColorRGB = nix-colors.lib-core.conversions.hexToRGBString "," colors.base00;
backgroundAlpha = "0.7";
font = "JetBrainsMono Nerd Font";
fontSize = "9pt";
2022-10-03 23:21:40 +01:00
ds-battery = pkgs.writeShellScriptBin "ds-battery.sh" ''
ds_capacity_file="/sys/class/power_supply/ps-controller-battery-4c:b9:9b:74:ae:31/capacity"
ds_status_file="/sys/class/power_supply/ps-controller-battery-4c:b9:9b:74:ae:31/status"
2022-08-07 16:37:11 +01:00
2022-10-03 23:21:40 +01:00
while true; do
if [[ -f $ds_capacity_file ]]; then
charge=$(<"$ds_capacity_file")
if [[ $(<"$ds_status_file") == "Charging" ]]; then
echo "{\"class\":\"charging\",\"text\":\" Charging: $charge%\",\"tooltip\":\"Charging:\n$charge%\"}"
else
echo "{\"class\":\"discharging\",\"text\":\" $charge%\",\"tooltip\":\"Battery:\\n$charge%\"}"
fi
else
echo "{\"class\":\"not_connected\",\"text\":\"\"}"
fi
sleep 1
done
'';
2022-11-14 11:58:04 +00:00
in
{
2022-08-07 16:37:11 +01:00
programs.waybar = {
enable = true;
settings = [{
layer = "top";
position = "top";
height = 32;
2023-02-26 00:49:03 +00:00
modules-left = [ "custom/blank" "hyprland/window" ];
modules-center = [ "wlr/workspaces" "custom/blank" ];
2022-10-03 23:21:40 +01:00
modules-right = [
"custom/ds-battery"
2023-03-14 15:23:24 +00:00
"wireplumber"
2022-10-03 23:21:40 +01:00
"mpd"
"tray"
"custom/blank"
"clock"
"custom/blank"
];
2022-08-07 16:37:11 +01:00
2022-10-03 23:21:40 +01:00
"sway/mode" = { format = " {}"; };
2022-08-07 16:37:11 +01:00
"sway/window" = {
icon = false;
icon-size = 16;
};
"wlr/workspaces" = {
on-click = "activate";
on-scroll-up = "hyprctl dispatch workspace e+1";
on-scroll-down = "hyprctl dispatch workspace e-1";
2023-02-26 00:49:03 +00:00
format = "{icon}";
format-icons = {
active = "";
default = "";
};
};
"hyprland/window" = {
separate-outputs = true;
};
2022-11-14 11:58:04 +00:00
"clock" = {
format = "{:%a %d. %B %H:%M}";
};
2022-08-07 16:37:11 +01:00
2023-03-14 15:23:24 +00:00
"wireplumber" = {
2022-08-07 16:37:11 +01:00
scroll-step = 5;
format = "{icon} {volume}%";
format-icons = [ "" "" "" "" ];
2023-02-26 00:49:03 +00:00
ignored-sinks = [ "Easy Effects Sink" ];
2023-03-14 15:23:24 +00:00
on-scroll-up = "${pkgs.pamixer}/bin/pamixer -i 10 --get-volume > ${wobsock}";
on-scroll-down = "${pkgs.pamixer}/bin/pamixer -d 10 --get-volume > ${wobsock}";
2022-08-07 16:37:11 +01:00
};
"tray" = {
icon-size = 16;
spacing = 10;
};
2023-03-14 15:23:24 +00:00
2022-08-07 16:37:11 +01:00
"mpd" = {
2022-10-03 23:21:40 +01:00
format =
"{stateIcon} {artist} - {title} {elapsedTime:%M:%S}/{totalTime:%M:%S}";
2022-08-07 16:37:11 +01:00
format-stopped = " stopped";
state-icons = {
playing = "";
paused = "";
};
2023-03-14 15:23:24 +00:00
on-click = "${pkgs.foot}/bin/foot -e ${pkgs.ncmpcpp}/bin/ncmpcpp";
2022-08-07 16:37:11 +01:00
};
"custom/ds-battery" = {
return-type = "json";
exec = "${ds-battery}/bin/ds-battery.sh";
escape = "true";
};
2023-03-14 15:23:24 +00:00
2022-10-03 23:21:40 +01:00
"custom/blank" = { format = " "; };
2023-03-14 15:23:24 +00:00
2022-08-07 16:37:11 +01:00
}];
2023-03-14 15:23:24 +00:00
2022-08-07 16:37:11 +01:00
style = ''
2022-12-16 08:10:28 +00:00
@define-color foreground #${colors.base06};
2023-03-14 15:23:24 +00:00
@define-color background rgba(${backgroundColorRGB},${backgroundAlpha});
2022-12-16 08:10:28 +00:00
@define-color box-bg #${colors.base01};
2023-02-26 00:49:03 +00:00
@define-color workspace-bg #${colors.base00};
2022-08-07 16:37:11 +01:00
* {
2023-03-14 15:23:24 +00:00
font-family: ${font};
font-size: ${fontSize};
2022-08-07 16:37:11 +01:00
}
window#waybar {
background: @background;
color: @foreground;
}
2023-03-14 15:23:24 +00:00
#wireplumber,
#mpd,
#custom-waybar-mpris,
#custom-ds-battery,
#window,
#keyboard-state,
#tray,
#clock {
2022-08-07 16:37:11 +01:00
background: @box-bg;
2023-03-14 15:23:24 +00:00
padding: 0px 10px 0px 10px;
margin: 5px 10px 5px 0px;
2023-02-26 00:49:03 +00:00
border-radius: 10px;
2022-08-07 16:37:11 +01:00
}
2023-03-14 15:23:24 +00:00
#wireplumber {
margin: 5px 4px 5px 0px;
border-radius: 10px 0px 0px 10px;
}
#mpd {
border-radius: 0px 10px 10px 0px;
}
2022-08-07 16:37:11 +01:00
#tray, #clock {
2023-03-14 15:23:24 +00:00
margin: 5px 0px 5px 0px;
2022-08-07 16:37:11 +01:00
}
2023-02-26 00:49:03 +00:00
window#waybar.empty #window {
background: @background;
2022-08-07 16:37:11 +01:00
}
#workspaces {
2023-03-14 15:23:24 +00:00
margin: 5px 0px 5px 0px;
2023-02-26 00:49:03 +00:00
padding-left: 10px;
2022-08-07 16:37:11 +01:00
}
#workspaces button {
color: @foreground;
2023-02-26 00:49:03 +00:00
background: @box-bg;
2023-03-14 15:23:24 +00:00
padding: 0px 5px;
2022-08-07 16:37:11 +01:00
}
2023-02-26 00:49:03 +00:00
#workspaces button:last-child {
background: @box-bg;
2023-03-14 15:23:24 +00:00
border-radius: 0px 10px 10px 0px;
2023-02-26 00:49:03 +00:00
}
#workspaces button:first-child {
background: @box-bg;
border-radius: 10px 0px 0px 10px;
}
#workspaces button:only-child {
background: @box-bg;
border-radius: 10px 10px 10px 10px;
}
#workspaces button.active {
2022-08-07 16:37:11 +01:00
color: @foreground;
background: @box-bg;
font-weight: bold;
}
#workspaces button.unfocused {
color: @foreground;
2023-02-26 00:49:03 +00:00
background: @box-bg;
2022-08-07 16:37:11 +01:00
}
'';
};
}
2023-02-26 00:49:03 +00:00