diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-11-29 18:51:52 +0100 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-11-29 19:37:38 +0100 |
commit | 2138b4624eae088a81852f50b3a8f50fc0431a10 (patch) | |
tree | 701f7fdd68775c4c1589db463ef4ed37458c354c /modules/by-name/ya/yambar/settings | |
parent | chore(pkgs/by-name/ya/{cpu,memory}): Merge (diff) | |
download | nixos-config-2138b4624eae088a81852f50b3a8f50fc0431a10.tar.gz nixos-config-2138b4624eae088a81852f50b3a8f50fc0431a10.zip |
refactor(modules/legacy/conf/yambar): Move to `by-name` and modernize
Diffstat (limited to 'modules/by-name/ya/yambar/settings')
-rw-r--r-- | modules/by-name/ya/yambar/settings/default.nix | 370 |
1 files changed, 370 insertions, 0 deletions
diff --git a/modules/by-name/ya/yambar/settings/default.nix b/modules/by-name/ya/yambar/settings/default.nix new file mode 100644 index 00000000..041ac88e --- /dev/null +++ b/modules/by-name/ya/yambar/settings/default.nix @@ -0,0 +1,370 @@ +# TODO: This should not do something depending on whether the host is a laptop or not. It +# should instead match on monitor-width or scale factor. <2024-11-29> +{ + lib, + laptop ? false, + laptopBacklightName ? null, + scripts, +}: let + mkUnderline = color: { + underline = { + inherit color; + size = "3"; + }; + }; + + shellExec = cmd: ''sh -c "${cmd}"''; + + values = { + foreground = { + blue = "99d1dbff"; + focus = "e78284ff"; + green = "a6e3a1dd"; + lavendar = "b4befedd"; + mauve = "cba6f7dd"; + none = "0"; + normal = "c6ceefff"; + peach = "fab387dd"; + sapphire = "74c7ecdd"; + teal = "94e2d5dd"; + }; + font = { + main = "Source Code Pro:pixelsize=${ + if laptop + then "22" + else "26" + }"; + aws = "Font Awesome 5 Free:style=solid:pixelsize=${ + if laptop + then "20" + else "23" + }"; + }; + background = { + normal = "303446ff"; + tag = "585b70ff"; + tag2 = "45475aff"; + urgent = "e78284ff"; + }; + backgroundBlock = { + normal = {background = {color = values.background.normal;};}; + urgent = {background = {color = values.background.urgent;};}; + }; + underline = { + battery = mkUnderline values.foreground.sapphire; + clock = mkUnderline values.foreground.teal; + focused = mkUnderline values.foreground.focus; + resources = mkUnderline values.foreground.green; + title = mkUnderline values.background.tag; + urgent = mkUnderline values.foreground.blue; + utils = mkUnderline values.foreground.peach; + weather = mkUnderline values.foreground.lavendar; + }; + combination = { + battery.stack = [ + values.backgroundBlock.normal + values.underline.battery + ]; + clock.stack = [ + values.backgroundBlock.normal + values.underline.clock + ]; + resources.stack = [ + values.backgroundBlock.normal + values.underline.resources + ]; + utils.stack = [ + values.backgroundBlock.normal + values.underline.utils + ]; + weather.stack = [ + values.backgroundBlock.normal + values.underline.weather + ]; + }; + }; +in { + bar = { + background = values.foreground.none; + foreground = values.foreground.normal; + + font = values.font.main; + height = + if laptop + then "25" + else "45"; + margin = + if laptop + then "5" + else "10"; + location = "top"; + layer = "bottom"; + spacing = "0"; + + border = { + margin = "0"; + top-margin = "10"; + }; + + left = [ + { + river = let + tag_base_setting = { + map = let + normal = { + string = { + margin = "10"; + text = "{id}"; + }; + }; + in { + default = normal; + conditions = { + "state == focused" = { + string = { + deco = { + stack = [ + {background = {color = values.background.tag;};} + values.underline.focused + ]; + }; + margin = "10"; + text = "{id}"; + }; + }; + "state == invisible" = { + map = { + conditions = { + occupied = { + string = { + deco = {background = {color = values.background.tag2;};}; + margin = "10"; + text = "{id}"; + }; + }; + "~occupied" = normal; + }; + }; + }; + "state == unfocused" = { + string = { + deco = {background = {color = values.background.tag2;};}; + margin = "10"; + text = "{id}"; + }; + }; + "state == urgent" = { + string = { + deco = { + stack = [ + {background = {color = values.background.urgent;};} + values.underline.urgent + ]; + }; + margin = "10"; + text = "{id}"; + }; + }; + }; + }; + }; + in { + content = { + map = { + conditions = { + "id == 1" = tag_base_setting; + "id == 2" = tag_base_setting; + "id == 3" = tag_base_setting; + "id == 4" = tag_base_setting; + "id == 5" = tag_base_setting; + "id == 6" = tag_base_setting; + "id == 7" = tag_base_setting; + "id == 8" = tag_base_setting; + "id == 9" = tag_base_setting; + }; + on-click = { + left = shellExec "riverctl set-focused-tags $((1 << ({id} - 1)))"; + middle = shellExec "riverctl toggle-view-tags $((1 << ({id} -1)))"; + right = shellExec "riverctl toggle-focused-tags $((1 << ({id} -1)))"; + }; + }; + }; + title = { + map = { + conditions = {"title == \"\"" = {string = {text = "";};};}; + default = { + string = { + max = "35"; + deco = values.underline.title; + left-margin = "12"; + right-margin = "12"; + text = "{title}"; + }; + }; + }; + }; + }; + } + ]; + + center = [ + { + clock = { + date-format = "%d/%m/%y (%a)"; + time-format = "%H:%M:%S %Z"; + foreground = values.foreground.blue; + content = { + string = { + deco = values.combination.clock; + text = " {date} {time} "; + }; + }; + }; + } + ]; + + right = + [ + { + script = { + path = scripts.mpd_song_name_script; + content.map.conditions = { + playing = { + string = { + deco = values.combination.weather; + text = "{song} "; + }; + }; + "~playing" = { + string = { + deco = values.combination.weather; + text = ""; + }; + }; + }; + }; + } + { + script = { + path = scripts.volume_script; + content.map = { + on-click = shellExec "pavucontrol"; + conditions = { + muted = { + string = { + deco = values.backgroundBlock.urgent; + text = " "; + }; + }; + "~muted" = { + string = { + deco = values.combination.utils; + text = " {volume}% "; + }; + }; + }; + }; + }; + } + { + script = { + path = scripts.cpu_script; + content.string = { + deco = values.combination.resources; + text = " {cpu}% "; + }; + }; + } + { + script = { + path = scripts.memory_script; + content.map.conditions = { + swapstate = { + string = { + deco = values.combination.resources; + text = " {memperc}%({swapperc}%) "; + }; + }; + "~swapstate" = { + string = { + deco = values.combination.resources; + text = " {memperc}% "; + }; + }; + }; + }; + } + { + script = { + path = scripts.disk_script; + content.string = { + deco = values.combination.resources; + text = " {diskspace}({diskperc})"; + }; + }; + } + ] + ++ lib.optionals laptop [ + { + backlight = { + name = laptopBacklightName; + content.string = { + text = " {percent}% "; + deco = values.combination.utils; + }; + }; + } + { + battery = { + name = "BAT0"; + poll-interval = "300"; + content.list.items = [ + { + ramp = { + tag = "capacity"; + items = let + stack = [ + values.backgroundBlock.normal + values.underline.battery + ]; + in [ + { + string = { + text = " {capacity}%({estimate}) "; + deco = + values.backgroundBlock.urgent; + }; + } + { + string = { + text = " {capacity}%({estimate}) "; + deco.stack = stack; + }; + } + { + string = { + text = " {capacity}%({estimate}) "; + deco.stack = stack; + }; + } + { + string = { + text = " {capacity}%({estimate}) "; + deco.stack = stack; + }; + } + { + string = { + text = " {capacity}%({estimate}) "; + deco.stack = stack; + }; + } + ]; + }; + } + ]; + }; + } + ]; + }; +} |