diff --git a/home-modules/bar.nix b/home-modules/bar.nix index fd70074..06cd61e 100644 --- a/home-modules/bar.nix +++ b/home-modules/bar.nix @@ -1,808 +1,9 @@ -{ pkgs, hyper, ... }@all: with all; let - sep = " "; -in { - sops.secrets = { - "nx2site/radicale/password" = { }; - }; - home.packages = [ -# (pkgs.writeShellApplication { name = "submap_indicator"; text = /*bash*/ '' -# print_help() { -# echo "Usage: submap_indicator {set |unset}" -# } -# if [ $# -lt 1 ]; then -# print_help; exit 1; -# fi -# case "$1" in -# set) -# # Check if there is a second argument for the 'set' operation -# if [ $# -eq 2 ]; then -# echo "$2" > /tmp/submap-indictor -# pkill -RTMIN+8 waybar -# pkill -RTMIN+8 hyprpanel -# else -# echo "Error: 'set' operation requires exactly one string argument." -# print_help -# exit 1 -# fi -# ;; -# unset) -# echo "" > /tmp/submap-indictor -# pkill -RTMIN+8 waybar -# pkill -RTMIN+8 hyprpanel -# ;; -# *) -# echo "Error: Unknown command '$1'" -# print_help -# exit 1 -# ;; -# esac -# exit 0 -# '';}) - (pkgs.writeShellApplication { name = "cclock"; text = /*bash*/ '' - ord=$(date +"%e" | awk '{printf("%d%s\n", $1, ($1==11||$1==12||$1==13)?"th":((($1%10)==1)?"st":((($1%10)==2)?"nd":((($1%10)==3)?"rd":"th"))))}') - if [ $# -eq 0 ]; then - echo "󰃮${sep}$(date +'%A the')" "$ord" "of" "$(date +'%B')" " ${sep}$(date +'%R')" - elif [ "$1" = "--no-icons" ]; then - echo "$(date +'%A the')" "$ord" "of" "$(date +'%B')" "$(date +'%R')" - fi - '';}) - - (pkgs.writers.writePython3Bin "caldav_event" { - libraries = with pkgs.python3Packages; [ caldav ics pytz ]; - flakeIgnore = [ "E302" "E305" "E501" "E261" ]; - } /* python */ '' -import os -import json -from caldav import DAVClient -from datetime import datetime, timezone -from ics import Calendar -from pytz import UTC - -def get_password(password_file): - with open(password_file, "r") as file: - return file.read().strip() - -def datetime_converter(obj): - if isinstance(obj, datetime): - return obj.isoformat() - return obj - -def datetime_parser(dct): - for key, value in dct.items(): - if isinstance(value, str): - try: - dct[key] = datetime.fromisoformat(value) - except ValueError: - pass - return dct - -def load_cache(cache_file): - if os.path.exists(cache_file): - with open(cache_file, "r") as file: - return json.load(file, object_hook=datetime_parser) - return None - -def save_cache(cache_file, data): - with open(cache_file, "w") as file: - json.dump(data, file, default=datetime_converter, indent=4) - - -def get_ongoing_or_next_event(url, username, password): - now = datetime.now(timezone.utc) - - try: - client = DAVClient(url, username=username, password=password) - principal = client.principal() - calendars = principal.calendars() - - next_event_dict = { - 'event_name': "fake", - 'event_begin': datetime(9000, 1, 1, tzinfo=UTC), # in the year 9000 - 'event_end': datetime(9000, 1, 1, 8, tzinfo=UTC), - } - - for calendar in calendars: - for event in calendar.search(start=now): - calendar_parsed = Calendar(event.data) - for ics_event in calendar_parsed.events: - event_dict = {} - event_dict['event_name'] = ics_event.name or "(No Title)" - event_dict['event_begin'] = ics_event.begin.astimezone(timezone.utc) - event_dict['event_end'] = ics_event.end.astimezone(timezone.utc) - - if event_dict['event_begin'] <= now and now <= event_dict['event_end']: - return event_dict - elif event_dict['event_begin'] >= now and next_event_dict['event_begin'] > event_dict['event_begin']: - next_event_dict = event_dict - return next_event_dict - - except Exception as e: - print(f"Error accessing {url}: {e}") - return None - -def is_expired(event_dict: dict): - now = datetime.now(timezone.utc).timestamp() - event_end = event_dict['event_end'].timestamp() - return not (now <= event_end) - -if __name__ == "__main__": - password_file = "${config.sops.secrets."nx2site/radicale/password".path}" # Path to password file - cache_file = "/tmp/caldav_event_cache.json" # Path to cache file - url = "https://dav.${hyper.domain}/" - username = "nx2" - password = get_password(password_file) - now = datetime.now(timezone.utc).timestamp() - - event_dict = load_cache(cache_file) - - if (event_dict is None) or (is_expired(event_dict)): - event_dict = get_ongoing_or_next_event(url, username, password) - save_cache(cache_file, event_dict) - - if event_dict is None: # none were found - print("* zen *") - exit(0) - - event_start = event_dict['event_begin'].timestamp() - event_end = event_dict['event_end'].timestamp() - - if event_start <= now <= event_end: # is currently ongoing - action_string = "ends" - t = event_end - now # time_remaining - else: # is in the future - action_string = "starts" - t = event_start - now # time_remaining - - hours, rem = divmod(int(t), 3600) - minutes, _ = divmod(rem, 60) - hour_string = f"{hours} hour{'s ' if hours != 1 else ' '}" if hours > 0 else "" - minu_string = f"{minutes} minute{'s ' if minutes != 1 else ' '}" if minutes > 0 else "" - if hour_string == "" and minu_string == "": - time_string = "now" - elif hour_string == "" or minu_string == "": - time_string = "in " + hour_string + minu_string - else: - time_string = "in " + hour_string + "and " + minu_string - - print(f"{event_dict['event_name']} {action_string} {time_string}") -'') +{ ... }: { + imports = [ + # ./bar/submap-indicator.nix + ./bar/cclock.nix + ./bar/caldav-event.nix + # ./bar/waybar.nix + ./bar/hyprpanel.nix ]; - programs = { -# waybar = { -# enable = false; -# package = pkgs.waybar; -# settings = { -# bar = { -# # height = 20; -# layer = "top"; -# position = "bottom"; -# margin-top = 0; -# # margin-left = rice.gap-size; -# # margin-bottom = rice.gap-size; -# # margin-right = rice.gap-size; -# margin-left = 0; -# margin-bottom = 0; -# margin-right = 0; -# spacing = 10; -# fixed-center = true; -# modules-left = [ -# # "cpu" -# # "memory" -# "wireplumber" -# "backlight" -# "battery" -# "network" -# "hyprland/window" -# ]; -# modules-center = [ -# "hyprland/workspaces" -# ]; -# modules-right = [ -# "custom/mode" -# "custom/caldav_event" -# "custom/cclock" -# "tray" -# ]; -# "hyprland/workspaces" = { -# on-click = "activate"; -# format = "{name}"; -# all-outputs = false; -# active-only = false; -# }; -# "hyprland/window" = { -# # format = "${sep}{}"; -# format = "{}"; -# separate-outputs = true; -# }; -# "custom/cclock" = { -# exec = "cclock"; -# restart-interval = 60; -# }; -# "custom/caldav_event" = { -# format = "󰃰${sep}{}"; -# exec = "caldav_event"; -# restart-interval = 60; -# max-width = 60; -# }; -# "custom/mode" = { -# exec = "cat /tmp/submap-indictor"; -# interval = "once"; -# signal = 8; -# }; - -# cpu = { -# interval = 1; -# format = "󰍛${sep}{}%"; -# max-length = 10; -# }; -# memory = { -# interval = 5; -# format = "${sep}{avail:.0f}G free"; -# }; -# battery = { -# interval = 60; -# tooltip = false; -# format = "{icon}${sep}{capacity}%"; -# states = { -# warning = 15; -# critical = 5; -# }; -# format-icons = [ " " " " " " " " " " ]; -# format-charging = "{icon}${sep}+{capacity}%"; -# format-plugged = "{icon}${sep}P{capacity}%"; -# format-full = "{icon}${sep}F{capacity}%"; -# }; -# backlight = { -# device = "eDP-1"; -# format = "{icon}${sep}{percent}%"; -# format-icons = [ "" "" "" "" "" "" "" "" "" ]; -# }; -# network = { -# format-wifi = "${sep}{essid}"; -# format-ethernet = "󰈀${sep}Wired"; -# format-disconnected = "󰌙${sep}Disconnected"; -# }; -# wireplumber = { -# format = "󰕾${sep}{volume}%"; -# format-muted = "󰝟${sep}--%"; -# }; -# }; -# }; -# style = with rice.color; let f = rice.lib.hex-to-rgb-comma-string; in /* css */ '' -# * { -# font-family: ${rice.font.code.name}; -# font-size: 1em; -# min-height: 0px; -# margin: 0px; -# padding: 0px; -# } - -# window#waybar { -# background: rgba(${f background},${builtins.toString rice.transparency}); -# } - -# #clock, -# #custom-cclock, -# #custom-mode, -# #custom-caldav-event, -# #battery, -# #cpu, -# #tray, -# #disk, -# #backlight, -# #network, -# #wireplumber, -# #memory, -# #window, -# #workspaces { -# padding: 0px 3px; -# margin-top: 0.3em; -# border-radius: ${builtins.toString rice.rounding}px; -# color: rgb(${f accent.bright}); -# } - -# #workspaces button { -# color: rgb(${f accent.base}); -# padding-left: 15px; -# padding-right: 15px; -# border-radius: ${builtins.toString rice.rounding}px; -# } -# #workspaces button.active { color: rgb(${f background}); background-color: rgb(${f accent.base}); } -# #workspaces button:hover { color: rgb(${f tertiary.bright}); } -# #workspaces button.urgent { background-color: rgba(${f magenta.base},${builtins.toString rice.transparency}); } - -# #window, #custom-caldav_event { -# font-family: ${rice.font.base.name}, ${rice.font.code.name}; -# color: rgb(${f tertiary.bright}); -# } - -# #wireplumber.muted { color: rgb(${f tertiary.bright}); } -# #wireplumber { padding-left: 10px; } - -# #battery.warning:not(.charging) { color: rgb(${f green.base});; } -# #battery.charging { color: rgb(${f green.base}); } -# #battery.critical { -# background: rgb(${f negative.base}); -# color: rgb(${f foreground}); -# } - -# #custom-mode { color: rgb(${f red.base}); } -# ''; -# }; - hyprpanel = { - enable = true; - package = pkgs.unstable.hyprpanel; - settings = with rice.color; let - t = builtins.toString (builtins.ceil (rice.transparency * 100)); - in { - "bar.layouts" = { - "*" = { - "left" = [ - "volume" - # "microphone" - # "cpu" - # "cputemp" - # "ram" - "battery" - # "bluetooth" - "network" - "windowtitle" - ]; - "middle" = [ "workspaces" ]; - "right" = [ - "submap" - "custom/caldav_event" - "media" - "custom/cclock" - "notifications" - "systray" - ]; - }; - }; - - "bar.bluetooth.label" = true; - - "bar.customModules.submap.enabledIcon" = "[󰧹]"; - "bar.customModules.submap.showSubmapName" = false; - "bar.customModules.submap.label" = false; - "bar.customModules.submap.icon" = true; - "bar.customModules.submap.disabledIcon" = ""; - - "bar.workspaces.applicationIconEmptyWorkspace" = ""; - "bar.workspaces.applicationIconOncePerWorkspace" = false; - "bar.workspaces.numbered_active_indicator" = "underline"; - "bar.workspaces.scroll_speed" = 1; - "bar.workspaces.showAllActive" = false; - "bar.workspaces.showApplicationIcons" = true; - "bar.workspaces.show_icons" = false; - "bar.workspaces.show_numbered" = false; - "bar.workspaces.showWsIcons" = true; - "bar.workspaces.spacing" = 1; - "bar.workspaces.workspaceMask" = true; - "bar.workspaces.workspaces" = 5; - - "theme.bar.background" = background; - "theme.bar.border.color" = accent.base; - "theme.bar.border_radius" = "0.2em"; - - "theme.bar.buttons.background" = background; - "theme.bar.buttons.background_opacity" = 0; - "theme.bar.buttons.spacing" = "0em"; - "theme.bar.buttons.padding_x" = "0.5rem"; - - "theme.bar.buttons.battery.background" = background; - "theme.bar.buttons.battery.border" = accent.base; - "theme.bar.buttons.battery.icon_background" = background; - "theme.bar.buttons.battery.icon" = accent.base; - "theme.bar.buttons.battery.text" = accent.base; - - "theme.bar.buttons.bluetooth.background" = background; - "theme.bar.buttons.bluetooth.border" = accent.base; - "theme.bar.buttons.bluetooth.icon_background" = background; - "theme.bar.buttons.bluetooth.icon" = accent.base; - "theme.bar.buttons.bluetooth.text" = accent.base; - - "theme.bar.buttons.borderColor" = accent.base; - - "theme.bar.buttons.clock.background" = background; - "theme.bar.buttons.clock.border" = accent.base; - "theme.bar.buttons.clock.icon_background" = background; - "theme.bar.buttons.clock.icon" = accent.base; - "theme.bar.buttons.clock.text" = accent.base; - - "theme.bar.buttons.dashboard.background" = background; - "theme.bar.buttons.dashboard.border" = accent.base; - "theme.bar.buttons.dashboard.icon" = accent.base; - "theme.bar.buttons.icon_background" = background; - - "theme.bar.buttons.icon" = accent.base; - - "theme.bar.buttons.media.background" = background; - "theme.bar.buttons.media.border" = accent.base; - "theme.bar.buttons.media.icon_background" = background; - "theme.bar.buttons.media.icon" = accent.base; - "theme.bar.buttons.media.text" = accent.base; - - "theme.bar.buttons.modules.cava.background" = background; - "theme.bar.buttons.modules.cava.border" = accent.base; - "theme.bar.buttons.modules.cava.icon_background" = background; - "theme.bar.buttons.modules.cava.icon" = accent.base; - "theme.bar.buttons.modules.cava.text" = accent.base; - - "theme.bar.buttons.modules.cpu.background" = background; - "theme.bar.buttons.modules.cpu.border" = accent.base; - "theme.bar.buttons.modules.cpu.icon_background" = background; - "theme.bar.buttons.modules.cpu.icon" = accent.base; - "theme.bar.buttons.modules.cpu.text" = accent.base; - - "theme.bar.buttons.modules.cpuTemp.background" = background; - "theme.bar.buttons.modules.cpuTemp.border" = accent.base; - "theme.bar.buttons.modules.cpuTemp.icon_background" = background; - "theme.bar.buttons.modules.cpuTemp.icon" = accent.base; - "theme.bar.buttons.modules.cpuTemp.text" = accent.base; - - "theme.bar.buttons.modules.hypridle.background" = background; - "theme.bar.buttons.modules.hypridle.border" = accent.base; - "theme.bar.buttons.modules.hypridle.icon_background" = background; - "theme.bar.buttons.modules.hypridle.icon" = accent.base; - "theme.bar.buttons.modules.hypridle.text" = accent.base; - - "theme.bar.buttons.modules.hyprsunset.background" = background; - "theme.bar.buttons.modules.hyprsunset.border" = accent.base; - "theme.bar.buttons.modules.hyprsunset.icon_background" = background; - "theme.bar.buttons.modules.hyprsunset.icon" = accent.base; - "theme.bar.buttons.modules.hyprsunset.text" = accent.base; - - "theme.bar.buttons.modules.kbLayout.background" = background; - "theme.bar.buttons.modules.kbLayout.border" = accent.base; - "theme.bar.buttons.modules.kbLayout.icon_background" = background; - "theme.bar.buttons.modules.kbLayout.icon" = accent.base; - "theme.bar.buttons.modules.kbLayout.text" = accent.base; - - "theme.bar.buttons.modules.microphone.background" = background; - "theme.bar.buttons.modules.microphone.border" = accent.base; - "theme.bar.buttons.modules.microphone.icon_background" = background; - "theme.bar.buttons.modules.microphone.icon" = accent.base; - "theme.bar.buttons.modules.microphone.text" = accent.base; - - "theme.bar.buttons.modules.netstat.background" = background; - "theme.bar.buttons.modules.netstat.border" = accent.base; - "theme.bar.buttons.modules.netstat.icon_background" = background; - "theme.bar.buttons.modules.netstat.icon" = accent.base; - "theme.bar.buttons.modules.netstat.text" = accent.base; - - "theme.bar.buttons.modules.power.background" = background; - "theme.bar.buttons.modules.power.border" = accent.base; - "theme.bar.buttons.modules.power.icon_background" = background; - "theme.bar.buttons.modules.power.icon" = accent.base; - - "theme.bar.buttons.modules.ram.background" = background; - "theme.bar.buttons.modules.ram.border" = accent.base; - "theme.bar.buttons.modules.ram.icon_background" = background; - "theme.bar.buttons.modules.ram.icon" = accent.base; - "theme.bar.buttons.modules.ram.text" = accent.base; - - "theme.bar.buttons.modules.storage.background" = background; - "theme.bar.buttons.modules.storage.border" = accent.base; - "theme.bar.buttons.modules.storage.icon_background" = background; - "theme.bar.buttons.modules.storage.icon" = accent.base; - "theme.bar.buttons.modules.storage.text" = accent.base; - - "theme.bar.buttons.modules.submap.background" = background; - "theme.bar.buttons.modules.submap.border" = accent.base; - "theme.bar.buttons.modules.submap.icon_background" = background; - "theme.bar.buttons.modules.submap.icon" = accent.base; - "theme.bar.buttons.modules.submap.text" = special.base; - - "theme.bar.buttons.modules.updates.background" = background; - "theme.bar.buttons.modules.updates.border" = accent.base; - "theme.bar.buttons.modules.updates.icon_background" = background; - "theme.bar.buttons.modules.updates.icon" = accent.base; - "theme.bar.buttons.modules.updates.text" = accent.base; - - "theme.bar.buttons.modules.weather.background" = background; - "theme.bar.buttons.modules.weather.border" = accent.base; - "theme.bar.buttons.modules.weather.icon_background" = background; - "theme.bar.buttons.modules.weather.icon" = accent.base; - "theme.bar.buttons.modules.weather.text" = accent.base; - - "theme.bar.buttons.modules.worldclock.background" = background; - "theme.bar.buttons.modules.worldclock.border" = accent.base; - "theme.bar.buttons.modules.worldclock.icon_background" = background; - "theme.bar.buttons.modules.worldclock.icon" = accent.base; - "theme.bar.buttons.modules.worldclock.text" = accent.base; - "theme.bar.buttons.monochrome" = false; - - "theme.bar.buttons.network.background" = background; - "theme.bar.buttons.network.border" = accent.base; - "theme.bar.buttons.network.icon_background" = background; - "theme.bar.buttons.network.icon" = accent.base; - "theme.bar.buttons.network.text" = accent.base; - - "theme.bar.buttons.notifications.background" = background; - "theme.bar.buttons.notifications.border" = accent.base; - "theme.bar.buttons.notifications.icon_background" = background; - "theme.bar.buttons.notifications.icon" = accent.base; - "theme.bar.buttons.notifications.total" = accent.base; - - "theme.bar.buttons.opacity" = t; - - "theme.bar.buttons.separator.color" = accent.base; - - "theme.bar.buttons.style" = "default"; - - "theme.bar.buttons.systray.background" = background; - "theme.bar.buttons.systray.border" = accent.base; - "theme.bar.buttons.systray.customIcon" = accent.base; - - "theme.bar.buttons.text" = accent.base; - - "theme.bar.buttons.volume.background" = background; - "theme.bar.buttons.volume.border" = accent.base; - "theme.bar.buttons.volume.icon_background" = background; - "theme.bar.buttons.volume.icon" = accent.base; - "theme.bar.buttons.volume.text" = accent.base; - - "theme.bar.buttons.windowtitle.background" = background; - "theme.bar.buttons.windowtitle.border" = secondary.base; - "theme.bar.buttons.windowtitle.icon_background" = background; - "theme.bar.buttons.windowtitle.icon" = secondary.base; - "theme.bar.buttons.windowtitle.text" = secondary.base; - - "theme.bar.buttons.workspaces.active" = accent.bright; - "theme.bar.buttons.workspaces.available" = accent.base; - "theme.bar.buttons.workspaces.background" = background; - "theme.bar.buttons.workspaces.border" = accent.base; - "theme.bar.buttons.workspaces.hover" = foreground; - "theme.bar.buttons.workspaces.numbered_active_highlighted_text_color" = accent.base; - "theme.bar.buttons.workspaces.numbered_active_highlight_padding" = "0.2em"; - "theme.bar.buttons.workspaces.numbered_active_underline_color" = accent.bright; - "theme.bar.buttons.workspaces.numbered_inactive_padding" = "0.2em"; - "theme.bar.buttons.workspaces.occupied" = secondary.base; - "theme.bar.buttons.workspaces.pill.width" = "4em"; - "theme.bar.buttons.workspaces.smartHighlight" = true; - "theme.bar.buttons.y_margins" = "0em"; - - "theme.bar.location" = "bottom"; - - "theme.bar.menus.menu.battery.background.color" = background; - "theme.bar.menus.menu.battery.border.color" = accent.base; - "theme.bar.menus.menu.battery.card.color" = accent.dark; - "theme.bar.menus.menu.battery.icons.active" = accent.base; - "theme.bar.menus.menu.battery.icons.passive" = accent.base; - "theme.bar.menus.menu.battery.label.color" = accent.base; - "theme.bar.menus.menu.battery.listitems.active" = accent.base; - "theme.bar.menus.menu.battery.listitems.passive" = accent.base; - "theme.bar.menus.menu.battery.slider.background" = background; - "theme.bar.menus.menu.battery.slider.backgroundhover" = background; - "theme.bar.menus.menu.battery.slider.primary" = accent.base; - "theme.bar.menus.menu.battery.slider.puck" = accent.base; - "theme.bar.menus.menu.battery.text" = foreground; - - "theme.bar.menus.menu.bluetooth.background.color" = background; - "theme.bar.menus.menu.bluetooth.border.color" = accent.base; - "theme.bar.menus.menu.bluetooth.card.color" = accent.dark; - "theme.bar.menus.menu.bluetooth.iconbutton.active" = accent.base; - "theme.bar.menus.menu.bluetooth.iconbutton.passive" = accent.base; - "theme.bar.menus.menu.bluetooth.icons.active" = accent.base; - "theme.bar.menus.menu.bluetooth.icons.passive" = accent.base; - "theme.bar.menus.menu.bluetooth.label.color" = accent.base; - "theme.bar.menus.menu.bluetooth.listitems.active" = accent.base; - "theme.bar.menus.menu.bluetooth.listitems.passive" = accent.base; - "theme.bar.menus.menu.bluetooth.scroller.color" = accent.base; - "theme.bar.menus.menu.bluetooth.status" = accent.base; - "theme.bar.menus.menu.bluetooth.switch.disabled" = accent.base; - "theme.bar.menus.menu.bluetooth.switch_divider" = accent.base; - "theme.bar.menus.menu.bluetooth.switch.enabled" = accent.base; - "theme.bar.menus.menu.bluetooth.switch.puck" = accent.base; - "theme.bar.menus.menu.bluetooth.text" = foreground; - - "theme.bar.menus.menu.clock.background.color" = background; - "theme.bar.menus.menu.clock.border.color" = accent.base; - "theme.bar.menus.menu.clock.calendar.contextdays" = foreground; - "theme.bar.menus.menu.clock.calendar.currentday" = accent.base; - "theme.bar.menus.menu.clock.calendar.days" = accent.base; - "theme.bar.menus.menu.clock.calendar.paginator" = accent.base; - "theme.bar.menus.menu.clock.calendar.weekdays" = accent.base; - "theme.bar.menus.menu.clock.calendar.yearmonth" = accent.base; - "theme.bar.menus.menu.clock.card.color" = accent.dark; - "theme.bar.menus.menu.clock.text" = foreground; - "theme.bar.menus.menu.clock.time.time" = accent.base; - "theme.bar.menus.menu.clock.time.timeperiod" = accent.base; - "theme.bar.menus.menu.clock.weather.hourly.icon" = accent.base; - "theme.bar.menus.menu.clock.weather.hourly.temperature" = accent.base; - "theme.bar.menus.menu.clock.weather.hourly.time" = accent.base; - "theme.bar.menus.menu.clock.weather.icon" = accent.base; - "theme.bar.menus.menu.clock.weather.stats" = accent.base; - "theme.bar.menus.menu.clock.weather.status" = accent.base; - "theme.bar.menus.menu.clock.weather.temperature" = accent.base; - "theme.bar.menus.menu.clock.weather.thermometer.cold" = accent.base; - "theme.bar.menus.menu.clock.weather.thermometer.extremelycold" = accent.base; - "theme.bar.menus.menu.clock.weather.thermometer.extremelyhot" = accent.base; - "theme.bar.menus.menu.clock.weather.thermometer.hot" = accent.base; - "theme.bar.menus.menu.clock.weather.thermometer.moderate" = accent.base; - - "theme.bar.menus.menu.dashboard.background.color" = background; - "theme.bar.menus.menu.dashboard.border.color" = accent.base; - "theme.bar.menus.menu.dashboard.card.color" = accent.dark; - - "theme.bar.menus.menu.dashboard.controls.bluetooth.background" = background; - "theme.bar.menus.menu.dashboard.controls.bluetooth.text" = foreground; - "theme.bar.menus.menu.dashboard.controls.disabled" = accent.base; - "theme.bar.menus.menu.dashboard.controls.input.background" = background; - "theme.bar.menus.menu.dashboard.controls.input.text" = foreground; - "theme.bar.menus.menu.dashboard.controls.notifications.background" = background; - "theme.bar.menus.menu.dashboard.controls.notifications.text" = foreground; - "theme.bar.menus.menu.dashboard.controls.volume.background" = background; - "theme.bar.menus.menu.dashboard.controls.volume.text" = foreground; - "theme.bar.menus.menu.dashboard.controls.wifi.background" = background; - "theme.bar.menus.menu.dashboard.controls.wifi.text" = foreground; - - "theme.bar.menus.menu.dashboard.directories.left.bottom.color" = accent.base; - "theme.bar.menus.menu.dashboard.directories.left.middle.color" = accent.base; - "theme.bar.menus.menu.dashboard.directories.left.top.color" = accent.base; - "theme.bar.menus.menu.dashboard.directories.right.bottom.color" = accent.base; - "theme.bar.menus.menu.dashboard.directories.right.middle.color" = accent.base; - "theme.bar.menus.menu.dashboard.directories.right.top.color" = accent.base; - - "theme.bar.menus.menu.dashboard.monitors.bar_background" = background; - "theme.bar.menus.menu.dashboard.monitors.cpu.bar" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.cpu.icon" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.cpu.label" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.disk.bar" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.disk.icon" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.disk.label" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.gpu.bar" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.gpu.icon" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.gpu.label" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.ram.bar" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.ram.icon" = accent.base; - "theme.bar.menus.menu.dashboard.monitors.ram.label" = accent.base; - - "theme.bar.menus.menu.dashboard.powermenu.confirmation.background" = background; - "theme.bar.menus.menu.dashboard.powermenu.confirmation.body" = accent.base; - "theme.bar.menus.menu.dashboard.powermenu.confirmation.border" = accent.base; - "theme.bar.menus.menu.dashboard.powermenu.confirmation.button_text" = foreground; - "theme.bar.menus.menu.dashboard.powermenu.confirmation.card" = accent.dark; - "theme.bar.menus.menu.dashboard.powermenu.confirmation.confirm" = accent.base; - "theme.bar.menus.menu.dashboard.powermenu.confirmation.deny" = accent.base; - "theme.bar.menus.menu.dashboard.powermenu.confirmation.label" = accent.base; - "theme.bar.menus.menu.dashboard.powermenu.logout" = accent.base; - "theme.bar.menus.menu.dashboard.powermenu.restart" = accent.base; - "theme.bar.menus.menu.dashboard.powermenu.shutdown" = accent.base; - "theme.bar.menus.menu.dashboard.powermenu.sleep" = accent.base; - "theme.bar.menus.menu.dashboard.profile.name" = accent.base; - "theme.bar.menus.menu.dashboard.shortcuts.background" = background; - "theme.bar.menus.menu.dashboard.shortcuts.recording" = accent.base; - "theme.bar.menus.menu.dashboard.shortcuts.text" = foreground; - - "theme.bar.menus.menu.media.album" = accent.base; - "theme.bar.menus.menu.media.artist" = accent.base; - "theme.bar.menus.menu.media.background.color" = "#000000"; - "theme.bar.menus.menu.media.border.color" = accent.base; - "theme.bar.menus.menu.media.buttons.background" = background; - "theme.bar.menus.menu.media.buttons.enabled" = accent.base; - "theme.bar.menus.menu.media.buttons.inactive" = accent.base; - "theme.bar.menus.menu.media.buttons.text" = foreground; - "theme.bar.menus.menu.media.card.color" = accent.dark; - "theme.bar.menus.menu.media.card.tint" = accent.dark; - "theme.bar.menus.menu.media.slider.background" = accent.dark; - "theme.bar.menus.menu.media.slider.backgroundhover" = secondary.dark; - "theme.bar.menus.menu.media.slider.primary" = accent.base; - "theme.bar.menus.menu.media.slider.puck" = accent.bright; - "theme.bar.menus.menu.media.song" = accent.base; - "theme.bar.menus.menu.media.timestamp" = accent.base; - - "theme.bar.menus.menu.network.background.color" = background; - "theme.bar.menus.menu.network.border.color" = accent.base; - "theme.bar.menus.menu.network.card.color" = accent.dark; - "theme.bar.menus.menu.network.iconbuttons.active" = accent.base; - "theme.bar.menus.menu.network.iconbuttons.passive" = accent.base; - "theme.bar.menus.menu.network.icons.active" = accent.base; - "theme.bar.menus.menu.network.icons.passive" = accent.base; - "theme.bar.menus.menu.network.label.color" = accent.base; - "theme.bar.menus.menu.network.listitems.active" = accent.base; - "theme.bar.menus.menu.network.listitems.passive" = accent.base; - "theme.bar.menus.menu.network.scroller.color" = accent.base; - "theme.bar.menus.menu.network.status.color" = accent.base; - "theme.bar.menus.menu.network.switch.disabled" = accent.base; - "theme.bar.menus.menu.network.switch.enabled" = accent.base; - "theme.bar.menus.menu.network.switch.puck" = accent.base; - "theme.bar.menus.menu.network.text" = foreground; - - "theme.bar.menus.menu.notifications.background" = background; - "theme.bar.menus.menu.notifications.border" = accent.base; - "theme.bar.menus.menu.notifications.card" = accent.dark; - "theme.bar.menus.menu.notifications.clear" = accent.base; - "theme.bar.menus.menu.notifications.label" = accent.base; - "theme.bar.menus.menu.notifications.no_notifications_label" = accent.base; - "theme.bar.menus.menu.notifications.pager.background" = background; - "theme.bar.menus.menu.notifications.pager.button" = accent.dark; - "theme.bar.menus.menu.notifications.pager.label" = accent.base; - "theme.bar.menus.menu.notifications.scrollbar.color" = accent.base; - "theme.bar.menus.menu.notifications.switch.disabled" = accent.base; - "theme.bar.menus.menu.notifications.switch_divider" = accent.base; - "theme.bar.menus.menu.notifications.switch.enabled" = accent.base; - "theme.bar.menus.menu.notifications.switch.puck" = accent.base; - - - "theme.bar.menus.menu.power.background.color" = background; - "theme.bar.menus.menu.power.border.color" = accent.base; - - "theme.bar.menus.menu.power.buttons.logout.background" = background; - "theme.bar.menus.menu.power.buttons.logout.icon_background" = background; - "theme.bar.menus.menu.power.buttons.logout.icon" = accent.base; - "theme.bar.menus.menu.power.buttons.logout.text" = foreground; - - "theme.bar.menus.menu.power.buttons.restart.background" = background; - "theme.bar.menus.menu.power.buttons.restart.icon_background" = background; - "theme.bar.menus.menu.power.buttons.restart.icon" = accent.base; - "theme.bar.menus.menu.power.buttons.restart.text" = foreground; - - "theme.bar.menus.menu.power.buttons.shutdown.background" = background; - "theme.bar.menus.menu.power.buttons.shutdown.icon_background" = background; - "theme.bar.menus.menu.power.buttons.shutdown.icon" = accent.base; - "theme.bar.menus.menu.power.buttons.shutdown.text" = foreground; - - "theme.bar.menus.menu.power.buttons.sleep.background" = background; - "theme.bar.menus.menu.power.buttons.sleep.icon_background" = background; - "theme.bar.menus.menu.power.buttons.sleep.icon" = accent.base; - "theme.bar.menus.menu.power.buttons.sleep.text" = foreground; - - - "theme.bar.menus.menu.systray.dropdownmenu.background" = background; - "theme.bar.menus.menu.systray.dropdownmenu.divider" = accent.base; - "theme.bar.menus.menu.systray.dropdownmenu.text" = foreground; - - "theme.bar.menus.menu.volume.audio_slider.background" = background; - "theme.bar.menus.menu.volume.audio_slider.backgroundhover" = background; - "theme.bar.menus.menu.volume.audio_slider.primary" = accent.base; - "theme.bar.menus.menu.volume.audio_slider.puck" = accent.base; - "theme.bar.menus.menu.volume.background.color" = background; - "theme.bar.menus.menu.volume.border.color" = accent.base; - "theme.bar.menus.menu.volume.card.color" = accent.dark; - "theme.bar.menus.menu.volume.iconbutton.active" = accent.base; - "theme.bar.menus.menu.volume.iconbutton.passive" = accent.base; - "theme.bar.menus.menu.volume.input_slider.background" = background; - "theme.bar.menus.menu.volume.input_slider.backgroundhover" = background; - "theme.bar.menus.menu.volume.input_slider.primary" = accent.base; - "theme.bar.menus.menu.volume.input_slider.puck" = accent.base; - "theme.bar.menus.menu.volume.label.color" = accent.base; - "theme.bar.menus.menu.volume.listitems.active" = accent.base; - "theme.bar.menus.menu.volume.listitems.passive" = accent.base; - "theme.bar.menus.menu.volume.text" = foreground; - - "theme.bar.menus.monochrome" = false; - - "theme.bar.opacity" = t; - "theme.bar.outer_spacing" = "0em"; - "theme.bar.transparent" = false; - - "theme.font.name" = rice.font.code.name; - "theme.font.size" = "12px"; - - "theme.notification.actions.background" = background; - "theme.notification.actions.text" = foreground; - "theme.notification.background" = background; - "theme.notification.border" = accent.base; - "theme.notification.close_button.background" = accent.dark; - "theme.notification.close_button.label" = accent.base; - "theme.notification.label" = accent.base; - "theme.notification.labelicon" = accent.base; - "theme.notification.opacity" = 1.0; - "theme.notification.text" = foreground; - "theme.notification.time" = accent.base; - - "theme.osd.bar_color" = accent.base; - "theme.osd.bar_container" = accent.dark; - "theme.osd.bar_empty_color" = accent.dark; - "theme.osd.bar_overflow_color" = accent.base; - "theme.osd.border.color" = border; - "theme.osd.icon_container" = secondary.dark; - "theme.osd.icon" = secondary.bright; - "theme.osd.label" = accent.bright; - "theme.osd.opacity" = t; - }; - }; - }; } diff --git a/home-modules/bar/caldav-event.nix b/home-modules/bar/caldav-event.nix new file mode 100644 index 0000000..3228766 --- /dev/null +++ b/home-modules/bar/caldav-event.nix @@ -0,0 +1,5 @@ +{ pkgs, ... }@all: with all; { + sops.secrets = { + "nx2site/radicale/password" = { }; + }; +} diff --git a/home-modules/bar/cclock.nix b/home-modules/bar/cclock.nix new file mode 100644 index 0000000..2269be6 --- /dev/null +++ b/home-modules/bar/cclock.nix @@ -0,0 +1,133 @@ +{ pkgs, ... }@all: with all; { + home.packages = with pkgs; [ + + (pkgs.writeShellApplication { name = "cclock"; text = /*bash*/ '' + ord=$(date +"%e" | awk '{printf("%d%s\n", $1, ($1==11||$1==12||$1==13)?"th":((($1%10)==1)?"st":((($1%10)==2)?"nd":((($1%10)==3)?"rd":"th"))))}') + if [ $# -eq 0 ]; then + echo "󰃮${sep}$(date +'%A the')" "$ord" "of" "$(date +'%B')" " ${sep}$(date +'%R')" + elif [ "$1" = "--no-icons" ]; then + echo "$(date +'%A the')" "$ord" "of" "$(date +'%B')" "$(date +'%R')" + fi + '';}) + + (pkgs.writers.writePython3Bin "caldav_event" { + libraries = with pkgs.python3Packages; [ caldav ics pytz ]; + flakeIgnore = [ "E302" "E305" "E501" "E261" ]; + } /* python */ '' +import os +import json +from caldav import DAVClient +from datetime import datetime, timezone +from ics import Calendar +from pytz import UTC + +def get_password(password_file): + with open(password_file, "r") as file: + return file.read().strip() + +def datetime_converter(obj): + if isinstance(obj, datetime): + return obj.isoformat() + return obj + +def datetime_parser(dct): + for key, value in dct.items(): + if isinstance(value, str): + try: + dct[key] = datetime.fromisoformat(value) + except ValueError: + pass + return dct + +def load_cache(cache_file): + if os.path.exists(cache_file): + with open(cache_file, "r") as file: + return json.load(file, object_hook=datetime_parser) + return None + +def save_cache(cache_file, data): + with open(cache_file, "w") as file: + json.dump(data, file, default=datetime_converter, indent=4) + + +def get_ongoing_or_next_event(url, username, password): + now = datetime.now(timezone.utc) + + try: + client = DAVClient(url, username=username, password=password) + principal = client.principal() + calendars = principal.calendars() + + next_event_dict = { + 'event_name': "fake", + 'event_begin': datetime(9000, 1, 1, tzinfo=UTC), # in the year 9000 + 'event_end': datetime(9000, 1, 1, 8, tzinfo=UTC), + } + + for calendar in calendars: + for event in calendar.search(start=now): + calendar_parsed = Calendar(event.data) + for ics_event in calendar_parsed.events: + event_dict = {} + event_dict['event_name'] = ics_event.name or "(No Title)" + event_dict['event_begin'] = ics_event.begin.astimezone(timezone.utc) + event_dict['event_end'] = ics_event.end.astimezone(timezone.utc) + + if event_dict['event_begin'] <= now and now <= event_dict['event_end']: + return event_dict + elif event_dict['event_begin'] >= now and next_event_dict['event_begin'] > event_dict['event_begin']: + next_event_dict = event_dict + return next_event_dict + + except Exception as e: + print(f"Error accessing {url}: {e}") + return None + +def is_expired(event_dict: dict): + now = datetime.now(timezone.utc).timestamp() + event_end = event_dict['event_end'].timestamp() + return not (now <= event_end) + +if __name__ == "__main__": + password_file = "${config.sops.secrets."nx2site/radicale/password".path}" # Path to password file + cache_file = "/tmp/caldav_event_cache.json" # Path to cache file + url = "https://dav.${hyper.domain}/" + username = "nx2" + password = get_password(password_file) + now = datetime.now(timezone.utc).timestamp() + + event_dict = load_cache(cache_file) + + if (event_dict is None) or (is_expired(event_dict)): + event_dict = get_ongoing_or_next_event(url, username, password) + save_cache(cache_file, event_dict) + + if event_dict is None: # none were found + print("* zen *") + exit(0) + + event_start = event_dict['event_begin'].timestamp() + event_end = event_dict['event_end'].timestamp() + + if event_start <= now <= event_end: # is currently ongoing + action_string = "ends" + t = event_end - now # time_remaining + else: # is in the future + action_string = "starts" + t = event_start - now # time_remaining + + hours, rem = divmod(int(t), 3600) + minutes, _ = divmod(rem, 60) + hour_string = f"{hours} hour{'s ' if hours != 1 else ' '}" if hours > 0 else "" + minu_string = f"{minutes} minute{'s ' if minutes != 1 else ' '}" if minutes > 0 else "" + if hour_string == "" and minu_string == "": + time_string = "now" + elif hour_string == "" or minu_string == "": + time_string = "in " + hour_string + minu_string + else: + time_string = "in " + hour_string + "and " + minu_string + + print(f"{event_dict['event_name']} {action_string} {time_string}") +'') + ] +} diff --git a/home-modules/bar/hyprpanel.nix b/home-modules/bar/hyprpanel.nix new file mode 100644 index 0000000..d033a15 --- /dev/null +++ b/home-modules/bar/hyprpanel.nix @@ -0,0 +1,494 @@ +{ pkgs, ... }@all: with all; { + xdg.configFile = { + "hyprpanel/modules.scss".text = with rice.color; /* scss */ '' + @include styleModule('cmodule-cclock', ( + 'text-color': #${accent.base}, + /* 'icon-color': , */ + /* 'icon-background': , */ + /* 'label-background': #242438, */ + /* 'inner-spacing': 0.5em, */ + /* 'border-enabled': false, */ + /* 'border-color': #cba6f7, */ + /* 'icon-size': 1.2em */ + )); + @include styleModule('cmodule-caldav_event', ( + 'text-color': #${accent.base}, + )); + ''; + }; + programs.hyprpanel = { + enable = true; + package = pkgs.unstable.hyprpanel; + settings = with rice.color; let + t = builtins.toString (builtins.ceil (rice.transparency * 100)); + in { + "bar.layouts" = { + "*" = { + "left" = [ + "volume" + # "microphone" + # "cpu" + # "cputemp" + # "ram" + "battery" + # "bluetooth" + "network" + "windowtitle" + ]; + "middle" = [ "workspaces" ]; + "right" = [ + "submap" + "custom/caldav_event" + "media" + "custom/cclock" + "notifications" + "systray" + ]; + }; + }; + + "bar.bluetooth.label" = true; + + "bar.customModules.submap.enabledIcon" = "[󰧹]"; + "bar.customModules.submap.showSubmapName" = false; + "bar.customModules.submap.label" = false; + "bar.customModules.submap.icon" = true; + "bar.customModules.submap.disabledIcon" = ""; + + "bar.workspaces.applicationIconEmptyWorkspace" = ""; + "bar.workspaces.applicationIconOncePerWorkspace" = false; + "bar.workspaces.numbered_active_indicator" = "underline"; + "bar.workspaces.scroll_speed" = 1; + "bar.workspaces.showAllActive" = false; + "bar.workspaces.showApplicationIcons" = true; + "bar.workspaces.show_icons" = false; + "bar.workspaces.show_numbered" = false; + "bar.workspaces.showWsIcons" = true; + "bar.workspaces.spacing" = 1; + "bar.workspaces.workspaceMask" = true; + "bar.workspaces.workspaces" = 5; + + "theme.bar.background" = background; + "theme.bar.border.color" = accent.base; + "theme.bar.border_radius" = "0.2em"; + + "theme.bar.buttons.background" = background; + "theme.bar.buttons.background_opacity" = 0; + "theme.bar.buttons.spacing" = "0em"; + "theme.bar.buttons.padding_x" = "0.5rem"; + + "theme.bar.buttons.battery.background" = background; + "theme.bar.buttons.battery.border" = accent.base; + "theme.bar.buttons.battery.icon_background" = background; + "theme.bar.buttons.battery.icon" = accent.base; + "theme.bar.buttons.battery.text" = accent.base; + + "theme.bar.buttons.bluetooth.background" = background; + "theme.bar.buttons.bluetooth.border" = accent.base; + "theme.bar.buttons.bluetooth.icon_background" = background; + "theme.bar.buttons.bluetooth.icon" = accent.base; + "theme.bar.buttons.bluetooth.text" = accent.base; + + "theme.bar.buttons.borderColor" = accent.base; + + "theme.bar.buttons.clock.background" = background; + "theme.bar.buttons.clock.border" = accent.base; + "theme.bar.buttons.clock.icon_background" = background; + "theme.bar.buttons.clock.icon" = accent.base; + "theme.bar.buttons.clock.text" = accent.base; + + "theme.bar.buttons.dashboard.background" = background; + "theme.bar.buttons.dashboard.border" = accent.base; + "theme.bar.buttons.dashboard.icon" = accent.base; + "theme.bar.buttons.icon_background" = background; + + "theme.bar.buttons.icon" = accent.base; + + "theme.bar.buttons.media.background" = background; + "theme.bar.buttons.media.border" = accent.base; + "theme.bar.buttons.media.icon_background" = background; + "theme.bar.buttons.media.icon" = accent.base; + "theme.bar.buttons.media.text" = accent.base; + + "theme.bar.buttons.modules.cava.background" = background; + "theme.bar.buttons.modules.cava.border" = accent.base; + "theme.bar.buttons.modules.cava.icon_background" = background; + "theme.bar.buttons.modules.cava.icon" = accent.base; + "theme.bar.buttons.modules.cava.text" = accent.base; + + "theme.bar.buttons.modules.cpu.background" = background; + "theme.bar.buttons.modules.cpu.border" = accent.base; + "theme.bar.buttons.modules.cpu.icon_background" = background; + "theme.bar.buttons.modules.cpu.icon" = accent.base; + "theme.bar.buttons.modules.cpu.text" = accent.base; + + "theme.bar.buttons.modules.cpuTemp.background" = background; + "theme.bar.buttons.modules.cpuTemp.border" = accent.base; + "theme.bar.buttons.modules.cpuTemp.icon_background" = background; + "theme.bar.buttons.modules.cpuTemp.icon" = accent.base; + "theme.bar.buttons.modules.cpuTemp.text" = accent.base; + + "theme.bar.buttons.modules.hypridle.background" = background; + "theme.bar.buttons.modules.hypridle.border" = accent.base; + "theme.bar.buttons.modules.hypridle.icon_background" = background; + "theme.bar.buttons.modules.hypridle.icon" = accent.base; + "theme.bar.buttons.modules.hypridle.text" = accent.base; + + "theme.bar.buttons.modules.hyprsunset.background" = background; + "theme.bar.buttons.modules.hyprsunset.border" = accent.base; + "theme.bar.buttons.modules.hyprsunset.icon_background" = background; + "theme.bar.buttons.modules.hyprsunset.icon" = accent.base; + "theme.bar.buttons.modules.hyprsunset.text" = accent.base; + + "theme.bar.buttons.modules.kbLayout.background" = background; + "theme.bar.buttons.modules.kbLayout.border" = accent.base; + "theme.bar.buttons.modules.kbLayout.icon_background" = background; + "theme.bar.buttons.modules.kbLayout.icon" = accent.base; + "theme.bar.buttons.modules.kbLayout.text" = accent.base; + + "theme.bar.buttons.modules.microphone.background" = background; + "theme.bar.buttons.modules.microphone.border" = accent.base; + "theme.bar.buttons.modules.microphone.icon_background" = background; + "theme.bar.buttons.modules.microphone.icon" = accent.base; + "theme.bar.buttons.modules.microphone.text" = accent.base; + + "theme.bar.buttons.modules.netstat.background" = background; + "theme.bar.buttons.modules.netstat.border" = accent.base; + "theme.bar.buttons.modules.netstat.icon_background" = background; + "theme.bar.buttons.modules.netstat.icon" = accent.base; + "theme.bar.buttons.modules.netstat.text" = accent.base; + + "theme.bar.buttons.modules.power.background" = background; + "theme.bar.buttons.modules.power.border" = accent.base; + "theme.bar.buttons.modules.power.icon_background" = background; + "theme.bar.buttons.modules.power.icon" = accent.base; + + "theme.bar.buttons.modules.ram.background" = background; + "theme.bar.buttons.modules.ram.border" = accent.base; + "theme.bar.buttons.modules.ram.icon_background" = background; + "theme.bar.buttons.modules.ram.icon" = accent.base; + "theme.bar.buttons.modules.ram.text" = accent.base; + + "theme.bar.buttons.modules.storage.background" = background; + "theme.bar.buttons.modules.storage.border" = accent.base; + "theme.bar.buttons.modules.storage.icon_background" = background; + "theme.bar.buttons.modules.storage.icon" = accent.base; + "theme.bar.buttons.modules.storage.text" = accent.base; + + "theme.bar.buttons.modules.submap.background" = background; + "theme.bar.buttons.modules.submap.border" = accent.base; + "theme.bar.buttons.modules.submap.icon_background" = background; + "theme.bar.buttons.modules.submap.icon" = accent.base; + "theme.bar.buttons.modules.submap.text" = special.base; + + "theme.bar.buttons.modules.updates.background" = background; + "theme.bar.buttons.modules.updates.border" = accent.base; + "theme.bar.buttons.modules.updates.icon_background" = background; + "theme.bar.buttons.modules.updates.icon" = accent.base; + "theme.bar.buttons.modules.updates.text" = accent.base; + + "theme.bar.buttons.modules.weather.background" = background; + "theme.bar.buttons.modules.weather.border" = accent.base; + "theme.bar.buttons.modules.weather.icon_background" = background; + "theme.bar.buttons.modules.weather.icon" = accent.base; + "theme.bar.buttons.modules.weather.text" = accent.base; + + "theme.bar.buttons.modules.worldclock.background" = background; + "theme.bar.buttons.modules.worldclock.border" = accent.base; + "theme.bar.buttons.modules.worldclock.icon_background" = background; + "theme.bar.buttons.modules.worldclock.icon" = accent.base; + "theme.bar.buttons.modules.worldclock.text" = accent.base; + "theme.bar.buttons.monochrome" = false; + + "theme.bar.buttons.network.background" = background; + "theme.bar.buttons.network.border" = accent.base; + "theme.bar.buttons.network.icon_background" = background; + "theme.bar.buttons.network.icon" = accent.base; + "theme.bar.buttons.network.text" = accent.base; + + "theme.bar.buttons.notifications.background" = background; + "theme.bar.buttons.notifications.border" = accent.base; + "theme.bar.buttons.notifications.icon_background" = background; + "theme.bar.buttons.notifications.icon" = accent.base; + "theme.bar.buttons.notifications.total" = accent.base; + + "theme.bar.buttons.opacity" = t; + + "theme.bar.buttons.separator.color" = accent.base; + + "theme.bar.buttons.style" = "default"; + + "theme.bar.buttons.systray.background" = background; + "theme.bar.buttons.systray.border" = accent.base; + "theme.bar.buttons.systray.customIcon" = accent.base; + + "theme.bar.buttons.text" = accent.base; + + "theme.bar.buttons.volume.background" = background; + "theme.bar.buttons.volume.border" = accent.base; + "theme.bar.buttons.volume.icon_background" = background; + "theme.bar.buttons.volume.icon" = accent.base; + "theme.bar.buttons.volume.text" = accent.base; + + "theme.bar.buttons.windowtitle.background" = background; + "theme.bar.buttons.windowtitle.border" = secondary.base; + "theme.bar.buttons.windowtitle.icon_background" = background; + "theme.bar.buttons.windowtitle.icon" = secondary.base; + "theme.bar.buttons.windowtitle.text" = secondary.base; + + "theme.bar.buttons.workspaces.active" = accent.bright; + "theme.bar.buttons.workspaces.available" = accent.base; + "theme.bar.buttons.workspaces.background" = background; + "theme.bar.buttons.workspaces.border" = accent.base; + "theme.bar.buttons.workspaces.hover" = foreground; + "theme.bar.buttons.workspaces.numbered_active_highlighted_text_color" = accent.base; + "theme.bar.buttons.workspaces.numbered_active_highlight_padding" = "0.2em"; + "theme.bar.buttons.workspaces.numbered_active_underline_color" = accent.bright; + "theme.bar.buttons.workspaces.numbered_inactive_padding" = "0.2em"; + "theme.bar.buttons.workspaces.occupied" = secondary.base; + "theme.bar.buttons.workspaces.pill.width" = "4em"; + "theme.bar.buttons.workspaces.smartHighlight" = true; + "theme.bar.buttons.y_margins" = "0em"; + + "theme.bar.location" = "bottom"; + + "theme.bar.menus.menu.battery.background.color" = background; + "theme.bar.menus.menu.battery.border.color" = accent.base; + "theme.bar.menus.menu.battery.card.color" = accent.dark; + "theme.bar.menus.menu.battery.icons.active" = accent.base; + "theme.bar.menus.menu.battery.icons.passive" = accent.base; + "theme.bar.menus.menu.battery.label.color" = accent.base; + "theme.bar.menus.menu.battery.listitems.active" = accent.base; + "theme.bar.menus.menu.battery.listitems.passive" = accent.base; + "theme.bar.menus.menu.battery.slider.background" = background; + "theme.bar.menus.menu.battery.slider.backgroundhover" = background; + "theme.bar.menus.menu.battery.slider.primary" = accent.base; + "theme.bar.menus.menu.battery.slider.puck" = accent.base; + "theme.bar.menus.menu.battery.text" = foreground; + + "theme.bar.menus.menu.bluetooth.background.color" = background; + "theme.bar.menus.menu.bluetooth.border.color" = accent.base; + "theme.bar.menus.menu.bluetooth.card.color" = accent.dark; + "theme.bar.menus.menu.bluetooth.iconbutton.active" = accent.base; + "theme.bar.menus.menu.bluetooth.iconbutton.passive" = accent.base; + "theme.bar.menus.menu.bluetooth.icons.active" = accent.base; + "theme.bar.menus.menu.bluetooth.icons.passive" = accent.base; + "theme.bar.menus.menu.bluetooth.label.color" = accent.base; + "theme.bar.menus.menu.bluetooth.listitems.active" = accent.base; + "theme.bar.menus.menu.bluetooth.listitems.passive" = accent.base; + "theme.bar.menus.menu.bluetooth.scroller.color" = accent.base; + "theme.bar.menus.menu.bluetooth.status" = accent.base; + "theme.bar.menus.menu.bluetooth.switch.disabled" = accent.base; + "theme.bar.menus.menu.bluetooth.switch_divider" = accent.base; + "theme.bar.menus.menu.bluetooth.switch.enabled" = accent.base; + "theme.bar.menus.menu.bluetooth.switch.puck" = accent.base; + "theme.bar.menus.menu.bluetooth.text" = foreground; + + "theme.bar.menus.menu.clock.background.color" = background; + "theme.bar.menus.menu.clock.border.color" = accent.base; + "theme.bar.menus.menu.clock.calendar.contextdays" = foreground; + "theme.bar.menus.menu.clock.calendar.currentday" = accent.base; + "theme.bar.menus.menu.clock.calendar.days" = accent.base; + "theme.bar.menus.menu.clock.calendar.paginator" = accent.base; + "theme.bar.menus.menu.clock.calendar.weekdays" = accent.base; + "theme.bar.menus.menu.clock.calendar.yearmonth" = accent.base; + "theme.bar.menus.menu.clock.card.color" = accent.dark; + "theme.bar.menus.menu.clock.text" = foreground; + "theme.bar.menus.menu.clock.time.time" = accent.base; + "theme.bar.menus.menu.clock.time.timeperiod" = accent.base; + "theme.bar.menus.menu.clock.weather.hourly.icon" = accent.base; + "theme.bar.menus.menu.clock.weather.hourly.temperature" = accent.base; + "theme.bar.menus.menu.clock.weather.hourly.time" = accent.base; + "theme.bar.menus.menu.clock.weather.icon" = accent.base; + "theme.bar.menus.menu.clock.weather.stats" = accent.base; + "theme.bar.menus.menu.clock.weather.status" = accent.base; + "theme.bar.menus.menu.clock.weather.temperature" = accent.base; + "theme.bar.menus.menu.clock.weather.thermometer.cold" = accent.base; + "theme.bar.menus.menu.clock.weather.thermometer.extremelycold" = accent.base; + "theme.bar.menus.menu.clock.weather.thermometer.extremelyhot" = accent.base; + "theme.bar.menus.menu.clock.weather.thermometer.hot" = accent.base; + "theme.bar.menus.menu.clock.weather.thermometer.moderate" = accent.base; + + "theme.bar.menus.menu.dashboard.background.color" = background; + "theme.bar.menus.menu.dashboard.border.color" = accent.base; + "theme.bar.menus.menu.dashboard.card.color" = accent.dark; + + "theme.bar.menus.menu.dashboard.controls.bluetooth.background" = background; + "theme.bar.menus.menu.dashboard.controls.bluetooth.text" = foreground; + "theme.bar.menus.menu.dashboard.controls.disabled" = accent.base; + "theme.bar.menus.menu.dashboard.controls.input.background" = background; + "theme.bar.menus.menu.dashboard.controls.input.text" = foreground; + "theme.bar.menus.menu.dashboard.controls.notifications.background" = background; + "theme.bar.menus.menu.dashboard.controls.notifications.text" = foreground; + "theme.bar.menus.menu.dashboard.controls.volume.background" = background; + "theme.bar.menus.menu.dashboard.controls.volume.text" = foreground; + "theme.bar.menus.menu.dashboard.controls.wifi.background" = background; + "theme.bar.menus.menu.dashboard.controls.wifi.text" = foreground; + + "theme.bar.menus.menu.dashboard.directories.left.bottom.color" = accent.base; + "theme.bar.menus.menu.dashboard.directories.left.middle.color" = accent.base; + "theme.bar.menus.menu.dashboard.directories.left.top.color" = accent.base; + "theme.bar.menus.menu.dashboard.directories.right.bottom.color" = accent.base; + "theme.bar.menus.menu.dashboard.directories.right.middle.color" = accent.base; + "theme.bar.menus.menu.dashboard.directories.right.top.color" = accent.base; + + "theme.bar.menus.menu.dashboard.monitors.bar_background" = background; + "theme.bar.menus.menu.dashboard.monitors.cpu.bar" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.cpu.icon" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.cpu.label" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.disk.bar" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.disk.icon" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.disk.label" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.gpu.bar" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.gpu.icon" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.gpu.label" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.ram.bar" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.ram.icon" = accent.base; + "theme.bar.menus.menu.dashboard.monitors.ram.label" = accent.base; + + "theme.bar.menus.menu.dashboard.powermenu.confirmation.background" = background; + "theme.bar.menus.menu.dashboard.powermenu.confirmation.body" = accent.base; + "theme.bar.menus.menu.dashboard.powermenu.confirmation.border" = accent.base; + "theme.bar.menus.menu.dashboard.powermenu.confirmation.button_text" = foreground; + "theme.bar.menus.menu.dashboard.powermenu.confirmation.card" = accent.dark; + "theme.bar.menus.menu.dashboard.powermenu.confirmation.confirm" = accent.base; + "theme.bar.menus.menu.dashboard.powermenu.confirmation.deny" = accent.base; + "theme.bar.menus.menu.dashboard.powermenu.confirmation.label" = accent.base; + "theme.bar.menus.menu.dashboard.powermenu.logout" = accent.base; + "theme.bar.menus.menu.dashboard.powermenu.restart" = accent.base; + "theme.bar.menus.menu.dashboard.powermenu.shutdown" = accent.base; + "theme.bar.menus.menu.dashboard.powermenu.sleep" = accent.base; + "theme.bar.menus.menu.dashboard.profile.name" = accent.base; + "theme.bar.menus.menu.dashboard.shortcuts.background" = background; + "theme.bar.menus.menu.dashboard.shortcuts.recording" = accent.base; + "theme.bar.menus.menu.dashboard.shortcuts.text" = foreground; + + "theme.bar.menus.menu.media.album" = accent.base; + "theme.bar.menus.menu.media.artist" = accent.base; + "theme.bar.menus.menu.media.background.color" = "#000000"; + "theme.bar.menus.menu.media.border.color" = accent.base; + "theme.bar.menus.menu.media.buttons.background" = background; + "theme.bar.menus.menu.media.buttons.enabled" = accent.base; + "theme.bar.menus.menu.media.buttons.inactive" = accent.base; + "theme.bar.menus.menu.media.buttons.text" = foreground; + "theme.bar.menus.menu.media.card.color" = accent.dark; + "theme.bar.menus.menu.media.card.tint" = accent.dark; + "theme.bar.menus.menu.media.slider.background" = accent.dark; + "theme.bar.menus.menu.media.slider.backgroundhover" = secondary.dark; + "theme.bar.menus.menu.media.slider.primary" = accent.base; + "theme.bar.menus.menu.media.slider.puck" = accent.bright; + "theme.bar.menus.menu.media.song" = accent.base; + "theme.bar.menus.menu.media.timestamp" = accent.base; + + "theme.bar.menus.menu.network.background.color" = background; + "theme.bar.menus.menu.network.border.color" = accent.base; + "theme.bar.menus.menu.network.card.color" = accent.dark; + "theme.bar.menus.menu.network.iconbuttons.active" = accent.base; + "theme.bar.menus.menu.network.iconbuttons.passive" = accent.base; + "theme.bar.menus.menu.network.icons.active" = accent.base; + "theme.bar.menus.menu.network.icons.passive" = accent.base; + "theme.bar.menus.menu.network.label.color" = accent.base; + "theme.bar.menus.menu.network.listitems.active" = accent.base; + "theme.bar.menus.menu.network.listitems.passive" = accent.base; + "theme.bar.menus.menu.network.scroller.color" = accent.base; + "theme.bar.menus.menu.network.status.color" = accent.base; + "theme.bar.menus.menu.network.switch.disabled" = accent.base; + "theme.bar.menus.menu.network.switch.enabled" = accent.base; + "theme.bar.menus.menu.network.switch.puck" = accent.base; + "theme.bar.menus.menu.network.text" = foreground; + + "theme.bar.menus.menu.notifications.background" = background; + "theme.bar.menus.menu.notifications.border" = accent.base; + "theme.bar.menus.menu.notifications.card" = accent.dark; + "theme.bar.menus.menu.notifications.clear" = accent.base; + "theme.bar.menus.menu.notifications.label" = accent.base; + "theme.bar.menus.menu.notifications.no_notifications_label" = accent.base; + "theme.bar.menus.menu.notifications.pager.background" = background; + "theme.bar.menus.menu.notifications.pager.button" = accent.dark; + "theme.bar.menus.menu.notifications.pager.label" = accent.base; + "theme.bar.menus.menu.notifications.scrollbar.color" = accent.base; + "theme.bar.menus.menu.notifications.switch.disabled" = accent.base; + "theme.bar.menus.menu.notifications.switch_divider" = accent.base; + "theme.bar.menus.menu.notifications.switch.enabled" = accent.base; + "theme.bar.menus.menu.notifications.switch.puck" = accent.base; + + + "theme.bar.menus.menu.power.background.color" = background; + "theme.bar.menus.menu.power.border.color" = accent.base; + + "theme.bar.menus.menu.power.buttons.logout.background" = background; + "theme.bar.menus.menu.power.buttons.logout.icon_background" = background; + "theme.bar.menus.menu.power.buttons.logout.icon" = accent.base; + "theme.bar.menus.menu.power.buttons.logout.text" = foreground; + + "theme.bar.menus.menu.power.buttons.restart.background" = background; + "theme.bar.menus.menu.power.buttons.restart.icon_background" = background; + "theme.bar.menus.menu.power.buttons.restart.icon" = accent.base; + "theme.bar.menus.menu.power.buttons.restart.text" = foreground; + + "theme.bar.menus.menu.power.buttons.shutdown.background" = background; + "theme.bar.menus.menu.power.buttons.shutdown.icon_background" = background; + "theme.bar.menus.menu.power.buttons.shutdown.icon" = accent.base; + "theme.bar.menus.menu.power.buttons.shutdown.text" = foreground; + + "theme.bar.menus.menu.power.buttons.sleep.background" = background; + "theme.bar.menus.menu.power.buttons.sleep.icon_background" = background; + "theme.bar.menus.menu.power.buttons.sleep.icon" = accent.base; + "theme.bar.menus.menu.power.buttons.sleep.text" = foreground; + + + "theme.bar.menus.menu.systray.dropdownmenu.background" = background; + "theme.bar.menus.menu.systray.dropdownmenu.divider" = accent.base; + "theme.bar.menus.menu.systray.dropdownmenu.text" = foreground; + + "theme.bar.menus.menu.volume.audio_slider.background" = background; + "theme.bar.menus.menu.volume.audio_slider.backgroundhover" = background; + "theme.bar.menus.menu.volume.audio_slider.primary" = accent.base; + "theme.bar.menus.menu.volume.audio_slider.puck" = accent.base; + "theme.bar.menus.menu.volume.background.color" = background; + "theme.bar.menus.menu.volume.border.color" = accent.base; + "theme.bar.menus.menu.volume.card.color" = accent.dark; + "theme.bar.menus.menu.volume.iconbutton.active" = accent.base; + "theme.bar.menus.menu.volume.iconbutton.passive" = accent.base; + "theme.bar.menus.menu.volume.input_slider.background" = background; + "theme.bar.menus.menu.volume.input_slider.backgroundhover" = background; + "theme.bar.menus.menu.volume.input_slider.primary" = accent.base; + "theme.bar.menus.menu.volume.input_slider.puck" = accent.base; + "theme.bar.menus.menu.volume.label.color" = accent.base; + "theme.bar.menus.menu.volume.listitems.active" = accent.base; + "theme.bar.menus.menu.volume.listitems.passive" = accent.base; + "theme.bar.menus.menu.volume.text" = foreground; + + "theme.bar.menus.monochrome" = false; + + "theme.bar.opacity" = t; + "theme.bar.outer_spacing" = "0em"; + "theme.bar.transparent" = false; + + "theme.font.name" = rice.font.code.name; + "theme.font.size" = "12px"; + + "theme.notification.actions.background" = background; + "theme.notification.actions.text" = foreground; + "theme.notification.background" = background; + "theme.notification.border" = accent.base; + "theme.notification.close_button.background" = accent.dark; + "theme.notification.close_button.label" = accent.base; + "theme.notification.label" = accent.base; + "theme.notification.labelicon" = accent.base; + "theme.notification.opacity" = 1.0; + "theme.notification.text" = foreground; + "theme.notification.time" = accent.base; + + "theme.osd.bar_color" = accent.base; + "theme.osd.bar_container" = accent.dark; + "theme.osd.bar_empty_color" = accent.dark; + "theme.osd.bar_overflow_color" = accent.base; + "theme.osd.border.color" = border; + "theme.osd.icon_container" = secondary.dark; + "theme.osd.icon" = secondary.bright; + "theme.osd.label" = accent.bright; + "theme.osd.opacity" = t; + }; + }; +} diff --git a/home-modules/bar/submap-indicator.nix b/home-modules/bar/submap-indicator.nix new file mode 100644 index 0000000..dad39dc --- /dev/null +++ b/home-modules/bar/submap-indicator.nix @@ -0,0 +1,38 @@ +{ pkgs, ... }@all: with all; { + home.packages = with pkgs; [ + + (pkgs.writeShellApplication { name = "submap_indicator"; text = /*bash*/ '' + print_help() { + echo "Usage: submap_indicator {set |unset}" + } + if [ $# -lt 1 ]; then + print_help; exit 1; + fi + case "$1" in + set) + # Check if there is a second argument for the 'set' operation + if [ $# -eq 2 ]; then + echo "$2" > /tmp/submap-indictor + pkill -RTMIN+8 waybar + pkill -RTMIN+8 hyprpanel + else + echo "Error: 'set' operation requires exactly one string argument." + print_help + exit 1 + fi + ;; + unset) + echo "" > /tmp/submap-indictor + pkill -RTMIN+8 waybar + pkill -RTMIN+8 hyprpanel + ;; + *) + echo "Error: Unknown command '$1'" + print_help + exit 1 + ;; + esac + exit 0 + '';}) + ] +} diff --git a/home-modules/bar/waybar.nix b/home-modules/bar/waybar.nix new file mode 100644 index 0000000..476b7f3 --- /dev/null +++ b/home-modules/bar/waybar.nix @@ -0,0 +1,163 @@ +{ pkgs, ... }@all: with all; { + programs.waybar = { + enable = false; + package = pkgs.waybar; + settings = { + bar = { + # height = 20; + layer = "top"; + position = "bottom"; + margin-top = 0; + # margin-left = rice.gap-size; + # margin-bottom = rice.gap-size; + # margin-right = rice.gap-size; + margin-left = 0; + margin-bottom = 0; + margin-right = 0; + spacing = 10; + fixed-center = true; + modules-left = [ + # "cpu" + # "memory" + "wireplumber" + "backlight" + "battery" + "network" + "hyprland/window" + ]; + modules-center = [ + "hyprland/workspaces" + ]; + modules-right = [ + "custom/mode" + "custom/caldav_event" + "custom/cclock" + "tray" + ]; + "hyprland/workspaces" = { + on-click = "activate"; + format = "{name}"; + all-outputs = false; + active-only = false; + }; + "hyprland/window" = { + # format = "${sep}{}"; + format = "{}"; + separate-outputs = true; + }; + "custom/cclock" = { + exec = "cclock"; + restart-interval = 60; + }; + "custom/caldav_event" = { + format = "󰃰${sep}{}"; + exec = "caldav_event"; + restart-interval = 60; + max-width = 60; + }; + "custom/mode" = { + exec = "cat /tmp/submap-indictor"; + interval = "once"; + signal = 8; + }; + + cpu = { + interval = 1; + format = "󰍛${sep}{}%"; + max-length = 10; + }; + memory = { + interval = 5; + format = "${sep}{avail:.0f}G free"; + }; + battery = { + interval = 60; + tooltip = false; + format = "{icon}${sep}{capacity}%"; + states = { + warning = 15; + critical = 5; + }; + format-icons = [ " " " " " " " " " " ]; + format-charging = "{icon}${sep}+{capacity}%"; + format-plugged = "{icon}${sep}P{capacity}%"; + format-full = "{icon}${sep}F{capacity}%"; + }; + backlight = { + device = "eDP-1"; + format = "{icon}${sep}{percent}%"; + format-icons = [ "" "" "" "" "" "" "" "" "" ]; + }; + network = { + format-wifi = "${sep}{essid}"; + format-ethernet = "󰈀${sep}Wired"; + format-disconnected = "󰌙${sep}Disconnected"; + }; + wireplumber = { + format = "󰕾${sep}{volume}%"; + format-muted = "󰝟${sep}--%"; + }; + }; + }; + style = with rice.color; let f = rice.lib.hex-to-rgb-comma-string; in /* css */ '' + * { + font-family: ${rice.font.code.name}; + font-size: 1em; + min-height: 0px; + margin: 0px; + padding: 0px; + } + + window#waybar { + background: rgba(${f background},${builtins.toString rice.transparency}); + } + + #clock, + #custom-cclock, + #custom-mode, + #custom-caldav-event, + #battery, + #cpu, + #tray, + #disk, + #backlight, + #network, + #wireplumber, + #memory, + #window, + #workspaces { + padding: 0px 3px; + margin-top: 0.3em; + border-radius: ${builtins.toString rice.rounding}px; + color: rgb(${f accent.bright}); + } + + #workspaces button { + color: rgb(${f accent.base}); + padding-left: 15px; + padding-right: 15px; + border-radius: ${builtins.toString rice.rounding}px; + } + #workspaces button.active { color: rgb(${f background}); background-color: rgb(${f accent.base}); } + #workspaces button:hover { color: rgb(${f tertiary.bright}); } + #workspaces button.urgent { background-color: rgba(${f magenta.base},${builtins.toString rice.transparency}); } + + #window, #custom-caldav_event { + font-family: ${rice.font.base.name}, ${rice.font.code.name}; + color: rgb(${f tertiary.bright}); + } + + #wireplumber.muted { color: rgb(${f tertiary.bright}); } + #wireplumber { padding-left: 10px; } + + #battery.warning:not(.charging) { color: rgb(${f green.base});; } + #battery.charging { color: rgb(${f green.base}); } + #battery.critical { + background: rgb(${f negative.base}); + color: rgb(${f foreground}); + } + + #custom-mode { color: rgb(${f red.base}); } + ''; + }; +}