feat(home): Polybar

This commit is contained in:
punkfairie 2024-11-18 20:00:49 -08:00
parent 11f596b1ae
commit 60b871bce0
Signed by: punkfairie
GPG key ID: A509E8F77FB9D696
3 changed files with 409 additions and 1 deletions

View file

@ -9,6 +9,7 @@ in
{ {
home.keyboard.options = [ "apple:alupckeys" ]; home.keyboard.options = [ "apple:alupckeys" ];
# FIXME: Remove once we are on NixOS
targets.genericLinux = enabled; targets.genericLinux = enabled;
# FIXME: Remove this once nvim is set up # FIXME: Remove this once nvim is set up
@ -53,6 +54,7 @@ in
neo = enabled; neo = enabled;
rbw = enabled; rbw = enabled;
ripgrep = enabled; ripgrep = enabled;
# TODO: is this xorg only? bundle under xorg if so
rofi = enabled; rofi = enabled;
ssh = enabled; ssh = enabled;
starship = enabled; starship = enabled;
@ -65,8 +67,10 @@ in
}; };
services = { services = {
clipboard = enabled; clipboard = enabled;
# TODO: bundle this with the WM under xorg # TODO: bundle this under xorg
dunst = enabled; dunst = enabled;
# TODO: bundle this with xorg
polybar = enabled;
syncthing = enabled; syncthing = enabled;
}; };
xorg = { xorg = {

View file

@ -0,0 +1,398 @@
{
lib,
config,
pkgs,
...
}:
let
inherit (lib) mkEnableOption mkIf;
cfg = config.marleyos.services.polybar;
hasXorg = config.xsession.enable;
in
{
options.marleyos.services.polybar.enable = mkEnableOption "polybar";
config = mkIf (cfg.enable && hasXorg) {
home.packages = with pkgs; [
xorg.xrandr
];
services.polybar = {
enable = true;
script = # bash
''
if type "xrandr" &/dev/null; then
for m in $(xrandr --query | grep " connected" | cut -d" " -f1); do
bar="main"
if [[ "$m" == "DP-0" ]]; then
bar="tray"
fi
MONITOR="$m" polybar -q "$bar" &
done
else
polybar -q main &
fi
'';
# colorblock theme from
# https://github.com/adi1090x/polybar-themes
settings =
let
color = rec {
background = "#26232f";
foreground = background;
foreground-alt = "#c8c8cb";
alpha = "#00000000";
shade1 = "#d6adb5";
shade2 = "#d7bdc3";
dark = "#0a0a0a";
};
fmt = {
prefix.font = 2;
padding = 2;
};
pref = {
font = 2;
padding = 2;
};
hasRofi = config.marleyos.programs.rofi.enable;
cfgHome = config.xdg.configHome;
in
{
### Global Settings ###
"settings" = {
screenchange.reload = true;
compositing = {
background = "source";
foreground = "over";
overline = "over";
underline = "over";
border = "over";
};
pseudo.transparency = false;
};
"global/wm" = {
margin.bottom = 0;
};
### Bars ###
"bar/main" = {
monitor.text = "\${env:MONITOR:}";
monitor.strict = false;
override.redirect = true;
bottom = false;
fixed.center = true;
width = "99%";
height = 40;
offset.x = "0.5%";
offset.y = "1%";
background = color.alpha;
inherit (color) foreground;
radius.top = 0.0;
radius.bottom = 0.0;
underline.size = 2;
underline.color = color.foreground;
border.size = 0;
border.color = color.background;
padding = 0;
module.margin.left = 0;
module.margin.right = 0;
font =
let
mkFt = s: "Maple Mono NF:pixelsize=${toString s};4";
in
[
(mkFt 10)
(mkFt 15)
];
modules.left = "launcher sep workspaces sep title sep mpd";
modules.right = "filesystem sep cpu memory pulseaudio network date sep sysmenu";
dim.value = 1.0;
wm.restack = "i3";
enable.ipc = true;
scroll.up = "i3-msg workspace next_on_output";
scroll.down = "i3-msg workspace prev_on_output";
};
"bar/tray" = {
"inherit" = "bar/main";
modules.right = "color-switch tray sep updates sep cpu memory pulseaudio network date sep sysmenu";
};
### Modules ###
"module/sep" = {
type = "custom/text";
format = " ";
content.background = color.alpha;
content-foreground = color.alpha;
};
"module/launcher" = {
type = "custom/text";
content = {
text = "";
inherit (color) background;
foreground = color.shade2;
padding = 2;
};
click.left = mkIf hasRofi "${cfgHome}/rofi/launchers/type-1/launcher.sh &";
click.right = mkIf hasRofi "${cfgHome}/rofi/applets/bin/screenshot.sh &";
};
"module/workspaces" = {
type = "internal/xworkspaces";
pin.workspaces = true;
enable.click = true;
enable.scroll = true;
icon.text = [
"1;1"
"2;2"
"3;3"
"4;4"
"5;5"
];
icon.default = 0;
format = {
text = "<label-state>";
inherit (color) background;
inherit (color) foreground;
};
label = {
monitor = "%name%";
active = {
text = "%icon%";
background = color.shade2;
foreground = color.dark;
padding = 2;
};
occupied = {
text = "%icon%";
inherit (color) background;
foreground = color.shade2;
padding = 2;
};
urgent = {
text = "%icon%";
inherit (color) background;
foreground = "#cc6666";
padding = 2;
};
empty = {
text = "%icon%";
inherit (color) background;
foreground = color.foreground-alt;
padding = 2;
};
};
};
"module/title" = {
type = "internal/xwindow";
format.text = "<label>";
format.prefix = pref // {
text = "";
background = color.shade2;
foreground = color.dark;
};
label = {
text = "%title%";
maxlen = 30;
inherit (color) background;
foreground = "${color.foreground-alt}";
padding = 2;
empty = {
text = "Desktop";
inherit (color) background;
foreground = "${color.foreground-alt}";
padding = 2;
};
};
};
"module/mpd" = {
type = "internal/mpd";
interval = 1;
format.online = "<icon-prev><toggle><icon-next><label-song>";
format.offline = {
text = "<label-offline>";
prefix = pref // {
text = "";
background = color.shade1;
inherit (color) foreground;
};
};
label = {
song = {
text = "%artist% - %title%";
maxlen = 25;
ellipsis = true;
inherit (color) background;
foreground = color.foreground-alt;
padding = 2;
};
time = "%elapsed / %total%";
offline = {
text = "Offline";
inherit (color) background;
foreground = color.foreground-alt;
padding = 2;
};
};
icon =
let
mkIcon =
i:
pref
// {
text = i;
foreground = color.dark;
background = color.shade1;
};
in
{
play = mkIcon "";
pause = mkIcon "";
stop = "";
prev = mkIcon " ";
next = mkIcon " ";
seekb = "";
seekf = "";
random = "";
repeat = "";
repeatone = "";
single = "";
consume = "";
};
toggle = {
on.foreground = color.foreground;
off.foreground = color.background;
};
};
"module/filesystem" = {
type = "internal/fs";
mount = [
"/"
"/mnt/babeshare/marley"
"/mnt/babeshare/babez"
];
interval = 30;
fixed.values = true;
format = {
mounted = fmt // {
text = "<label-mounted>";
prefix.text = "";
background = color.shade2;
};
unmounted = fmt // {
text = "<label-unmounted>";
prefix.text = "";
background = color.shade2;
};
};
label = {
mounted = " %free%";
unmounted = " %mountpoint: not mounted";
};
};
"module/cpu" = {
type = "internal/cpu";
interval = 1;
format = fmt // {
text = "<label>";
prefix.text = "";
background = color.shade2;
inherit (color) foreground;
};
label = " %percentage%%";
};
"module/memory" = {
type = "internal/memory";
interval = 1;
format = fmt // {
text = "<label>";
prefix.text = "";
background = color.shade1;
};
label = " %mb_used%";
};
"module/pulseaudio" = {
type = "internal/pulseaudio";
sink = "alsa_output.pci-0000_03_00.6.analog-stereo";
use.ui.max = false;
interval = 5;
format = {
volume = {
text = "<ramp-volume> <label-volume>";
background = color.shade2;
padding = 2;
};
muted = fmt // {
text = "<label-muted>";
prefix.text = "";
background = color.shade2;
};
};
};
"module/network" = {
type = "internal/network";
interface = "enp4s0";
interval = 1.0;
accumulate.stats = true;
unknown.as.up = true;
format = {
connected = fmt // {
text = "<label-connected>";
prefix.text = "";
background = color.shade2;
};
disconnected = fmt // {
text = "<label-disconnected>";
prefix.text = "";
background = color.shade2;
};
};
label = {
connected = "%{A1:networkmanager_dmenu &:} %netspeed%%{A}";
disconnected = "%{A1:networkmanager_dmenu &:} Offline%{A}";
};
};
"module/date" = {
type = "internal/date";
interval = 1.0;
time.text = " %I:%M %p";
time.alt = " %a, %d %b %Y";
format = fmt // {
text = "<label>";
prefix.text = "";
background = color.shade1;
inherit (color) foreground;
};
label = "%time%";
};
"module/sysmenu" = {
type = "custom/text";
format = {
text = "";
inherit (color) background;
foreground = color.shade2;
padding = 2;
};
click.left = mkIf hasRofi "${cfgHome}/rofi/powermenu/type-1/powermenu.sh &";
};
};
};
};
}

View file

@ -0,0 +1,6 @@
_: final: prev: {
polybar = prev.polybar.override {
mpdSupport = true;
pulseSupport = true;
};
}