-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract conky script logic
- Loading branch information
1 parent
7f5fa7a
commit 081ea72
Showing
26 changed files
with
77 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,4 @@ | ||
require 'config'; | ||
require 'base'; | ||
|
||
conky.text = [[ | ||
${goto 90}${voffset 25}${font adele:size=25} ${time %A, %d %B} | ||
${goto 90}${voffset -}${font LG Weather_Z:size=100}${time %H:%M}${image ./icons/white/line.png -p 354,23 -s 3x189} | ||
${offset 370}${voffset -183}${font ADELE:size=22} | ||
\ | ||
# --- Weather --- # | ||
################### | ||
\ | ||
# --- WOEID (Location id) --- # | ||
${execi 300 ./scripts/weather.sh}\ | ||
\ | ||
# --- Temperature --- # | ||
####################### | ||
\ | ||
${font ADELE :size=30}${offset 375}${voffset 10}${execi 300 ./scripts/kelvin2celsius.sh $(cat ~/.cache/eleg-weather.json | jq '.main.temp')}°${font ADELE :size=15}C${font ADELE :size=30}${voffset -20} | | ||
\ | ||
# --- Weather icon --- # | ||
######################## | ||
\ | ||
${execi 300 ./scripts/weather-icon.sh white $(cat ~/.cache/eleg-weather.json | jq -r '.weather[0].icon')}${image ~/.cache/eleg-weather-icon.png -p 410,8 -s 100x100} | ||
\ | ||
# --- Textual condition (e.g. Partly cloudy) --- # | ||
################################################## | ||
\ | ||
${font Roboto Light:size=18}${offset 462}${voffset -82}${execi 300 cat ~/.cache/eleg-weather.json | jq -r '.weather[0].main'} | ||
\ | ||
# --- Icon - high temperature --- # | ||
################################### | ||
\ | ||
${image ./icons/white/arrow-up.png -p 375,172 -s 12x12} | ||
\ | ||
# --- High temperature --- # | ||
############################ | ||
\ | ||
${font Roboto Light:size=12}${offset 395}${voffset -25}${execi 300 ./scripts/kelvin2celsius.sh $(cat ~/.cache/eleg-weather.json | jq '.main.temp_max')}° | ||
\ | ||
# --- Icon - low temperature icon --- # | ||
####################################### | ||
\ | ||
${image ./icons/white/arrow-down.png -p 422,172 -s 12x12} | ||
\ | ||
# --- Low temperature --- # | ||
########################### | ||
\ | ||
${font Roboto Light:size=12}${offset 438}${voffset -44}${execi 300 ./scripts/kelvin2celsius.sh $(cat ~/.cache/eleg-weather.json | jq '.main.temp_min')}° | ||
\ | ||
# --- Icon - map marker --- # | ||
############################# | ||
\ | ||
${image ./icons/white/map-marker.png -p 463,168 -s 16x16} | ||
\ | ||
# --- Location name (city) --- # | ||
############################################ | ||
\ | ||
${font Roboto Light:size=12}${offset 485}${voffset -45}${execi 300 cat ~/.cache/eleg-weather.json | jq -r '.name'} | ||
|
||
${goto 285}${voffset -35}${font adele:bold:size=25}${time %p} | ||
]]; | ||
conky.text = load('light', '#FFFFFF'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
script = [[ | ||
${color #{color}} | ||
${goto 90}${voffset 25}${font adele:size=25} ${time %A, %d %B} | ||
\ | ||
# --- Separator line --- # | ||
${goto 90}${voffset -}${font LG Weather_Z:size=100}${time %H:%M}${image ./icons/#{theme}/line.png -p 360,30 -s 3x189} | ||
\ | ||
${offset 370}${voffset -183}${font ADELE:size=22} | ||
\ | ||
# --- Weather --- # | ||
################### | ||
\ | ||
# --- WOEID (Location id) --- # | ||
${execi 300 ./scripts/weather.sh}\ | ||
\ | ||
# --- Temperature --- # | ||
####################### | ||
\ | ||
${font ADELE :size=30}${offset 260}${voffset 10}${execi 300 ./scripts/kelvin2celsius.sh $(cat ~/.cache/eleg-weather.json | jq '.main.temp')}°${font ADELE :size=15}C${font ADELE :size=30}${voffset -20} | | ||
\ | ||
# --- Weather icon --- # | ||
######################## | ||
\ | ||
${execi 300 ./scripts/weather-icon.sh #{theme} $(cat ~/.cache/eleg-weather.json | jq -r '.weather[0].icon')}${image ~/.cache/eleg-weather-icon.png -p 410,30 -s 100x100} | ||
\ | ||
# --- Textual condition (e.g. Partly cloudy) --- # | ||
################################################## | ||
\ | ||
${font Roboto Light:size=18}${offset 380}${voffset -82}${execi 300 cat ~/.cache/eleg-weather.json | jq -r '.weather[0].main'} | ||
\ | ||
# --- Icon - high temperature --- # | ||
################################### | ||
\ | ||
${image ./icons/#{theme}/arrow-up.png -p 375,190 -s 12x12} | ||
\ | ||
# --- High temperature --- # | ||
############################ | ||
\ | ||
${font Roboto Light:size=12}${offset 330}${voffset -25}${execi 300 ./scripts/kelvin2celsius.sh $(cat ~/.cache/eleg-weather.json | jq '.main.temp_max')}° | ||
\ | ||
# --- Icon - low temperature icon --- # | ||
####################################### | ||
\ | ||
${image ./icons/#{theme}/arrow-down.png -p 422,190 -s 12x12} | ||
\ | ||
# --- Low temperature --- # | ||
########################### | ||
\ | ||
${font Roboto Light:size=12}${offset 400}${voffset -44}${execi 300 ./scripts/kelvin2celsius.sh $(cat ~/.cache/eleg-weather.json | jq '.main.temp_min')}° | ||
\ | ||
# --- Icon - map marker --- # | ||
############################# | ||
\ | ||
${image ./icons/#{theme}/map-marker.png -p 463,187 -s 16x16} | ||
\ | ||
# --- Location name (city) --- # | ||
############################################ | ||
\ | ||
${font Roboto Light:size=12}${offset 440}${voffset -45}${execi 300 cat ~/.cache/eleg-weather.json | jq -r '.name'} | ||
${goto 285}${voffset -35}${font adele:bold:size=25}${time %p} | ||
]]; | ||
|
||
local function interp (s, t) | ||
return s:gsub('(#%b{})', function (w) | ||
return t[w:sub(3, -2)] or w | ||
end) | ||
end | ||
|
||
function load(theme, color) | ||
return interp(script, { | ||
theme = theme, | ||
color = color | ||
}) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes