weather widget
This commit is contained in:
1 parent
44afecd7df
commit
54278273cb
14 files changed
+2688
-50
No files matched your search
+1
-1
@@ -72,4 +72,4 @@
|
||||
min-height: 20px;
|
||||
min-width: 310px;
|
||||
margin : 10px 0px 0px 0px;
|
||||
}
|
||||
}
|
||||
+27
-47
@@ -3,55 +3,35 @@
|
||||
(deflisten music_position "scripts/music listen-position")
|
||||
(deflisten music_status "scripts/music listen-status")
|
||||
|
||||
(defwidget music_progress_widget []
|
||||
(box
|
||||
:class "music_progress_box"
|
||||
:halign "center"
|
||||
:space-evenly false
|
||||
(box
|
||||
:state "progress"
|
||||
(scale
|
||||
:onscroll "playerctl position {}"
|
||||
:min 0
|
||||
:max "${music_metadata.length}"
|
||||
:active true
|
||||
:hexpand true
|
||||
:vexpand true
|
||||
:value "${music_position.position}"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Music
|
||||
(defwidget music []
|
||||
(box :class "genwin" :orientation "h" :space-evenly "false" :vexpand "false" :hexpand "false"
|
||||
(box :class "album_art" :vexpand "false" :hexpand "false" :style "background-image: url('${music_metadata.arturl}');")
|
||||
(box :orientation "v" :spacing 20 :space-evenly "false" :vexpand "false" :hexpand "false"
|
||||
(label :halign "center" :class "song" :wrap "true" :limit-width 20 :text "${music_metadata.title}")
|
||||
(label :halign "center" :class "artist" :wrap "true" :limit-width 15 :text "${music_metadata.artist}")
|
||||
(box :orientation "h" :spacing 20 :halign "center" :space-evenly "true" :vexpand "false" :hexpand "false"
|
||||
(button :class "btn_prev" :onclick "playerctl previous" "")
|
||||
(button :class "btn_play" :onclick "playerctl play-pause" {"${music_status.status}" == "Playing" ? "" : ""})
|
||||
(button :class "btn_next" :onclick "playerctl next" "")
|
||||
)
|
||||
(box :class "music_bar" :halign "center" :state "progress"
|
||||
(scale
|
||||
:onscroll "playerctl position {}"
|
||||
:onclick "playerctl position {}"
|
||||
:min 0
|
||||
:max "${music_metadata.length}"
|
||||
:active true
|
||||
:hexpand true
|
||||
:vexpand true
|
||||
:value "${music_position.position}"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(defwidget music []
|
||||
(box :class "genwin" :orientation "h" :space-evenly "false" :vexpand "false" :hexpand "false"
|
||||
(box :class "album_art" :vexpand "false" :hexpand "false" :style "background-image: url('${music_metadata.arturl}');")
|
||||
(box :orientation "v" :spacing 20 :space-evenly "false" :vexpand "false" :hexpand "false"
|
||||
(label :halign "center" :class "song" :wrap "true" :limit-width 20 :text "${music_metadata.title}")
|
||||
(label :halign "center" :class "artist" :wrap "true" :limit-width 15 :text "${music_metadata.artist}")
|
||||
(box :orientation "h" :spacing 20 :halign "center" :space-evenly "true" :vexpand "false" :hexpand "false"
|
||||
(button :class "btn_prev" :onclick "playerctl previous" "")
|
||||
(button :class "btn_play" :onclick "playerctl play-pause" {"${music_status.status}" == "Playing" ? "" : ""})
|
||||
(button :class "btn_next" :onclick "playerctl next" "")
|
||||
)
|
||||
(box :class "music_bar" :halign "center" :state "progress"
|
||||
(scale
|
||||
:onscroll "playerctl position {}"
|
||||
:onclick "playerctl position {}"
|
||||
:min 0
|
||||
:max "${music_metadata.length}"
|
||||
:active true
|
||||
:hexpand true
|
||||
:vexpand true
|
||||
:value "${music_position.position}"
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; music
|
||||
(defwindow music :stacking "fg" :focusable "false" :screen 1 :monitor 0
|
||||
:geometry (geometry :x 100 :y 100 :width 610 :height 280)
|
||||
(music))
|
||||
:geometry (geometry :x 100 :y 100 :width 610 :height 280)
|
||||
(music))
|
||||
@@ -0,0 +1,28 @@
|
||||
/** Global *******************************************/
|
||||
*{
|
||||
all: unset;
|
||||
font-family: feather;
|
||||
font-family: Iosevka;
|
||||
}
|
||||
|
||||
/** Background ***************************************/
|
||||
.bg {
|
||||
// background-image: url("images/bg.png");
|
||||
background-color: #474D59;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/** Generic window ***********************************/
|
||||
.genwin {
|
||||
background-color: #2E3440;
|
||||
border-radius: 16px;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.label_temp {
|
||||
font-size: 100;
|
||||
}
|
||||
|
||||
.label_stat {
|
||||
font-size: 50;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
; Weather data
|
||||
(defpoll weatherdata :interval "15m" `wttr/wttr.py`)
|
||||
|
||||
(defwidget weather []
|
||||
(box :class "genwin" :style "background-image: url('images/bg.png');background-size: cover;"
|
||||
(box :orientation "v" :spacing 10 :space-evenly false :vexpand false :hexpand false
|
||||
(box :orientation "h" :spacing 0 :vexpand false :hexpand false
|
||||
(label :class "label_temp" :halign "center" :style "color: white;" :text "${weatherdata.current_condition[0].temp_C}")
|
||||
; (label :class "iconweather" :halign "center" :text "${weatherdata.current_condition[0].weatherCode}")
|
||||
)
|
||||
(box :orientation "v" :spacing 10 :halign "center" :space-evenly false :vexpand false :hexpand false
|
||||
(label :class "label_stat" :text "${weatherdata.current_condition[0].weatherDesc[0].value}")
|
||||
(box :orientation "h" :spacing 10 :space-evenly false :vexpand false :hexpand false
|
||||
(label :class "label_quote" :text "${weatherdata.nearest_area[0].country[0].value}")
|
||||
(label :class "label_quote" :text "${weatherdata.nearest_area[0].region[0].value}")
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
; Weather window
|
||||
(defwindow weather :stacking "fg" :focusable true :exclusive true :screen 1 :windowtype "dock"
|
||||
:geometry (geometry :x 100 :y 100 :width 610 :height 280)
|
||||
(weather)
|
||||
)
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 315 KiB |
File diff suppressed because it is too large.
Load diff
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import json
|
||||
import requests
|
||||
from datetime import datetime
|
||||
|
||||
WEATHER_CODES = {
|
||||
'113': '☀️',
|
||||
'116': '⛅️',
|
||||
'119': '☁️',
|
||||
'122': '☁️',
|
||||
'143': '🌫',
|
||||
'176': '🌦',
|
||||
'179': '🌧',
|
||||
'182': '🌧',
|
||||
'185': '🌧',
|
||||
'200': '⛈',
|
||||
'227': '🌨',
|
||||
'230': '❄️',
|
||||
'248': '🌫',
|
||||
'260': '🌫',
|
||||
'263': '🌦',
|
||||
'266': '🌦',
|
||||
'281': '🌧',
|
||||
'284': '🌧',
|
||||
'293': '🌦',
|
||||
'296': '🌦',
|
||||
'299': '🌧',
|
||||
'302': '🌧',
|
||||
'305': '🌧',
|
||||
'308': '🌧',
|
||||
'311': '🌧',
|
||||
'314': '🌧',
|
||||
'317': '🌧',
|
||||
'320': '🌨',
|
||||
'323': '🌨',
|
||||
'326': '🌨',
|
||||
'329': '❄️',
|
||||
'332': '❄️',
|
||||
'335': '❄️',
|
||||
'338': '❄️',
|
||||
'350': '🌧',
|
||||
'353': '🌦',
|
||||
'356': '🌧',
|
||||
'359': '🌧',
|
||||
'362': '🌧',
|
||||
'365': '🌧',
|
||||
'368': '🌨',
|
||||
'371': '❄️',
|
||||
'374': '🌧',
|
||||
'377': '🌧',
|
||||
'386': '⛈',
|
||||
'389': '🌩',
|
||||
'392': '⛈',
|
||||
'395': '❄️'
|
||||
}
|
||||
|
||||
data = {}
|
||||
|
||||
weather = requests.get("https://wttr.in/Tomsk+Russia?format=j1").json()
|
||||
|
||||
# data['text'] = WEATHER_CODES[weather['current_condition'][0]['weatherCode']] + \
|
||||
# " "+weather['current_condition'][0]['FeelsLikeC']+"°"
|
||||
|
||||
weather['current_condition'][0]['weatherCode'] = WEATHER_CODES[weather['current_condition'][0]['weatherCode']]
|
||||
|
||||
print(json.dumps(weather))
|
||||
Reference in new issue
Block a user