You are not logged in.

#1 2019-06-21 16:03:10

Nili
Member
From: $HOME/♫♪
Registered: 2015-09-30
Posts: 1,007
Website

[SOLVED] tint2-weather - a small modification

I'm using tint2-weather script executor by
addy-dclxv

#!/bin/bash

# I take this script from Anachron's i3blocks
# I only slightly modify this script to add an option to show icon
# I also remove the i3blocks specify script
# To make this works with tint2 executor, polybar custom script, dzen2 feeder, conkybar, lemonbar feeder, dunst notify, etc.
# 'weather -i' = with icon, 'weather' = text only
# Cheers!
# Addy

# Open Weather Map API code, register to http://openweathermap.org to get one ;)
API_KEY="365a6f3a274bba21cabdbee0aa44exxx"

# Check on http://openweathermap.org/find
CITY_ID="1650xxx"

ICON_SUNNY=" Clear"
ICON_CLOUDY=" Cloudy"
ICON_RAINY=" Rainy"
ICON_STORM=" Storm"
ICON_SNOW=" Snow"
ICON_FOG=" Fog"
ICON_MISC=" "

TEXT_SUNNY="Clear"
TEXT_CLOUDY="Cloudy"
TEXT_RAINY="Rainy"
TEXT_STORM="Storm"
TEXT_SNOW="Snow"
TEXT_FOG="Fog"

SYMBOL_CELSIUS="˚C"

WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"

WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[A-Za-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')

if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_SNOW} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Rain* ]] || [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_RAINY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_CLOUDY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_SUNNY} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
elif [[ "${WEATHER_MAIN}" = *Fog* ]] || [[ "${WEATHER_MAIN}" = *Mist* ]]; then
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${TEXT_FOG} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi
else
	if  [[ $1 = "-i" ]]; then
    echo "${ICON_MISC} ${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	else
    echo "${WEATHER_MAIN} ${WEATHER_TEMP}${SYMBOL_CELSIUS}"
	fi	
fi

So far, it goes smoothly with the exception of if my internet connection goes down. I would like to add a message there is no connection.
Could someone set if eth0 present (weather-url) else if no connection (con-down)

I know how to do on conky, but i'm not that good on bash.

Thanks in advance!
Nili

Last edited by Nili (2020-08-30 19:37:40)

Offline

#2 2019-06-21 17:31:22

damo
....moderator....
Registered: 2015-08-20
Posts: 6,529

Re: [SOLVED] tint2-weather - a small modification

The bunsenweather script uses a connection test, which you could adapt I guess

connectiontest() {
    local -i i attempts=${1-0}
    for (( i=0; i < attempts || attempts == 0; i++ )); do
        if wget -O - 'http://ftp.debian.org/debian/README' &> /dev/null; then
            return 0
        fi
        if (( i == attempts - 1 )); then # if last attempt
            return 1
        fi
    done
}

A code snippet which might work is

if wget -O - 'http://ftp.debian.org/debian/README' &> /dev/null; then
    return 0
else
    notify-send "No internet connection"
    return 1        
fi

You could probably also parse the output from a ping command instead.


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#3 2019-06-22 05:57:38

Nili
Member
From: $HOME/♫♪
Registered: 2015-09-30
Posts: 1,007
Website

Re: [SOLVED] tint2-weather - a small modification

Thank you damo, I have difficult to adapt those two scripts you showed, but the ping output you gave me an idea because i already have a little snippets.

ping -qc1 8.8.8.8 2>&1 | awk -F/ '/^rtt/ { printf "%.2f", $5; ok = 1 } END { if (!ok) print "eth0 FAIL" }'

# Fixed this display link down when there's error from network connection.

if ping -qc1 1.1.1.1 >/dev/null; then
 WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"
else
  echo " Link Down"
fi

Thank you!

Last edited by Nili (2020-08-30 20:02:36)

Offline

#4 2020-11-06 21:09:11

ceeslans
Member
Registered: 2015-09-30
Posts: 105

Re: [SOLVED] tint2-weather - a small modification

Building on Addy's tint2 weather script executor - and Nili's ping-check for network connection.
I reworked the script to draw the current icon details from openweathermap server output - which are then set from an icon folder in tint2-executor path.
This way, the correct 'day' or 'night' icon is set in the toolbar widget.
Script allows to call the original openweathermap icons, or the relevant Papirus icons

e1GAZQrt.png

here is the updated 'weather' script :

#!/bin/bash
#
# ===========================================================
# Based on script from @Anachron's i3blocks, as well as 
# @Addy's icon additions and @Nili's network-connection check
# Mod by @ceeslans, to draw icons from tint2 config folder
# ===========================================================

# Open Weather Map API code, register to http://openweathermap.org to get one :
API_KEY="f6853011e20f4063f8808bcc74e25b84"

# Check on http://openweathermap.org/find :
CITY_ID="2747891"

# Select applicable temperature symbol "˚C" or "˚F" :
SYMBOL_CELSIUS="˚C"

# Change "Text" to your preferred language :
TEXT_SNOW="Snow"
TEXT_RAINY="Rainy"
TEXT_DRIZZLE="Drizzle"
TEXT_SHOWERS="Showers"
TEXT_SUNNY="Sunny"
TEXT_CLEAR="Clear"
TEXT_CLOUDY="Cloudy"
TEXT_OVERCAST="Overcast"
TEXT_STORM="Storm"
TEXT_FOG="Fog"

# Show Papirus weather-icons :
ICONPATH="$HOME/.config/tint2/executors/icons/weather/"
# or show original openweathermap weather-icons :
#ICONPATH="$HOME/.config/tint2/executors/icons/weather/openweathermap/"

# Don't change these lines, unless you know what you're doing...
if ping -qc1 1.1.1.1 >/dev/null; then
 WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"
else
	echo "${ICONPATH}404.png"
	echo "Link Down"
fi

WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[A-Za-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_ICON=$(echo "${WEATHER_INFO}" | grep -o -e '\"icon\":\"[0-9a-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')

# To add short condition description in the toolbar, comment out # ${TEXT-*} :

if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SNOW}"
    
elif [[ "${WEATHER_MAIN}" = *Rain* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}"	# "${TEXT_RAINY}"

elif [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_DRIZZLE}"

elif [[ "${WEATHER_MAIN}" = *Shower* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SHOWERS}"

elif [[ "${WEATHER_MAIN}" = *Sunny* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SUNNY}"
	
elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_CLEAR}"
	
elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_CLOUDY}"

elif [[ "${WEATHER_MAIN}" = *Overcast* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_OVERCAST}"
    
elif [[ "${WEATHER_MAIN}" = *Storm* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_STORM}"
    
elif [[ "${WEATHER_MAIN}" = *Fog* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_FOG}"

else
	echo "${ICONPATH}04.png"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS} ${WEATHER_MAIN}"
fi 

and example executor config for tint2:

# Executor 6	(weather local)
execp = new
execp_command = ~/.config/tint2/executors/weather
execp_interval = 300
execp_has_icon = 1
execp_cache_icon = 1
execp_continuous = 0
execp_markup = 1
execp_tooltip = Current weather --> leftclick for 7days weather forecast
execp_lclick_command = exo-open https://openweathermap.org/city/2747891
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = DejaVu Sans Condensed 9
execp_font_color = #ffffff 100
execp_padding = 6 0
execp_background_id = 0
execp_centered = 0
execp_icon_w = 24
execp_icon_h = 24 

If you want to test it: the icons can be downloaded here
.

Last edited by ceeslans (2020-11-06 21:18:49)

Offline

#5 2021-02-10 22:30:48

giantowl
Member
From: another place
Registered: 2021-02-08
Posts: 10

Re: [SOLVED] tint2-weather - a small modification

hi all, don't know should I create new topic? I think no, because of my question is quite stupid (as usual)))

ceeslans, can u please post your full config?

or can someone told me where I fkd up?

I created script.sh in /home/nik/.config/tint2/executors/weather/

#!/bin/bash
#
# ===========================================================
# Based on script from @Anachron's i3blocks, as well as 
# @Addy's icon additions and @Nili's network-connection check
# Mod by @ceeslans, to draw icons from tint2 config folder
# ===========================================================

# Open Weather Map API code, register to http://openweathermap.org to get one :
API_KEY="xxx"

# Check on http://openweathermap.org/find :
CITY_ID="xxx"

# Select applicable temperature symbol "˚C" or "˚F" :
SYMBOL_CELSIUS="˚C"

# Change "Text" to your preferred language :
TEXT_SNOW="Snow"
TEXT_RAINY="Rainy"
TEXT_DRIZZLE="Drizzle"
TEXT_SHOWERS="Showers"
TEXT_SUNNY="Sunny"
TEXT_CLEAR="Clear"
TEXT_CLOUDY="Cloudy"
TEXT_OVERCAST="Overcast"
TEXT_STORM="Storm"
TEXT_FOG="Fog"

# Show Papirus weather-icons :
ICONPATH="$HOME/.config/tint2/executors/icons/weather/"
# or show original openweathermap weather-icons :
#ICONPATH="$HOME/.config/tint2/executors/icons/weather/openweathermap/"

# Don't change these lines, unless you know what you're doing...
if ping -qc1 1.1.1.1 >/dev/null; then
 WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"
else
	echo "${ICONPATH}404.png"
	echo "Link Down"
fi

WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[A-Za-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_ICON=$(echo "${WEATHER_INFO}" | grep -o -e '\"icon\":\"[0-9a-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')

# To add short condition description in the toolbar, comment out # ${TEXT-*} :

if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SNOW}"
    
elif [[ "${WEATHER_MAIN}" = *Rain* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}"	# "${TEXT_RAINY}"

elif [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_DRIZZLE}"

elif [[ "${WEATHER_MAIN}" = *Shower* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SHOWERS}"

elif [[ "${WEATHER_MAIN}" = *Sunny* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SUNNY}"
	
elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_CLEAR}"
	
elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_CLOUDY}"

elif [[ "${WEATHER_MAIN}" = *Overcast* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_OVERCAST}"
    
elif [[ "${WEATHER_MAIN}" = *Storm* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_STORM}"
    
elif [[ "${WEATHER_MAIN}" = *Fog* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_FOG}"

else
	echo "${ICONPATH}04.png"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS} ${WEATHER_MAIN}"
fi 

then I put Executor6 into current tint2 conf

#---------------------------------------------
# TINT2 CONFIG FILE "myconf lithium.tint2rc"
#
# A simple theme. Note that many properties are set to "0"
# Please see 'man tint2' for full configuration options
#---------------------------------------------
#---- Generated by tint2conf 0320 ----
# See https://gitlab.com/o9000/tint2/wikis/Configure for
# full documentation of the configuration options.
#
# Tweaked for BunsenLabs
#
#-------------------------------------
# Gradients
#-------------------------------------
# Backgrounds
# Background 1: Iconified task, Panel
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #cccccc 0
border_color = #828282 0
background_color_hover = #cccccc 0
border_color_hover = #828282 0
background_color_pressed = #cccccc 0
border_color_pressed = #828282 0

# Background 2: Active task
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #000000 40
border_color = #d8d8d8 0
background_color_hover = #ffffff 20
border_color_hover = #d8d8d8 0
background_color_pressed = #ffffff 30
border_color_pressed = #d8d8d8 0

# Background 3: Default task (inactive tasks that are not iconified)
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #000000 0
border_color = #000000 0
background_color_hover = #ffffff 10
border_color_hover = #000000 0
background_color_pressed = #ffffff 20
border_color_pressed = #000000 0

# Background 4: Urgent task
rounded = 0
border_width = 1
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #ff0034 20
border_color = #ff0034 0
background_color_hover = #ffffff 20
border_color_hover = #ffffff 0
background_color_pressed = #ffffff 30
border_color_pressed = #ffffff 0

# Background 5: Inactive taskbar
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #000000 20
#border_color = #000000 0
#background_color_hover = #ff0000 100
#border_color_hover = #000000 0
#background_color_pressed = #808384 0
#border_color_pressed = #000000 0

# Background 6: Active taskbar
rounded = 0
border_width = 1
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #ffffff 5
border_color = #000000 0
#background_color_hover = #000000 0
#border_color_hover = #000000 0
#background_color_pressed = #000000 0
#border_color_pressed = #000000 0

# Background 7: Tooltip
rounded = 2
border_width = 1
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #3D6270 100
border_color = #3D6270 100
background_color_hover = #000000 0
border_color_hover = #000000 0
background_color_pressed = #000000 0
border_color_pressed = #000000 0

#-------------------------------------
# Panel
panel_items = LTSCP
panel_size = 99% 30
panel_margin = 0 0
panel_padding = 6 0 0
panel_background_id = 1
wm_menu = 1
panel_dock = 0
panel_position = bottom center horizontal
panel_layer = bottom
panel_monitor = all
panel_shrink = 0
autohide = 0
autohide_show_timeout = 0.3
autohide_hide_timeout = 1.5
autohide_height = 6
strut_policy = follow_size
panel_window_name = tint2
disable_transparency = 0
# enable mouse_hover
mouse_effects = 1
font_shadow = 0
mouse_hover_icon_asb = 100 0 10
mouse_pressed_icon_asb = 100 0 0
scale_relative_to_dpi = 0
scale_relative_to_screen_height = 0

#-------------------------------------
# Taskbar - Panel item = T
taskbar_mode = multi_desktop
taskbar_hide_if_empty = 0
taskbar_padding = 2 0 4 (the last number determines icon spacing)

taskbar_background_id = 5
taskbar_active_background_id = 6

taskbar_name = 0
taskbar_hide_inactive_tasks = 0
taskbar_hide_different_monitor = 0
taskbar_hide_different_desktop = 0
taskbar_always_show_all_desktop_tasks = 0
taskbar_name_padding = 0 0
taskbar_name_background_id = 0
taskbar_name_active_background_id = 0
taskbar_name_font = Sans 9
taskbar_name_font_color = #828282 100
taskbar_name_active_font_color = #828282 100
taskbar_distribute_size = 0
taskbar_sort_order = none
task_align = left

#-------------------------------------
# Task
task_text = 0
task_icon = 1
task_centered = 1
urgent_nb_of_blink = 20
task_maximum_size = 30 30
task_padding = 2 2
task_font = Sans 9
task_tooltip = 1
task_thumbnail = 0
task_thumbnail_size = 210
task_font_color = #d8d8d8 60
task_active_font_color = #d8d8d8 100
task_urgent_font_color = #ffffff 100
task_iconified_font_color = #d8d8d8 60
task_icon_asb = 70 0 0
task_active_icon_asb = 100 0 0
task_urgent_icon_asb = 100 0 0
task_iconified_icon_asb = 50 0 0
task_background_id = 3
task_active_background_id = 2
task_urgent_background_id = 4
task_iconified_background_id = 1
mouse_left = toggle_iconify
mouse_middle = none
mouse_right = close
mouse_scroll_up = toggle
mouse_scroll_down = iconify

#-------------------------------------
# System tray (notification area) - Panel item = S
systray_padding = 1 1 1
systray_background_id = 5
systray_sort = right2left
systray_icon_size = 22
systray_icon_asb = 100 0 0
systray_monitor = primary
systray_name_filter =

#-------------------------------------
# Launcher - Panel item = L
launcher_padding = 8 4 4
launcher_background_id = 5
launcher_icon_background_id = 0
launcher_icon_size = 0
launcher_icon_asb = 100 0 0
launcher_icon_theme = Papirus-Bunsen-Dark-bluegrey
launcher_icon_theme_override = 0
startup_notifications = 0
launcher_tooltip = 1
launcher_item_app = /usr/share/applications/bl-www-browser.desktop
launcher_item_app = /usr/share/applications/bl-file-manager.desktop
launcher_item_app = /usr/share/applications/bl-text-editor.desktop
launcher_item_app = /usr/share/applications/bl-terminal-emulator.desktop

#-------------------------------------
# Clock - Panel item = C

#24hr clock (for seconds, use %H:%M:%S)
# See 'man strftime' for other time and date formats.
time1_format = %H:%M
#12hr clock with am/pm (%p for AM/PM)
#time1_format = %l:%M%P
time2_format =
#font example
#time1_font = Futura Bk BT bold 10
time1_font = Sans bold 12
time1_timezone =
time2_timezone =
clock_font_color = #DFDFDF 100
clock_padding = 6 0 6
clock_background_id = 5

#The day and date
clock_tooltip = %A %F
clock_tooltip_timezone =
#Show calendar
clock_lclick_command = gsimplecal
clock_rclick_command = bl-beepmein-pipemenu --standalone
clock_mclick_command =
clock_uwheel_command =
clock_dwheel_command =


#-------------------------------------
# Battery
battery_tooltip = 1
battery_low_status = 20
battery_low_cmd = notify-send "battery low"
battery_full_cmd =
bat1_font = Monospace 8
bat2_font = Monospace 8
battery_font_color = #b5b5b5 100
bat1_format =
bat2_format =
battery_padding = 2 0
battery_background_id = 0
battery_hide = 96
battery_lclick_command =
battery_rclick_command =
battery_mclick_command =
battery_uwheel_command =
battery_dwheel_command =
ac_connected_cmd =
ac_disconnected_cmd =

#-------------------------------------
# Executor 6	(weather local)
execp = new
execp_command = ~/.config/tint2/executors/weather.sh
execp_interval = 300
execp_has_icon = 1
execp_cache_icon = 1
execp_continuous = 0
execp_markup = 1
execp_tooltip = Current weather --> leftclick for 7days weather forecast
execp_lclick_command = exo-open https://openweathermap.org/city/xxx
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = DejaVu Sans Condensed 9
execp_font_color = #ffffff 100
execp_padding = 6 0
execp_background_id = 0
execp_centered = 0
execp_icon_w = 24
execp_icon_h = 24 

#-------------------------------------
# Tooltip
tooltip_show_timeout = 0
tooltip_hide_timeout = 0
tooltip_padding = 8 8
tooltip_background_id = 7
tooltip_font_color = #d3dae3 100
tooltip_font = Sans normal 10

#-------------------------------------
# Buttons - Panel item = P

# Show Root Menu (BL-flame icon)
#button = new
#button_icon = start-here-bunsenlabs
#button_text =
#button_tooltip = Main Menu
#button_lclick_command = jgmenu_run
#button_rclick_command =
#button_mclick_command =
#button_uwheel_command =
#button_dwheel_command =
#button_font_color = #ffffff 100
#button_padding = 2 2
#button_background_id = 5
#button_centered = 1
#button_max_icon_size = 28


# Exit dialog (Power icon)
button = new
#button_icon = /usr/share/images/bunsen/exit/light/poweroff.png
button_icon = system-shutdown-symbolic
button_text =
button_tooltip = Logout/Shutdown...
button_lclick_command = bl-exit
button_rclick_command =
button_mclick_command =
button_uwheel_command =
button_dwheel_command =
button_font_color = #ffffff 100
button_padding = 2 2
button_background_id = 5
button_centered = 1
button_max_icon_size = 20

and nothing happens )) I don't fully understand that panel_items-thing , I did it to "LTSCP" and commented that windows-like menu, but I cant add that weather script, because of panel_items or what?

yep, had to erase API and city info for privacy causes tongue icons exists in catalogs.


hate manuals :)

Offline

#6 2021-02-11 01:14:55

damo
....moderator....
Registered: 2015-08-20
Posts: 6,529

Re: [SOLVED] tint2-weather - a small modification

^ What happens if you run the command, as written, in a terminal?

~/.config/tint2/executors/weather.sh

You probably need to do

./home/<user>/.config/tint2/executors/weather.sh

Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#7 2021-02-11 06:09:21

ohnonot
...again
Registered: 2015-09-29
Posts: 5,342
Website

Re: [SOLVED] tint2-weather - a small modification

I don't think tint2rc likes "~". I have used "$HOME" instead, that works.


Please use CODE tags for code.
Search youtube without a browser: repo | thread
BL quote proposals to this thread please.
my repos / my repos

Offline

#8 2021-02-11 08:13:13

ceeslans
Member
Registered: 2015-09-30
Posts: 105

Re: [SOLVED] tint2-weather - a small modification

giantowl: the script requires 'jq' (a lightweight command-line JSON processor). Please verify this is installed on your system.

Please follow suggestion by damo. the terminal output should show the current temperature.

And you need to add an 'E' under panel_items, so something like this:

panel_items = LTESCP 

otherwise the weather script is not executed in your tint2
.

Last edited by ceeslans (2021-02-11 08:24:48)

Offline

#9 2021-02-11 09:01:28

giantowl
Member
From: another place
Registered: 2021-02-08
Posts: 10

Re: [SOLVED] tint2-weather - a small modification

damo wrote:

^ What happens if you run the command, as written, in a terminal?

~/.config/tint2/executors/weather.sh

You probably need to do

./home/<user>/.config/tint2/executors/weather.sh
nik@Bender2:~$ /home/nik/.config/tint2/executors/weather.sh
bash: /home/nik/.config/tint2/executors/weather.sh: access denied
nik@Bender2:~$ sudo /home/nik/.config/tint2/executors/weather.sh
sudo: /home/nik/.config/tint2/executors/weather.sh: command not found
damo wrote:

I don't think tint2rc likes "~". I have used "$HOME" instead, that works.

"$HOME" gives me path from "root" instead of "home"

ceeslans wrote:

giantowl: the script requires 'jq' (a lightweight command-line JSON processor). Please verify this is installed on your system.

Please follow suggestion by damo. the terminal output should show the current temperature.

And you need to add an 'E' under panel_items, so something like this:

panel_items = LTESCP 

otherwise the weather script is not executed in your tint2
.

jq (1.5+dfsg-2+b1) is on the board.
added "E", corrected the path and still nothing...

tint2 conf

#---------------------------------------------
# TINT2 CONFIG FILE "myconf lithium.tint2rc"
#
# A simple theme. Note that many properties are set to "0"
# Please see 'man tint2' for full configuration options
#---------------------------------------------
#---- Generated by tint2conf 0320 ----
# See https://gitlab.com/o9000/tint2/wikis/Configure for
# full documentation of the configuration options.
#
# Tweaked for BunsenLabs
#
#-------------------------------------
# Gradients
#-------------------------------------
# Backgrounds
# Background 1: Iconified task, Panel
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #cccccc 0
border_color = #828282 0
background_color_hover = #cccccc 0
border_color_hover = #828282 0
background_color_pressed = #cccccc 0
border_color_pressed = #828282 0

# Background 2: Active task
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #000000 40
border_color = #d8d8d8 0
background_color_hover = #ffffff 20
border_color_hover = #d8d8d8 0
background_color_pressed = #ffffff 30
border_color_pressed = #d8d8d8 0

# Background 3: Default task (inactive tasks that are not iconified)
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #000000 0
border_color = #000000 0
background_color_hover = #ffffff 10
border_color_hover = #000000 0
background_color_pressed = #ffffff 20
border_color_pressed = #000000 0

# Background 4: Urgent task
rounded = 0
border_width = 1
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #ff0034 20
border_color = #ff0034 0
background_color_hover = #ffffff 20
border_color_hover = #ffffff 0
background_color_pressed = #ffffff 30
border_color_pressed = #ffffff 0

# Background 5: Inactive taskbar
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #000000 20
#border_color = #000000 0
#background_color_hover = #ff0000 100
#border_color_hover = #000000 0
#background_color_pressed = #808384 0
#border_color_pressed = #000000 0

# Background 6: Active taskbar
rounded = 0
border_width = 1
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #ffffff 5
border_color = #000000 0
#background_color_hover = #000000 0
#border_color_hover = #000000 0
#background_color_pressed = #000000 0
#border_color_pressed = #000000 0

# Background 7: Tooltip
rounded = 2
border_width = 1
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #3D6270 100
border_color = #3D6270 100
background_color_hover = #000000 0
border_color_hover = #000000 0
background_color_pressed = #000000 0
border_color_pressed = #000000 0

#-------------------------------------
# Panel
panel_items = LTESCP
panel_size = 99% 30
panel_margin = 0 0
panel_padding = 6 0 0
panel_background_id = 1
wm_menu = 1
panel_dock = 0
panel_position = bottom center horizontal
panel_layer = bottom
panel_monitor = all
panel_shrink = 0
autohide = 0
autohide_show_timeout = 0.3
autohide_hide_timeout = 1.5
autohide_height = 6
strut_policy = follow_size
panel_window_name = tint2
disable_transparency = 0
# enable mouse_hover
mouse_effects = 1
font_shadow = 0
mouse_hover_icon_asb = 100 0 10
mouse_pressed_icon_asb = 100 0 0
scale_relative_to_dpi = 0
scale_relative_to_screen_height = 0

#-------------------------------------
# Taskbar - Panel item = T
taskbar_mode = multi_desktop
taskbar_hide_if_empty = 0
taskbar_padding = 2 0 4 (the last number determines icon spacing)

taskbar_background_id = 5
taskbar_active_background_id = 6

taskbar_name = 0
taskbar_hide_inactive_tasks = 0
taskbar_hide_different_monitor = 0
taskbar_hide_different_desktop = 0
taskbar_always_show_all_desktop_tasks = 0
taskbar_name_padding = 0 0
taskbar_name_background_id = 0
taskbar_name_active_background_id = 0
taskbar_name_font = Sans 9
taskbar_name_font_color = #828282 100
taskbar_name_active_font_color = #828282 100
taskbar_distribute_size = 0
taskbar_sort_order = none
task_align = left

#-------------------------------------
# Task
task_text = 0
task_icon = 1
task_centered = 1
urgent_nb_of_blink = 20
task_maximum_size = 30 30
task_padding = 2 2
task_font = Sans 9
task_tooltip = 1
task_thumbnail = 0
task_thumbnail_size = 210
task_font_color = #d8d8d8 60
task_active_font_color = #d8d8d8 100
task_urgent_font_color = #ffffff 100
task_iconified_font_color = #d8d8d8 60
task_icon_asb = 70 0 0
task_active_icon_asb = 100 0 0
task_urgent_icon_asb = 100 0 0
task_iconified_icon_asb = 50 0 0
task_background_id = 3
task_active_background_id = 2
task_urgent_background_id = 4
task_iconified_background_id = 1
mouse_left = toggle_iconify
mouse_middle = none
mouse_right = close
mouse_scroll_up = toggle
mouse_scroll_down = iconify

#-------------------------------------
# System tray (notification area) - Panel item = S
systray_padding = 1 1 1
systray_background_id = 5
systray_sort = right2left
systray_icon_size = 22
systray_icon_asb = 100 0 0
systray_monitor = primary
systray_name_filter =

#-------------------------------------
# Launcher - Panel item = L
launcher_padding = 8 4 4
launcher_background_id = 5
launcher_icon_background_id = 0
launcher_icon_size = 0
launcher_icon_asb = 100 0 0
launcher_icon_theme = Papirus-Bunsen-Dark-bluegrey
launcher_icon_theme_override = 0
startup_notifications = 0
launcher_tooltip = 1
launcher_item_app = /usr/share/applications/chromium.desktop
launcher_item_app = /usr/share/applications/firefox-esr.desktop 
launcher_item_app = /usr/share/applications/bl-file-manager.desktop
launcher_item_app = /usr/share/applications/bl-terminal-emulator.desktop

#-------------------------------------
# Clock - Panel item = C

#24hr clock (for seconds, use %H:%M:%S)
# See 'man strftime' for other time and date formats.
time1_format = %H:%M
#12hr clock with am/pm (%p for AM/PM)
#time1_format = %l:%M%P
time2_format =
#font example
#time1_font = Futura Bk BT bold 10
time1_font = Sans bold 12
time1_timezone =
time2_timezone =
clock_font_color = #DFDFDF 100
clock_padding = 6 0 6
clock_background_id = 5

#The day and date
clock_tooltip = %A %F
clock_tooltip_timezone =
#Show calendar
clock_lclick_command = gsimplecal
clock_rclick_command = bl-beepmein-pipemenu --standalone
clock_mclick_command =
clock_uwheel_command =
clock_dwheel_command =


#-------------------------------------
# Battery
battery_tooltip = 1
battery_low_status = 20
battery_low_cmd = notify-send "battery low"
battery_full_cmd =
bat1_font = Monospace 8
bat2_font = Monospace 8
battery_font_color = #b5b5b5 100
bat1_format =
bat2_format =
battery_padding = 2 0
battery_background_id = 0
battery_hide = 96
battery_lclick_command =
battery_rclick_command =
battery_mclick_command =
battery_uwheel_command =
battery_dwheel_command =
ac_connected_cmd =
ac_disconnected_cmd =

#-------------------------------------
# Executor 6	(weather local)
execp = new
execp_command = /home/nik/.config/tint2/executors/weather.sh
execp_interval = 300
execp_has_icon = 1
execp_cache_icon = 1
execp_continuous = 0
execp_markup = 1
execp_tooltip = Current weather --> leftclick for 7days weather forecast
execp_lclick_command = exo-open https://openweathermap.org/city/XXXXXX
execp_rclick_command = 
execp_mclick_command = 
execp_uwheel_command = 
execp_dwheel_command = 
execp_font = DejaVu Sans Condensed 9
execp_font_color = #ffffff 100
execp_padding = 6 0
execp_background_id = 0
execp_centered = 0
execp_icon_w = 24
execp_icon_h = 24 

#-------------------------------------
# Tooltip
tooltip_show_timeout = 0
tooltip_hide_timeout = 0
tooltip_padding = 8 8
tooltip_background_id = 7
tooltip_font_color = #d3dae3 100
tooltip_font = Sans normal 10

#-------------------------------------
# Buttons - Panel item = P

# Show Root Menu (BL-flame icon)
#button = new
#button_icon = start-here-bunsenlabs
#button_text =
#button_tooltip = Main Menu
#button_lclick_command = jgmenu_run
#button_rclick_command =
#button_mclick_command =
#button_uwheel_command =
#button_dwheel_command =
#button_font_color = #ffffff 100
#button_padding = 2 2
#button_background_id = 5
#button_centered = 1
#button_max_icon_size = 28


# Exit dialog (Power icon)
button = new
#button_icon = /usr/share/images/bunsen/exit/light/poweroff.png
button_icon = system-shutdown-symbolic
button_text =
button_tooltip = Logout/Shutdown...
button_lclick_command = bl-exit
button_rclick_command =
button_mclick_command =
button_uwheel_command =
button_dwheel_command =
button_font_color = #ffffff 100
button_padding = 2 2
button_background_id = 5
button_centered = 1
button_max_icon_size = 20

weather.sh

#!/bin/bash
#
# ===========================================================
# Based on script from @Anachron's i3blocks, as well as 
# @Addy's icon additions and @Nili's network-connection check
# Mod by @ceeslans, to draw icons from tint2 config folder
# ===========================================================

# Open Weather Map API code, register to http://openweathermap.org to get one :
API_KEY="4f02c97d03cc2f772339b1295dcxxxxx"

# Check on http://openweathermap.org/find :
CITY_ID="XXXXXX"

# Select applicable temperature symbol "˚C" or "˚F" :
SYMBOL_CELSIUS="˚C"

# Change "Text" to your preferred language :
TEXT_SNOW="Snow"
TEXT_RAINY="Rainy"
TEXT_DRIZZLE="Drizzle"
TEXT_SHOWERS="Showers"
TEXT_SUNNY="Sunny"
TEXT_CLEAR="Clear"
TEXT_CLOUDY="Cloudy"
TEXT_OVERCAST="Overcast"
TEXT_STORM="Storm"
TEXT_FOG="Fog"

# Show Papirus weather-icons :
ICONPATH="/home/nik/.config/tint2/executors/icons/weather/"
# or show original openweathermap weather-icons :
#ICONPATH="/home/nik/.config/tint2/executors/icons/weather/openweathermap/"

# Don't change these lines, unless you know what you're doing...
if ping -qc1 1.1.1.1 >/dev/null; then
 WEATHER_URL="http://api.openweathermap.org/data/2.5/weather?id=${CITY_ID}&appid=${API_KEY}&units=metric"
else
	echo "${ICONPATH}404.png"
	echo "Link Down"
fi

WEATHER_INFO=$(wget -qO- "${WEATHER_URL}")
WEATHER_MAIN=$(echo "${WEATHER_INFO}" | grep -o -e '\"main\":\"[A-Za-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_TEMP=$(echo "${WEATHER_INFO}" | grep -o -e '\"temp\":\-\?[0-9]*' | awk -F ':' '{print $2}' | tr -d '"')
WEATHER_ICON=$(echo "${WEATHER_INFO}" | grep -o -e '\"icon\":\"[0-9a-z]*\"' | awk -F ':' '{print $2}' | tr -d '"')

# To add short condition description in the toolbar, comment out # ${TEXT-*} :

if [[ "${WEATHER_MAIN}" = *Snow* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SNOW}"
    
elif [[ "${WEATHER_MAIN}" = *Rain* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}"	# "${TEXT_RAINY}"

elif [[ "${WEATHER_MAIN}" = *Drizzle* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_DRIZZLE}"

elif [[ "${WEATHER_MAIN}" = *Shower* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SHOWERS}"

elif [[ "${WEATHER_MAIN}" = *Sunny* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_SUNNY}"
	
elif [[ "${WEATHER_MAIN}" = *Clear* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_CLEAR}"
	
elif [[ "${WEATHER_MAIN}" = *Cloud* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_CLOUDY}"

elif [[ "${WEATHER_MAIN}" = *Overcast* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_OVERCAST}"
    
elif [[ "${WEATHER_MAIN}" = *Storm* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_STORM}"
    
elif [[ "${WEATHER_MAIN}" = *Fog* ]]; then
	echo "${ICONPATH}${WEATHER_ICON}"
	echo "${WEATHER_TEMP}${SYMBOL_CELSIUS}" # "${TEXT_FOG}"

else
	echo "${ICONPATH}04.png"
    echo "${WEATHER_TEMP}${SYMBOL_CELSIUS} ${WEATHER_MAIN}"
fi 

I mean, maybe I do not want this weather script anymore but I have spend too many time for solving this DDDD


hate manuals :)

Offline

#10 2021-02-11 09:17:09

unklar
Member
Registered: 2015-10-31
Posts: 1,384

Re: [SOLVED] tint2-weather - a small modification

giantowl wrote:
nik@Bender2:~$ /home/nik/.config/tint2/executors/weather.sh
bash: /home/nik/.config/tint2/executors/weather.sh: access denied

^your script is not executable   wink

Offline

#11 2021-02-11 09:31:47

giantowl
Member
From: another place
Registered: 2021-02-08
Posts: 10

Re: [SOLVED] tint2-weather - a small modification

unklar wrote:
giantowl wrote:
nik@Bender2:~$ /home/nik/.config/tint2/executors/weather.sh
bash: /home/nik/.config/tint2/executors/weather.sh: access denied

^your script is not executable   wink

ikr ) what does it mean? I found the script in this topic and this is not mine and I don't know what to do because of this )


hate manuals :)

Offline

#12 2021-02-11 09:44:26

unklar
Member
Registered: 2015-10-31
Posts: 1,384

Re: [SOLVED] tint2-weather - a small modification

^the script must be executable

chmod +x /home/nik/.config/tint2/executors/weather.sh

or
right click on the file weather.sh -->Properties-->Access rights-->Program check mark, "File may be started as program"   smile

Offline

#13 2021-02-11 09:49:04

ceeslans
Member
Registered: 2015-09-30
Posts: 105

Re: [SOLVED] tint2-weather - a small modification

deleted   ---   unklar is way faster.... smile

Last edited by ceeslans (2021-02-11 09:50:28)

Offline

#14 2021-02-11 09:56:10

giantowl
Member
From: another place
Registered: 2021-02-08
Posts: 10

Re: [SOLVED] tint2-weather - a small modification

unklar wrote:

^the script must be executable

chmod +x /home/nik/.config/tint2/executors/weather.sh

or
right click on the file weather.sh -->Properties-->Access rights-->Program check mark, "File may be started as program"   smile

wtf man?) linux rejects me DD))) double solved!!! )) big thanks!

btw it reminds me one of my friend, who called me to help her because she can't connect to wifi on her windows laptop and Fn+F12 was the problem salvation hmm

Last edited by giantowl (2021-02-11 10:31:32)


hate manuals :)

Offline

#15 2021-02-15 17:01:54

Nili
Member
From: $HOME/♫♪
Registered: 2015-09-30
Posts: 1,007
Website

Re: [SOLVED] tint2-weather - a small modification

@ceeslans I don't have tint2 nor openbox at this time to test it, but i'm using a more simple code for wttr.in on my conky.

texeci 500 curl -s 'v3.wttr.in/London?format=%t' 2>&1 || echo "Error"

If the network goes down or loss the ping, it repports the error sign. This code provide only a simple text like +4°C
curl must be installed.

Offline

Board footer

Powered by FluxBB