From 8d4e5d1a24e4c667680ba5ec5f5ccef022808a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Dom=C3=ADnguez?= Date: Mon, 24 Mar 2025 12:59:04 -0400 Subject: [PATCH] add waybar configs --- .config/waybar/config | 233 ++++++++++++++++++++ .config/waybar/scripts/weather.py | 125 +++++++++++ .config/waybar/style.css | 350 ++++++++++++++++++++++++++++++ 3 files changed, 708 insertions(+) create mode 100644 .config/waybar/config create mode 100755 .config/waybar/scripts/weather.py create mode 100644 .config/waybar/style.css diff --git a/.config/waybar/config b/.config/waybar/config new file mode 100644 index 0000000..7e7d995 --- /dev/null +++ b/.config/waybar/config @@ -0,0 +1,233 @@ +[{ + "output": "DP-1", + "layer": "top", + "modules-left": ["hyprland/workspaces", "hyprland/mode"], + "modules-center": ["hyprland/window"], + "modules-right": ["mpris"], + +"mpris": { + "format": "{player_icon} {dynamic}", + "format-paused": "{status_icon} {dynamic}", + "tooltip-format": "󰠃 {artist}:  {title} (󰀥 {album})", + "interval": 1, + "album-len": 0, + "player-icons": { + "default": "", + "mpv": "" + }, + "status-icons": { + "paused": "", + }, + "ignored-players": ["firefox"] + }, + "hyprland/window": { + "format": "{title} ", + "max-length": 60, + "icon": true, + "icon-size": 20, + "all-outputs" : true, + }, + "hyprland/workspaces": { + "format": "{icon}", + "on-click": "activate", + "format-icons": { + "1": "󰈹", + "2": "", + "3": "󰷈", + "4": "󱇤", + "5": "", + "6": "󰙵", + }, + "sort-by-number": true + }, + }, { + "output": "DP-2", + "layer": "top", + "modules-left": ["hyprland/mode"], + "modules-center": ["custom/gpu-usage", "cpu", "memory", "temperature", "network", "custom/vpn", "bluetooth", "clock", "custom/weather", "idle_inhibitor", "custom/pacman", "disk", "disk#disk2", "disk#disk3", "disk#disk4", "disk#disk5"], + /* "modules-right": ["tray", "custom/scratchpad-indicator", "pulseaudio",], */ + "modules-right": ["tray", "pulseaudio", "group/group-power"], + + "hyprland/mode": { + "format": " 󰹶 {}" + }, + "hyprland/workspaces": { + "format": "{icon}", + "on-click": "activate", + "format-icons": { + "7": "", + "8": "󰙵", + "9": "󰙵", + "10": "󰙵", + "11": "󰙵", + "12": "󰙵", + }, + "sort-by-number": true + }, + "custom/pacman": { + "format": "󰣇 {}", + "tooltip": true, + "tooltip-format": "Available updates", + "interval": 60, + "exec": "checkupdates | wc -l", + "exec-if": "exit 0", + "signal": 8 + }, + "group/group-power": { + "orientation": "inherit", + "drawer": { + "transition-duration": 500, + "children-class": "not-power", + "transition-left-to-right": false, + }, + "modules": [ + "custom/power", + "custom/lock", + "custom/reboot", + ] + }, + "custom/lock": { + "format": " 󰍁 ", + "tooltip": false, + "on-click": "hyprlock" + }, + "custom/reboot": { + "format": " 󰜉 ", + "tooltip": false, + "on-click": "shutdown -r now" + }, + "custom/power": { + "format": "  ", + "tooltip": false, + "on-click": "shutdown -h now" + }, + "network": { + "interface": "enp7s0", + "format": "{ifname}", + "interval": 1, + "format-wifi": "{essid} ({signalStrength}%) ", + "format-ethernet": "{ifname}", + "format-disconnected": "{ifname}", + "max-length": 50, + "tooltip-format": "speed:  {bandwidthDownBytes} /  {bandwidthUpBytes}", + "on-click": "kitty --class nmnet --single-instance -e nmtui", + "on-click-right": "nm-connection-editor" + + }, + "idle_inhibitor": { + "format": "{icon}", + "format-icons": { + "activated": "", + "deactivated": "" + }, + "on-click": "toggleRemote" + }, + "tray": { + "icon-size": 20, + "spacing": 6 + }, + "clock": { + "format": "󱑏 {:%I:%M:%OS}", + "interval": 1, + "tooltip-format": " {:%d/%m/%y}", + // "format-alt": "{:%Y-%m-%d}" + "on-click": "gsimplecal" + }, + "cpu": { + "interval": 10, + "format": "{icon} {usage}%", + "format-icons": [""] + }, + "memory": { + "format": "{icon} {percentage}%", + "format-icons": [""] + }, + "temperature": { + // "thermal-zone": 2, + "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input", + "critical-threshold": 80, + "format-critical": " {temperatureC}°C", + "format": " {temperatureC}°C", + "tooltip": false, + }, + "disk": { + "interval": 30, + "format": "󰋊 /: {percentage_used}%", + "path": "/" + }, + "disk#disk2": { + "interval": 30, + "format": "󰋊 M2: {percentage_used}%", + "path": "/mnt/M2" + }, + "disk#disk3": { + "interval": 30, + "format": "󰋊 SSD: {percentage_used}%", + "path": "/mnt/SSD" + }, + "disk#disk4": { + "interval": 30, + "format": "󰋊 Games: {percentage_used}%", + "path": "/media/Games" + }, + "disk#disk5": { + "interval": 30, + "format": "󰋊 Backups: {percentage_used}%", + "path": "/mnt/Backups" + },"pulseaudio": { + "format": "{volume}% {icon}", + "format-bluetooth": "{volume}% {icon} ", + "format-bluetooth-muted": "{icon} ", + "format-muted": "0% {icon}", + "format-source": "{volume}% ", + "format-source-muted": "", + "format-icons": { + "headphone": "󰋋", + "headphone-muted": "󰟎", + "hands-free": "", + "headset": "󰋋", + "headset-muted": "󰟎", + "phone": "", + "portable": "", + "car": "", + "default": ["", "󰖀", "󰕾", ""] + }, + "on-click": "pavucontrol" + }, + "bluetooth": { + "format": " {status}", + "format-connected": " on", + "format-connected-battery": " on", + "on-click": "blueman-manager", + // "format-device-preference": [ "device1", "device2" ], // preference list deciding the displayed device + "tooltip-format": "{controller_alias}\t{controller_address}\n\n{num_connections} connected", + "tooltip-format-connected": "{controller_alias}\t{controller_address}\n\n{num_connections} connected\n\n{device_enumerate}", + "tooltip-format-enumerate-connected": "{device_alias}\t{device_address}", + "tooltip-format-enumerate-connected-battery": "{device_alias}\t{device_address}\t{device_battery_percentage}%" + }, +"custom/vpn": { + "format": " VPN", + "tooltip": true, + "tooltip-format": "Connected", + "exec": "echo '{\"class\": \"connected\"}'", + "exec-if": "test -d /proc/sys/net/ipv4/conf/tun0", + "return-type": "json", + "on-click": "exec kitty --class nmnet --single-instance -e nmtui", + "interval": 5 +}, + "custom/weather": { + "exec": "python ~/.config/waybar/scripts/weather.py", + "restart-interval": 300, + "format": "{}", + "return-type": "json", + "on-click": "xdg-open https://weather.com/en-IN/weather/today/l/e42bb25a58c2e689ec85e632d82e69d7e46c82defb9ad7a5551b6c3a70fbc282" + // "format-alt": "{alt}", +}, + "custom/gpu-usage": { + "exec": "cat /sys/class/hwmon/hwmon2/device/gpu_busy_percent", + "format": "󰍹 {}%", + "return-type": "", + "interval": 1, + "tooltip": false + }, +}] diff --git a/.config/waybar/scripts/weather.py b/.config/waybar/scripts/weather.py new file mode 100755 index 0000000..41a532d --- /dev/null +++ b/.config/waybar/scripts/weather.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python + +import subprocess +from pyquery import PyQuery # install using `pip install pyquery` +import json + +# weather icons +weather_icons = { + "sunnyDay": "󰖨", + "clearNight": "󰖔", + "cloudyFoggyDay": "󰖕", + "cloudyFoggyNight": "", + "rainyDay": "󰼳", + "rainyNight": "", + "snowyIcyDay": "󰼴", + "snowyIcyNight": "󰖘", + "severe": "󰢘", + "default": "", +} + +# get location_id +# to get your own location_id, go to https://weather.com & search your location. +# once you choose your location, you can see the location_id in the URL(64 chars long hex string) +# like this: https://weather.com/en-IN/weather/today/l/c3e96d6cc4965fc54f88296b54449571c4107c73b9638c16aafc83575b4ddf2e +location_id = "e42bb25a58c2e689ec85e632d82e69d7e46c82defb9ad7a5551b6c3a70fbc282" # TODO +# location_id = "8139363e05edb302e2d8be35101e400084eadcecdfce5507e77d832ac0fa57ae" + +# priv_env_cmd = 'cat $PRIV_ENV_FILE | grep weather_location | cut -d "=" -f 2' +# location_id = subprocess.run( +# priv_env_cmd, shell=True, capture_output=True).stdout.decode('utf8').strip() + +# get html page +url_fetch = "https://weather.com/en-IN/weather/today/l/" + location_id +html_data = PyQuery(url=url_fetch) + +# current temperature +temp = html_data("span[data-testid='TemperatureValue']").eq(0).text() +# print(temp) + +# current status phrase +status = html_data("div[data-testid='wxPhrase']").text() +status = f"{status[:16]}.." if len(status) > 17 else status +# print(status) + +# status code +status_code = html_data("#regionHeader").attr("class").split(" ")[2].split("-")[2] +# print(status_code) + +# status icon +icon = ( + weather_icons[status_code] + if status_code in weather_icons + else weather_icons["default"] +) +# print(icon) + +# temperature feels like +temp_feel = html_data( + "div[data-testid='FeelsLikeSection'] > span > span[data-testid='TemperatureValue']" +).text() +temp_feel_text = f"Feels like {temp_feel}C" +# print(temp_feel_text) + +# min-max temperature +temp_min = ( + html_data("div[data-testid='wxData'] > span[data-testid='TemperatureValue']") + .eq(0) + .text() +) +temp_max = ( + html_data("div[data-testid='wxData'] > span[data-testid='TemperatureValue']") + .eq(1) + .text() +) +temp_min_max = f" {temp_min}\t\t {temp_max}" +# print(temp_min_max) + +# wind speed +wind_speed = html_data("span[data-testid='Wind']").text().split("\n")[1] +wind_text = f" {wind_speed}" +# print(wind_text) + +# humidity +humidity = html_data("span[data-testid='PercentageValue']").text() +humidity_text = f" {humidity}" +# print(humidity_text) + +# visibility +visbility = html_data("span[data-testid='VisibilityValue']").text() +visbility_text = f" {visbility}" +# print(visbility_text) + +# air quality index +air_quality_index = html_data("text[data-testid='DonutChartValue']").text() +# print(air_quality_index) + +# hourly rain prediction +prediction = html_data("section[aria-label='Hourly Forecast']")( + "div[data-testid='SegmentPrecipPercentage'] > span" +).text() +prediction = prediction.replace("Chance of Rain", "") +prediction = f"\n\n  (hourly) {prediction}" if len(prediction) > 0 else prediction +# print(prediction) + +# tooltip text +tooltip_text = str.format( + "\t\t{}\t\t\n{}\n{}\n{}\n\n{}\n{}\n{}{}", + f'{temp}C 🇩🇴', + f"{icon}", + f"{status}", + f"{temp_feel_text}", + f"{temp_min_max}", + f"{wind_text}\t{humidity_text}", + f"{visbility_text}\tAQI {air_quality_index}", + f"{prediction}", +) + +# print waybar module data +out_data = { + "text": f"{icon} {temp}", + "alt": status, + "tooltip": tooltip_text, + "class": status_code, +} +print(json.dumps(out_data)) diff --git a/.config/waybar/style.css b/.config/waybar/style.css new file mode 100644 index 0000000..994308c --- /dev/null +++ b/.config/waybar/style.css @@ -0,0 +1,350 @@ +* { + border: none; + border-radius: 10; + font-family: "Droid Sans Font, Font Awesome, Roboto, FreeSans, FreeSerif" ; + font-size: 15px; + min-height: 10px; +} + +window#waybar { + background: transparent; +} + +window#waybar.hidden { + opacity: 0.2; +} + +#window { + margin-top: 6px; + padding-left: 10px; + padding-right: 10px; + border-radius: 10px; + transition: none; + color: transparent; + background: transparent; +} + +#mode { + color: #ff5555; +} + +#workspaces button { + margin-top: 6px; + margin-left: 8px; + padding-left: 8px; + padding-right: 8px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + background-color: transparent; +} +#workspaces button:hover { + box-shadow: inherit; + background-color: #282a36; +} + +#workspaces button.active { + background-color: #ff79c6; + color: #282a36; +} + + +#network { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} + +#pulseaudio { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #282a36; + background: #50fa7b; +} + +#bluetooth { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} + +#battery { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} + +#battery.charging, #battery.plugged { + color: #f8f8f2; + background-color: #282a36; +} + +#battery.critical:not(.charging) { + background-color: #282a36; + color: #f8f8f2; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +@keyframes blink { + to { + background-color: #282a36; + color: #f8f8f2; + } +} + +#backlight { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} +#clock { + margin-top: 6px; + margin-left: 6px; + padding-left: 8px; + padding-right: 3px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: transparent; + /*background: #1A1826;*/ +} + +#memory { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + margin-bottom: 0px; + padding-right: 10px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} +#cpu { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + margin-bottom: 0px; + padding-right: 10px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} + +#tray { + margin-top: 6px; + margin-left: 28px; + padding-left: 10px; + margin-bottom: 0px; + padding-right: 10px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #5d4185; +} + +#disk { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} + +#temperature { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} + +#idle_inhibitor { + margin-top: 6px; + margin-left: 1px; + padding-left: 1px; + padding-right: 6px; + margin-bottom: 0px; + border-radius: 10px; +} + +#idle_inhibitor.activated { + color: #50fa7b; +} + +#custom-vpn { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} + +#custom-weather { + margin-top: 6px; + margin-left: 3px; + padding-left: 3px; + padding-right: 6px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: transparent; +} + +#custom-weather.severe { + color: #ff5555; +} + +#custom-weather.sunnyDay { + color: #f1fa8c; +} + +#custom-weather.clearNight { + color: #bd93f9; +} + +#custom-weather.cloudyFoggyDay, #custom-weather.cloudyFoggyNight { + color: #9599b4; +} + +#custom-weather.rainyDay, #custom-weather.rainyNight { + color: #8be9fd; +} + +#custom-weather.showyIcyDay, #custom-weather.snowyIcyNight { + color: #8be9fd; +} + +#custom-weather.default { + color: #f8f8f2; +} + +#custom-gpu-usage { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #282a36; +} +#mpris { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 6px; + margin-right: 6px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #bd93f9; + background: #282a36; +} +#custom-scratchpad-indicator { + margin-top: 6px; + margin-left: 8px; + padding-left: 10px; + padding-right: 10px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f8f2; + background: #6272a4; +} +#custom-power { + margin-top: 6px; + margin-left: 8px; + padding-left: 7px; + padding-right: 7px; + margin-bottom: 0px; + margin-right: 6px; + border-radius: 10px; + transition: none; + color: #282A36; + background: #FF5555; +} +#custom-lock { + margin-top: 6px; + margin-left: 8px; + padding-left: 7px; + padding-right: 7px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #282A36; + background: #FFB86C; +} +#custom-reboot { + margin-top: 6px; + margin-left: 8px; + padding-left: 2px; + padding-right: 2px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #282A36; + background: #8BE9FD; +} +#custom-pacman { + margin-top: 6px; + margin-left: 2px; + padding-left: 2px; + padding-right: 5px; + margin-right: 5px; + margin-bottom: 0px; + border-radius: 10px; + transition: none; + color: #f8f2f2; + background: transparent; +} +