fixed more stuff with waybar

This commit is contained in:
opal
2024-06-03 23:17:19 -07:00
parent f5cbaf2c30
commit c8d671eaff
4 changed files with 34 additions and 19 deletions
+13 -12
View File
@@ -1,10 +1,10 @@
{ {
"layer": "top", "layer": "top",
"position": "top", "position": "top",
"height": 35, "height": 44,
"modules-left": ["sway/workspaces"], "modules-left": ["sway/workspaces"],
"modules-center": ["clock"], "modules-center": ["clock","custom/padd","custom/weather"],
"modules-right": ["custom/l_end","custom/music","custom/padd","custom/weather","custom/padd","pulseaudio", "custom/padd","network", "custom/padd","battery","custom/padd","custom/wlsunset","custom/padd", "tray","custom/power","custom/padd"], "modules-right": ["custom/l_end","custom/music","custom/padd","pulseaudio","custom/padd","network", "custom/padd","battery","custom/padd","custom/wlsunset","custom/padd", "tray","custom/power","custom/padd"],
"sway/workspaces": { "sway/workspaces": {
"disable-scroll": true, "disable-scroll": true,
"all-outputs": true, "all-outputs": true,
@@ -21,35 +21,36 @@
}, },
"clock": { "clock": {
"format": "{:  %H:%M  %A %B %d}", "format": "{:  %H:%M  %a %B %d}",
"tooltip-format": "<tt><big>{calendar}</big></tt>" "tooltip-format": "<tt><big>{calendar}</big></tt>"
}, },
"custom/music": { "custom/music": {
"exec": "~/.config/waybar/scripts/music.py", "exec": "~/.config/waybar/scripts/music.py",
"interval": 5, "interval": 3,
"tooltip": false "tooltip": false
}, },
"custom/weather": { "custom/weather": {
"exec": "~/.config/waybar/scripts/weather.py", "exec": "~/.config/waybar/scripts/weather.py",
"interval": 600, "interval": 600,
"tooltip": true "tooltip": false
}, },
"battery": { "battery": {
"interval": 30, "interval": 15,
"states": { "states": {
// "good": 95, // "good": 95,
"warning": 30, "warning": 30,
"critical": 15 "critical": 15
}, },
"full-at": "99", "full-at": "99",
"format": "󰁹 {capacity}%", "format": "<span font='Font Awesome 5 Free 11'>{icon}</span> {capacity}%",
"format-icons": ["󰁺","󰁻", "󰁼","󰁽", "󰁾", "󰁿", "󰂀", "󰂁", "󰂂", "󰁹"],
"format-good": "󰁹 {capacity}%", // An empty format will hide the module "format-good": "󰁹 {capacity}%", // An empty format will hide the module
"format-full": "󰁹 Full", "format-full": "󰁹",
"format-charging": "󰂄 {capacity}% " "format-charging": "󱐋{capacity}% "
}, },
"custom/wlsunset": { "custom/wlsunset": {
"format": "<span size='large'></span>", "format": "<span size='large'>{icon}</span>",
"format-icons": ["", ""], "format-icons": [""],
"on-click": "wlsunset -l 47.6 -L -122.3 -t 3000 -T 6500" "on-click": "wlsunset -l 47.6 -L -122.3 -t 3000 -T 6500"
}, },
"network": { "network": {
+9 -1
View File
@@ -15,8 +15,16 @@ def get_playerctl_metadata(field):
return None return None
def abbreviate(text, max_length=30):
if len(text) > max_length:
return text[: max_length - 3] + "..."
return text
artist = get_playerctl_metadata("artist") artist = get_playerctl_metadata("artist")
title = get_playerctl_metadata("title") title = get_playerctl_metadata("title")
if artist and title: if artist and title:
print(f"󰝚 {artist} - {title}") display_text = f"{artist} - {title}"
display_text = abbreviate(display_text, 40) # Adjust the max_length as needed
print(f"󰝚 {display_text}")
+6 -4
View File
@@ -19,12 +19,13 @@ def get_weather_icon(description):
"few clouds": "", "few clouds": "",
"scattered clouds": "", "scattered clouds": "",
"broken clouds": "", "broken clouds": "",
"overcast clouds": "",
"shower rain": "", "shower rain": "",
"light rain": "",
"rain": "", "rain": "",
"thunderstorm": "", "thunderstorm": "",
"snow": "", "snow": "",
"mist": "󰖑", "mist": "󰖑",
"overcast clouds": "",
} }
return icons.get(description, "") return icons.get(description, "")
@@ -37,11 +38,12 @@ try:
weather_data = response.json() weather_data = response.json()
weather_desc = weather_data["weather"][0]["description"] weather_desc = weather_data["weather"][0]["description"]
temp_c = weather_data["main"]["temp"] # print(weather_desc)
temp_f = celsius_to_fahrenheit(temp_c) temp_c = round(weather_data["main"]["temp"])
temp_f = round(celsius_to_fahrenheit(temp_c))
weather_icon = get_weather_icon(weather_desc) weather_icon = get_weather_icon(weather_desc)
print(f"{weather_icon} {temp_c:.1f}°C / {temp_f:.1f}°F") print(f"{weather_icon} {temp_c}°C / {temp_f}°F")
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
print(f"Error: {e}") print(f"Error: {e}")
+6 -2
View File
@@ -38,6 +38,8 @@ window#waybar {
} }
#battery { #battery {
/* margin: top right bottom left; */
margin: 8px 2px 8px 2px;
border-radius: 5px; border-radius: 5px;
} }
@@ -89,12 +91,14 @@ window#waybar {
} }
#custom-power { #custom-power {
margin:0px 3px 0px 0px; /* margin: top right bottom left; */
margin:0px 3px 0px 5px;
border-radius: 6px; border-radius: 6px;
} }
#tray { #tray {
margin: 7px 10px 8px 4px; /* margin: top right bottom left; */
margin: 8px 2px 8px 2px;
background: rgba(40,40,40, .65); background: rgba(40,40,40, .65);
border-radius: 6px; border-radius: 6px;
padding: 5px 5px 5px 5px; padding: 5px 5px 5px 5px;