ww
This commit is contained in:
@@ -0,0 +1,284 @@
|
||||
[colors]
|
||||
disabled = #707880
|
||||
Rosewater = #f5e0dc
|
||||
Flamingo = #f2cdcd
|
||||
Pink = #f5c2e7
|
||||
Mauve = #cba6f7
|
||||
Red = #f38ba8
|
||||
Maroon = #eba0ac
|
||||
Peach = #fab387
|
||||
Yellow = #f9e2af
|
||||
Green = #a6e3a1
|
||||
Teal = #94e2d5
|
||||
Sky = #89dceb
|
||||
Sapphire = #74c7ec
|
||||
Blue = #89b4fa
|
||||
Lavender = #b4befe
|
||||
Base = #1e1e2e
|
||||
Mantle = #181825
|
||||
|
||||
[bar/left]
|
||||
|
||||
width = 16%
|
||||
offset-x = 1%
|
||||
offset-y = 1%
|
||||
height = 22pt
|
||||
fixed-center = true
|
||||
|
||||
background = ${colors.Mantle}
|
||||
foreground = ${colors.Lavender}
|
||||
|
||||
line-size = 1pt
|
||||
|
||||
font-0 = "RobotoMono Nerd Font:weight=bold:size=9;2"
|
||||
font-1 = "RobotoMono Nerd Font:size=10;3"
|
||||
font-2 = "RobotoMono Nerd Font:size=11;3"
|
||||
font-3 = "NotoEmoji:scale=11;3"
|
||||
font-4 = "Noto Sans CJK JP:size=10;3"
|
||||
|
||||
modules-left = space space power xworkspaces sep space weather
|
||||
|
||||
enable-ipc = true
|
||||
|
||||
wm-restack = generic
|
||||
|
||||
[bar/middle]
|
||||
|
||||
width = 14%
|
||||
offset-x = 43%
|
||||
offset-y = 1%
|
||||
height = 22pt
|
||||
fixed-center = true
|
||||
|
||||
background = ${colors.Mantle}
|
||||
foreground = ${colors.Lavender}
|
||||
|
||||
line-size = 1pt
|
||||
|
||||
font-0 = "RobotoMono Nerd Font:weight=bold:size=9;2"
|
||||
font-1 = "RobotoMono Nerd Font:size=10;3"
|
||||
font-2 = "RobotoMono Nerd Font:size=11;3"
|
||||
|
||||
modules-center = day space sep space date space sep space time
|
||||
|
||||
enable-ipc = true
|
||||
|
||||
wm-restack = generic
|
||||
|
||||
[bar/right]
|
||||
|
||||
width = 8%
|
||||
offset-x = 91%
|
||||
offset-y = 1%
|
||||
height = 22pt
|
||||
fixed-center = true
|
||||
|
||||
background = ${colors.Mantle}
|
||||
foreground = ${colors.Lavender}
|
||||
|
||||
line-size = 1pt
|
||||
|
||||
font-0 = "RobotoMono Nerd Font:weight=bold:size=9;2"
|
||||
font-1 = "RobotoMono Nerd Font:size=10;3"
|
||||
font-2 = "RobotoMono Nerd Font:size=11;3"
|
||||
|
||||
modules-center = space pulseaudio space sep space backlight space
|
||||
enable-ipc = true
|
||||
|
||||
wm-restack = generic
|
||||
|
||||
[bar/tray]
|
||||
|
||||
width = 9%
|
||||
offset-x = 81%
|
||||
offset-y = 1%
|
||||
height = 22pt
|
||||
fixed-center = true
|
||||
|
||||
background = ${colors.Mantle}
|
||||
foreground = ${colors.Lavender}
|
||||
|
||||
line-size = 1pt
|
||||
|
||||
font-0 = "RobotoMono Nerd Font:size=10;3"
|
||||
|
||||
modules-center = tray
|
||||
|
||||
; tray-position = center
|
||||
|
||||
; tray-detached = false
|
||||
|
||||
; tray-maxsize = 16
|
||||
|
||||
enable-ipc = true
|
||||
|
||||
wm-restack = generic
|
||||
|
||||
[bar/xwindow]
|
||||
|
||||
width = 19%
|
||||
offset-x = 18%
|
||||
offset-y = 1%
|
||||
height = 22pt
|
||||
fixed-center = true
|
||||
|
||||
background = ${colors.Mantle}
|
||||
foreground = ${colors.Lavender}
|
||||
|
||||
line-size = 1pt
|
||||
|
||||
font-0 = "RobotoMono Nerd Font:weight=bold:size=10;3"
|
||||
font-1 = "Noto Sans CJK JP:style=Regular;size=10;1"
|
||||
|
||||
modules-center = space xwindow space
|
||||
enable-ipc = true
|
||||
|
||||
wm-restack = generic
|
||||
|
||||
[module/xworkspaces]
|
||||
type = internal/xworkspaces
|
||||
|
||||
label-active =
|
||||
label-active-padding = 2
|
||||
label-active-foreground = ${colors.Lavender}
|
||||
label-active-font = 2
|
||||
|
||||
label-occupied =
|
||||
label-occupied-padding = 2
|
||||
label-occupied-font = 2
|
||||
|
||||
label-empty =
|
||||
label-empty-foreground = ${colors.disabled}
|
||||
label-empty-padding = 2
|
||||
label-empty-font = 2
|
||||
|
||||
[module/xwindow]
|
||||
|
||||
type = internal/xwindow
|
||||
format = <label>
|
||||
format-background = ${colors.Mantle}
|
||||
format-foreground = ${colors.Lavender}
|
||||
format-padding = 2
|
||||
|
||||
label = %title%
|
||||
label-maxlen = 40
|
||||
|
||||
label-empty = ~/
|
||||
label-empty-foreground = ${colors.disabled}
|
||||
|
||||
[module/pulseaudio]
|
||||
type = internal/pulseaudio
|
||||
format-volume-prefix = "墳 "
|
||||
format-volume-prefix-foreground = ${colors.Rosewater}
|
||||
format-volume = <label-volume>
|
||||
format-volume-prefix-font = 3
|
||||
|
||||
label-volume = %percentage%%
|
||||
|
||||
label-muted = muted
|
||||
label-muted-foreground = ${colors.disabled}
|
||||
|
||||
[network-base]
|
||||
type = internal/network
|
||||
interval = 5
|
||||
format-connected = <label-connected>
|
||||
format-disconnected = <label-disconnected>
|
||||
label-disconnected = disconnected
|
||||
format-connected-foreground = ${colors.Lavender}
|
||||
|
||||
[module/wlan]
|
||||
inherit = network-base
|
||||
interface-type = wireless
|
||||
label-connected-font = 3
|
||||
label-connected =
|
||||
label-connected-foreground = ${colors.Rosewater}
|
||||
|
||||
[module/day]
|
||||
type = internal/date
|
||||
interval = 1
|
||||
|
||||
date = %A
|
||||
|
||||
label = %date%
|
||||
label-foreground = ${colors.Lavender}
|
||||
|
||||
[module/date]
|
||||
type = internal/date
|
||||
interval = 1
|
||||
|
||||
date = %d-%m-%Y
|
||||
|
||||
label = %date%
|
||||
label-foreground = ${colors.Lavender}
|
||||
|
||||
[module/time]
|
||||
type = internal/date
|
||||
interval = 1
|
||||
|
||||
date = %H:%M:%S
|
||||
|
||||
label = %date%
|
||||
label-foreground = ${colors.Lavender}
|
||||
|
||||
[module/battery]
|
||||
type = internal/battery
|
||||
poll-interval = 5
|
||||
full-at = 99
|
||||
format-full-prefix = " "
|
||||
format-charging-prefix = " "
|
||||
format-discharging-prefix = " "
|
||||
format-full-prefix-foreground = ${colors.Rosewater}
|
||||
format-charging-prefix-foreground = ${colors.Rosewater}
|
||||
format-discharging-prefix-foreground = ${colors.Red}
|
||||
label-charging = %percentage%%
|
||||
label-discharging = %percentage%%
|
||||
label-full = %percentage%%
|
||||
|
||||
[module/backlight]
|
||||
type = internal/backlight
|
||||
|
||||
; Use the following command to list available cards:
|
||||
; $ ls -1 /sys/class/backlight/
|
||||
|
||||
card = amdgpu_bl1
|
||||
use-actual-brightness = true
|
||||
format-prefix = "盛 "
|
||||
format-prefix-foreground = ${colors.Rosewater}
|
||||
format-prefix-font = 3
|
||||
enable-scroll = true
|
||||
|
||||
[module/tray]
|
||||
type = internal/tray
|
||||
format-margin = 8px
|
||||
; tray-spacing = 8px
|
||||
tray-padding = 4px
|
||||
|
||||
[module/power]
|
||||
type = custom/text
|
||||
content =
|
||||
content-font = 3
|
||||
content-foreground = ${colors.Red}
|
||||
content-margin = 1
|
||||
click-left = "sh ~/.config/rofi/powermenu/type-6/powermenu.sh"
|
||||
|
||||
[module/weather]
|
||||
type = custom/script
|
||||
exec = "sh ~/.config/polybar/weather.sh"
|
||||
interval = 700
|
||||
|
||||
; decor
|
||||
|
||||
[module/sep]
|
||||
type = custom/text
|
||||
content = "|"
|
||||
content-foreground = ${colors.disabled}
|
||||
|
||||
[module/space]
|
||||
type = custom/text
|
||||
content = " "
|
||||
|
||||
[settings]
|
||||
screenchange-reload = true
|
||||
pseudo-transparency = true
|
||||
|
||||
; vim:ft=dosini
|
||||
@@ -0,0 +1,99 @@
|
||||
import json
|
||||
import requests
|
||||
|
||||
def wc_extract(wc):
|
||||
wc = str(wc)
|
||||
if wc in ("0", "1"):
|
||||
if day == "1":
|
||||
return ("☀️")
|
||||
else:
|
||||
return("🌙")
|
||||
elif wc == "2":
|
||||
if day == "1":
|
||||
return ("⛅")
|
||||
else:
|
||||
return("☁️")
|
||||
elif wc in ("3", "45", "48"):
|
||||
return ("☁️")
|
||||
elif wc in ("51", "53", "55", "61", "63", "65", "80", "81", "82"):
|
||||
return ("🌧️")
|
||||
elif wc in ("56", "57", "66", "67", "85", "86"):
|
||||
return ("🌨️")
|
||||
elif wc in ("71", "73", "75", "77"):
|
||||
return ("❄️")
|
||||
elif wc in ("95", "96", "99"):
|
||||
return ("⛈️")
|
||||
|
||||
def json_extract(obj, path):
|
||||
'''
|
||||
Extracts an element from a nested dictionary or
|
||||
a list of nested dictionaries along a specified path.
|
||||
If the input is a dictionary, a list is returned.
|
||||
If the input is a list of dictionary, a list of lists is returned.
|
||||
obj - list or dict - input dictionary or list of dictionaries
|
||||
path - list - list of strings that form the path to the desired element
|
||||
'''
|
||||
def extract(obj, path, ind, arr):
|
||||
'''
|
||||
Extracts an element from a nested dictionary
|
||||
along a specified path and returns a list.
|
||||
obj - dict - input dictionary
|
||||
path - list - list of strings that form the JSON path
|
||||
ind - int - starting index
|
||||
arr - list - output list
|
||||
'''
|
||||
key = path[ind]
|
||||
if ind + 1 < len(path):
|
||||
if isinstance(obj, dict):
|
||||
if key in obj.keys():
|
||||
extract(obj.get(key), path, ind + 1, arr)
|
||||
else:
|
||||
arr.append(None)
|
||||
elif isinstance(obj, list):
|
||||
if not obj:
|
||||
arr.append(None)
|
||||
else:
|
||||
for item in obj:
|
||||
extract(item, path, ind, arr)
|
||||
else:
|
||||
arr.append(None)
|
||||
if ind + 1 == len(path):
|
||||
if isinstance(obj, list):
|
||||
if not obj:
|
||||
arr.append(None)
|
||||
else:
|
||||
for item in obj:
|
||||
arr.append(item.get(key, None))
|
||||
elif isinstance(obj, dict):
|
||||
arr.append(obj.get(key, None))
|
||||
else:
|
||||
arr.append(None)
|
||||
return arr
|
||||
if isinstance(obj, dict):
|
||||
return extract(obj, path, 0, [])
|
||||
elif isinstance(obj, list):
|
||||
outer_arr = []
|
||||
for item in obj:
|
||||
outer_arr.append(extract(item, path, 0, []))
|
||||
return outer_arr
|
||||
|
||||
latitude = 26.50
|
||||
longitude = 80.24
|
||||
|
||||
wurl = "https://api.open-meteo.com/v1/forecast?latitude=" + str(latitude) + "&longitude=" + str(longitude) + "&hourly=temperature_2m,is_day¤t_weather=true&timezone=auto"
|
||||
|
||||
wjson = requests.get(wurl).content
|
||||
wjson = json.loads(wjson)
|
||||
tmp = str(json_extract(wjson, ["current_weather", "temperature"])[0])
|
||||
day = str(json_extract(wjson, ["current_weather", "is_day"])[0])
|
||||
wcode = wc_extract(str(json_extract(wjson, ["current_weather", "weathercode"])[0]))
|
||||
|
||||
temp = ""
|
||||
for i in tmp:
|
||||
if i == ".":
|
||||
break
|
||||
else:
|
||||
temp += i
|
||||
|
||||
print(wcode, temp+"°C")
|
||||
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
sleep 5
|
||||
if 2>/dev/null 1>&2 ping -c 1 www.archlinux.org; then
|
||||
python3 ~/.config/polybar/weather.py
|
||||
else
|
||||
echo '\_(ツ)_/'
|
||||
fi
|
||||
Reference in New Issue
Block a user