You are not logged in.

#26 2017-10-31 20:22:58

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Tint2 Executors and Buttons.

@Steve: openbox's actions have a <prompt></prompt> option that can be used for a 2-stage logout, example here:

https://bbs.archlinux.org/viewtopic.php … 16#p485116

I must admit though that I haven't tested that with a modern version of openbox.

Last edited by Head_on_a_Stick (2017-10-31 20:23:19)


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#27 2018-09-28 12:41:52

S7.L
Member
Registered: 2018-09-16
Posts: 102

Re: Tint2 Executors and Buttons.

Hi, im following the OP on these tint2 executors and would like uptime.py to not show the seconds and just hour + minute, could someone please let me know how this would be possible to do with below ? Or maybe there is a bash one liner that could be insterted instead of the python script?

#!/usr/bin/env python

from datetime import timedelta

with open('/proc/uptime', 'r') as f:
    uptime_seconds = float(f.readline().split()[0])
    uptime_seconds = int(uptime_seconds)
    uptime_string = str(timedelta(seconds = uptime_seconds))

print("Uptime: " + uptime_string)

edit update:

I found and modified a bash one liner. My edit just shows hours and minutes leaving out the days, but i think my edit could just be the text output and the function still remains.

uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes."}'

to below for use in tint2 executor.

printf "Uptime: " && uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}}{print h+0,"h",m+0,"m"}'

Last edited by S7.L (2018-09-28 13:57:15)


"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate."...Voilà!

~ V

Offline

#28 2018-09-29 04:03:42

johnraff
nullglob
From: Nagoya, Japan
Registered: 2015-09-09
Posts: 4,673
Website

Re: Tint2 Executors and Buttons.

^You might also consider 'uptime -p' .

Difference:

john@helium:~$ uptime
 13:00:55 up  2:09,  2 users,  load average: 0.16, 0.17, 0.18
john@helium:~$ uptime -p
up 2 hours, 9 minutes

If you just wanted to snip out whatever 'uptime' gave after "up" and before the comma:

john@helium:~$ [[ $(uptime) =~ up\ ([^,]+), ]] && echo ${BASH_REMATCH[1]}
2:11

John
--------------------
( a boring Japan blog , Japan Links, idle twitterings  and GitStuff )
In case you forget, the rules.

Offline

#29 2018-09-29 10:07:30

S7.L
Member
Registered: 2018-09-16
Posts: 102

Re: Tint2 Executors and Buttons.

^ Thanks for the reply but i am getting below result. Im no bash programmer and i would really like to find out what is going on/understand these commands. Im going to take an online course or tutorial on it.

~$ [[ $(uptime) =~ up\ ([^,]+), ]] && echo ${BASH_REMATCH[1]}
10 min

"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate."...Voilà!

~ V

Offline

#30 2018-09-29 12:47:07

malm
jgmenu developer
Registered: 2016-10-13
Posts: 227
Website

Re: Tint2 Executors and Buttons.

^

What @johnraff suggested in nifty. An alternative could be:

uptime | awk '{ print $3 }' | tr -d ','

The awk command simply prints the third field, using space as the field separator.
You can use the -F option to to specify a different separator if you want to carve it up differently.

The tr -d command simple deletes characters (the comma in this case)

Online

#31 2018-10-14 23:30:45

nwg
Member
From: Poland
Registered: 2018-10-14
Posts: 5
Website

Re: Tint2 Executors and Buttons.

Hi,

I took a look at cpu.py posted by @tknomanzr, and found it a brilliant idea. Thanks! As the author mentioned, with the python-psutil module we may obtain quite a lot of information. Take a look at the executor below:

Overview

Description:

Fields description

Feel free to use the code posted on my notepad.

Offline

#32 2018-10-15 05:13:00

malm
jgmenu developer
Registered: 2016-10-13
Posts: 227
Website

Re: Tint2 Executors and Buttons.

That’s great. Thanks for sharing.

Online

#33 2018-10-18 14:04:06

nwg
Member
From: Poland
Registered: 2018-10-14
Posts: 5
Website

Re: Tint2 Executors and Buttons.

I've just tested the cpu-fan-memory.py script on BunsenLabs Linux, and applied some fixes, for it to run on older python and python-psutil versions. Also there's no longer need to hash out / un-hash lines to customize output. It can be done with an optional argument. Updated script has been published here. All my scripts/executors are also available as the GitHub project.

bunsenlabs-tint2-executors

Two scripts running: `cpu-fan-memory.py` and `bbswitch-status.sh`. Since BunsenLabs Linux was running on VM here, the display is limited by missing sensors. Slightly broader view (Arch Linux screenshot) looks like below:

bunsenlabs-tint2-executors

Last edited by nwg (2018-10-21 00:24:32)

Offline

#34 2018-10-25 23:17:34

nwg
Member
From: Poland
Registered: 2018-10-14
Posts: 5
Website

Re: Tint2 Executors and Buttons.

I've just finished publishing all the stuff I had in mind on GitHub. Below you'll find a screen showing most of the scripts in two Tint2 panels.

My Tint2 panels

Last edited by nwg (2018-10-25 23:18:21)

Offline

#35 2018-10-26 13:17:32

S7.L
Member
Registered: 2018-09-16
Posts: 102

Re: Tint2 Executors and Buttons.

Well done nwg, looks amazing.


"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate."...Voilà!

~ V

Offline

#36 2018-10-27 05:38:46

ohnonot
...again
Registered: 2015-09-29
Posts: 3,194
Website

Re: Tint2 Executors and Buttons.

oops post - disregard please.

Last edited by ohnonot (2018-10-27 05:39:28)

Offline

#37 2018-10-27 05:43:30

Dobbie03
Resident Metalhead
From: New Zealand
Registered: 2015-09-29
Posts: 1,964
Website

Re: Tint2 Executors and Buttons.

nwg wrote:

I've just finished publishing all the stuff I had in mind on GitHub. Below you'll find a screen showing most of the scripts in two Tint2 panels.

http://nwg.pl/wiki-tint2-executors/my-panels-261018.png

Incredible stuff.  Well done.


I like my Metal like my coffee.......Black!

Offline

#38 2018-10-27 13:20:34

nwg
Member
From: Poland
Registered: 2018-10-14
Posts: 5
Website

Re: Tint2 Executors and Buttons.

Dobbie03 wrote:

Incredible stuff.  Well done.

Thanks! (to you and @S7.L) smile On your ArchLabs should work OOTB. If it comes to BunsenLabs, someone who knows more than myself about Debian packages should check dependencies.

BTW: I would be grateful for feedback on this matter, to improve the project Wiki.

Last edited by nwg (2018-10-27 13:22:22)

Offline

#39 2018-11-16 23:14:48

nwg
Member
From: Poland
Registered: 2018-10-14
Posts: 5
Website

Re: Tint2 Executors and Buttons.

Update to info on my Tint2 executors collection: most of the scripts already look like what I wanted them to. The cpu-fan-mem.py has been separated as another GitHub project called psuinfo. I tested the latter on BunsenLabs (VM) today, and the only I needed to change was 'python3' instead of 'python' in the script header. The rest should work, having proper dependencies installed, but I didn't test them much on Debian. A sample setup may look as below:

sample tint2 executors

Last edited by nwg (2018-11-20 00:44:27)

Offline

#40 2018-11-27 16:31:36

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

Re: Tint2 Executors and Buttons.

Dobbie03 wrote:

Thanks to the awesome Addy I have a weather display

 #!/bin/bash

# I take this script from Anachron's i3blocks
# I only slightly modify this script to add an option to show icon, useful for my tint2 executor
# 'weather -i' = with icon, 'weather' = text only
# Cheers!
# Addy

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

# Check on http://openweathermap.org/find
CITY_ID="your city id here"

URGENT_LOWER=0
URGENT_HIGHER=30

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-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

if [[ "${WEATHER_TEMP}" -lt "${URGENT_LOWER}" ]] || [[ "${WEATHER_TEMP}" -gt "${URGENT_HIGHER}" ]]; then
  exit 33
fi

I have this as a script saved in ~/.bin/weather.  Works a treat

Hello Matt, does ^this bash script still works? I can't gets any data even by adding CITY_ID & API_KEY
Newest updates from Addy github i tested, but still no data on my Tint2.
00vv4hd.png

openweathermap says:

API key will be activated and ready for using within a couple of hours.
You can generate as many API keys as needed for your subscription. We accumulate the total load from all of them.

So far, I generated my API keys few hours ago. I'm not seeing anything?
Have no clue anymore... Anything how to succeed?

Edit: i haven't had wget installed, that was the reason for not getting data. Installed and succeeded.
Sorry for the noise, scripts it's OK.

Thanks!

BR,
Nili

Last edited by Nili (2018-11-27 17:04:41)


Nothing beats peace and quiet. - Tomoki Sakurai

Offline

#41 2018-12-07 19:04:40

o9000
tint2 developer
From: Network Neighborhood
Registered: 2015-10-24
Posts: 396
Website

Re: Tint2 Executors and Buttons.

Very cool!

Offline

Board footer

Powered by FluxBB