You are not logged in.
Something I am working on for moc:
Inspired by ohnonot's mpi-panel, which I've been using for months.
I've posted my python script on gitlab for anyone interested. Going to play with it some more, but I've been using it as-is for the last three days.
I really like the look of the scrolling text on my thicc thin panel. Might do something with a scrolling ticker and twitter updates or sms alerts via KDE Connect on my desktop.
Offline
^ i like it!
my original inspiration for the mpi script was to get the output on 2 or more lines, but i have long since given up on that (i still use the script though).
scrolling makes a lot of sense.
i was also planning to make support for different media players modular.
it's not much work, actually, but still not finished :-(
Offline
i was also planning to make support for different media players modular.
it's not much work, actually, but still not finished :-(
Yeah, I had noticed that looking over your code you have placeholders for MPD and mplayer. I know deadbeef and audacious can output the info easly too; Clementine looked a little more complicated. A little refactoring on mine, and they would integrate cleanly. MOC was my focus, since... thats what I use.
Offline
Got a question more reserved for openbsd users.
Ive created two buttons in tint2 using the following...
shutdown= doas halt -p
This shuts down the computer immediately. I would like a safer option in the button like a 2 step verification.
same with reboot = doas reboot
I cant seem to figure out how to implement a warning/hold message before the command executes.
Any ideas?
Last edited by Steve (2017-10-31 11:58:11)
Offline
^^ figured it out with some googlefu or startpagefu
reboot.sh
#!/bin/sh
echo "Would you like to 'reboot' [y/n]?"
read ans
if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
then
xterm -e doas reboot
fi
if [ $ans = n -o $ans = N -o $ans = no -o $ans = No -o $ans = NO ]
then
echo "rock on"
fi
shutdown.sh
shutdown.sh
#!/bin/sh
echo "Would you like to 'shutdown' [y/n]?"
read ans
if [ $ans = y -o $ans = Y -o $ans = yes -o $ans = Yes -o $ans = YES ]
then
xterm -e doas halt -p
fi
if [ $ans = n -o $ans = N -o $ans = no -o $ans = No -o $ans = NO ]
then
echo "rock on"
fi
tint2 buttons, left click commands.
reboot =
xterm -geometry 65x15 -bg black -fg white -fa 'terminus' -fs 10 -e "ksh -c \"reboot.sh; exec ksh\""
shutdown=
xterm -geometry 65x15 -bg black -fg white -fa 'terminus' -fs 10 -e "ksh -c \"shutdown.sh; exec ksh\""
Not the best of options but it works.
Last edited by Steve (2017-10-31 13:20:01)
Offline
@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)
Offline
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)
Offline
^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
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
^ 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
Offline
^
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)
Offline
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:
Description:
Feel free to use the code posted on my notepad.
Offline
That’s great. Thanks for sharing.
Offline
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.
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:
Last edited by nwg (2018-10-21 00:24:32)
Offline
Well done nwg, looks amazing.
Offline
oops post - disregard please.
Last edited by ohnonot (2018-10-27 05:39:28)
Offline
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.
Incredible stuff. Well done.
"All we are is dust in the wind, dude"
- Theodore "Ted" Logan
"Led Zeppelin didn't write tunes that everybody liked, they left that to the Bee Gees."
- Wayne Campbell
Offline
Incredible stuff. Well done.
Thanks! (to you and @S7.L) 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
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:
Last edited by nwg (2018-11-20 00:44:27)
Offline
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.
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)
Tumbleweed | KDE Plasma
Offline