You are not logged in.
Into the tooltip (if i understand the question). It is not something crucial thought, the way things work now is pretty cool.
Last edited by brontosaurusrex (2017-05-31 21:16:45)
Online
OK. That's a good suggestion.
So we would have a new config option, execp_tooltip_command, that specifies a command to be extecuted, for which the output is converted into tooltip.
Pros:
* simple to configure for one-shot scripts
Cons:
* hard to sync with the main command's output (if the tooltip content is known when the main command executes)
* unclear how it would work with continuous commands
Alternatives:
1. Have a single command as we do now, but stdout is shown in the panel, stderr becomes tooltip. Maybe add a flag to turn this on.
Pros:
* easy to script ( use (>&2 echo "tooltip content") in the main script )
* syncs well with the main content
Cons:
* Not clear how to reset the tooltip for continuous commands. Will need either line count or markers (e.g. TINT2_END_OF_TOOLTIP in the output clears it).
Will need to think about this (I don't have time until mid summer though).
Open to more suggestions.
P.S. Glad you've found the executor useful!
Offline
Another thing (having that master volume in mind): Now the script is only called when some action is performed (lclick, rclick, ...), which is very nice, however the data that this specific script reads can also be updated by other external apps, so perhaps some sort of
execp_lazy_interval = 30 (update every 30 seconds, unless we are mousing around)
would be in order. Or/and
execp_on_mouse_over = true
Online
You can already set the interval to 30 seconds.
But polling doesn't sound like the right solution here. It would be better to write a continously running script that listens for volume change events and updates whenever they happen.
Offline
i've been thinking about a tooltip command myself.
to me this option:
Have a single command as we do now, but stdout is shown in the panel, stderr becomes tooltip. Maybe add a flag to turn this on.
sounds pretty genius.
Offline
I like this "tooltip" idea very much :-)
I have recently disabled the tint2 systray and just used execp entries with some noddy scripts for mail, battery and wifi (using Numix status icons). I like the tweakability factor and think it suits BunsenLabs very well.
Having the option of a tooltip would be perfect to round this off.
Wrt implementation, my first reaction is to just do a once-per mouseover-update using a separate execp command. Maybe something like:
FILE *f;
char buf[4096];
f = popen("my_tooltip_script.sh", "r");
while (fgets(buf, sizeof(buf), f))
stuff...
But my taste can be a bit too simple at times :-) @o9000 is normally right. I have had a quick look at execplugin.c and it probably needs some thought.
Last edited by malm (2017-06-01 21:04:43)
Offline
It would be better to write a continuously running script that listens for volume change events and updates whenever they happen.
I wonder if that is something feasible/logical to do in bash?
Online
Try with alsactl monitor. You will need a recent version of alsa-utils.
Edit: For a continuous script, you probably need to use stdbuf -oL to change its output buffering to line by line. Read each line, if it contains a volume change event read the volume again and display a new output.
Last edited by o9000 (2017-06-02 09:46:53)
Offline
Thanks, I'll try. So if the script would be defined as execp_continuous = somenumber, will that mean that on mouse clicks is restarted at once, or will it wait somenumber all the time? Nevermind, I have to test/rethink this.
Ok so after some tests, without any script modifications, what I have is:
a. # looks good, behaves 'bad':
execp_interval = 0
b. # behaves good enough, looks 'bad':
execp_continuous = 1
there is some sort of redraw issue, video illustrating the case
https://transfer.sh/hygFw/06022017.blasters.1531.mp4
Last edited by brontosaurusrex (2017-06-02 14:56:32)
Online
Please post a full config with your script and any required files (e.g. images if you use any). Thanks.
Offline
@o9000
tint2rc
https://raw.githubusercontent.com/bront … c.printVol
script
https://raw.githubusercontent.com/bront … n/printVol
No images. Font doesn't seem to make any difference.
Last edited by brontosaurusrex (2017-06-02 17:48:39)
Online
Thanks.
Firstly, continuous scripts must run forever and include an event loop:
#!/bin/bash
# print alsa master volume as ascii slider ─────│───── ☐ Ξ · ‖ •
# awk, bc needed
(echo ""; stdbuf -oL alsactl monitor) |
while read
do
debug="nottrue"
volPercents=$(awk -F"[^0-9]*" '/dB/ { print $3 }' <(amixer sget Master))
if (( volPercents > 100 )); then
volPercents=100
fi
if (( volPercents < 0 )); then
volPercents=0
fi
chars="57"
fil="."
pos=" "
pos=" $volPercents " # Enable this to have a display like ─────50─────
[ "$debug" = true ] && { echo "$volPercents volPercents" ;}
faktor=$(echo "scale=2;$chars/100" | bc)
vol=$(echo "scale=0;($volPercents*$faktor+0.5)/1" | bc -l)
[ "$debug" = true ] && { echo "$vol vol" ;}
postloop=$(echo "$chars-$vol" | bc)
if (( vol == chars )); then
postloop=0
fi
preloop=$(echo "$vol-1" | bc)
if (( vol == 0 )); then
preloop=0
postloop=$(echo "$chars-$vol-1" | bc)
fi
[ "$debug" = true ] && { echo "$preloop preloop" ;}
[ "$debug" = true ] && { echo "$postloop postloop" ;}
for i in $(seq 1 $preloop); do
printf "$fil"
done
printf "$pos"
for i in $(seq 1 $postloop); do
printf "$fil"
done
printf "\n"
#printf " $volPercents"
done
Secondly, there was a small bug in the executor, it was printing the last line even if it was not terminated by newline. Since you were using multiple printfs, sometimes it would show partial lines, then a fraction of a second later it would read the remaining output and print it:
..................................
.................................. 61 ......................
which caused that quick resizing/flickering.
I fixed it in tint2, but you will need to wait for the next release, or compile from source.
Last edited by o9000 (2017-06-02 18:18:23)
Offline
I changed your script to print the whole line in one shot, this works with the current tint2:
#!/bin/bash
# print alsa master volume as ascii slider ─────│───── ☐ Ξ · ‖ •
# awk, bc needed
(echo ""; stdbuf -oL alsactl monitor) |
while read
do
debug="nottrue"
volPercents=$(awk -F"[^0-9]*" '/dB/ { print $3 }' <(amixer sget Master))
if (( volPercents > 100 )); then
volPercents=100
fi
if (( volPercents < 0 )); then
volPercents=0
fi
chars="57"
fil="."
pos=" "
pos=" $volPercents " # Enable this to have a display like ─────50─────
[ "$debug" = true ] && { echo "$volPercents volPercents" ;}
faktor=$(echo "scale=2;$chars/100" | bc)
vol=$(echo "scale=0;($volPercents*$faktor+0.5)/1" | bc -l)
[ "$debug" = true ] && { echo "$vol vol" ;}
postloop=$(echo "$chars-$vol" | bc)
if (( vol == chars )); then
postloop=0
fi
preloop=$(echo "$vol-1" | bc)
if (( vol == 0 )); then
preloop=0
postloop=$(echo "$chars-$vol-1" | bc)
fi
[ "$debug" = true ] && { echo "$preloop preloop" ;}
[ "$debug" = true ] && { echo "$postloop postloop" ;}
prefix=$(eval printf "${fil}%.0s" {1..$preloop})
suffix=$(eval printf "${fil}%.0s" {1..$postloop})
printf "${prefix}${pos}${suffix}\n"
#printf " $volPercents"
done
Offline
@o9000: That is just wonderful. I will now behave like I understand what (echo ""; stdbuf -oL alsactl monitor) | ... does
p.s. Added the mute state and changed the prefix=$(eval printf "${fil}%.0s" {1..$preloop}) to what it was (Don't understand it and it wasn't working properly on limits (0% and 100%), dunno how to fix). And recompiled the tint2 with fix (Thanks!).
So "my" continous script is now
https://raw.githubusercontent.com/bront … intVolCont
and my continous tint2rc
https://raw.githubusercontent.com/bront … intVolCont
and video update showing how great everything is now
https://transfer.sh/BMmC4/06022017.nonseasonal.2341.mp4
Last edited by brontosaurusrex (2017-06-02 21:45:50)
Online
(echo ""; stdbuf -oL alsactl monitor) | ...
( A ) | B : starts a subshell (another bash process) executing command(s) A, and pipes the output to B.
echo "" ; ... : prints an empty line, so that the while read loop is executed once at script startup. Otherwise we would wait for the first ALSA event before printing anything, in the meantime the executor would be empty.
stdbuf -oL alsactl monitor is a tricky one.
alsactl monitor runs this loop at line 120 that runs forever and calls print_event, which prints some strings with printf.
What's important is that there is no manual flushing of stdout. That means the data will sit in a C library buffer until the library decides to flush it, i.e. write it to stdout.
For interactive commands (i.e. stdout is a terminal), the C library flushes if the program prints a newline.
For non-interactive commands, such as commands writing to files or pipes (as is the case here) the C library flushes when there is some large number of bytes in the buffer (I think 4K), because that's the optimal size unit for writing to disk.
But here we actually need each line flushed as it is printed. The stdbuf trick forces line buffering for stdout when it is a pipe.
Offline
Looks great!
One more thing. For single digits, a leading zero (or padding with a space) should keep the width constant.
Offline
( A ) | B : starts a subshell (another bash process) executing command(s) A, and pipes the output to B.
I see. (I'll have to reread that post few times ...)
For single digits, a leading zero (or padding with a space) should keep the width constant
Sure, but i'am using non-monospaced font, so what would be the use? (The thing is slightly-variable-width'ish)
Last edited by brontosaurusrex (2017-06-02 23:21:25)
Online
In that case, none.
Offline
The latest code shows standard error as tooltips. From bash, you can use: (>&2 echo "tooltip").
For continuous executors, the tooltip needs to be cleared explicitly, otherwise it keeps growing. You can do this with the VT100 clear screen sequence: (>&2 echo -en "\033[2J").
Looking forward to your feedback.
Offline
Neat! I've tried it with a simple script and it works beautifully.
#!/bin/sh
mail_unread="/usr/share/icons/Numix/scalable/status/mail-unread-symbolic.svg"
mail_read="/usr/share/icons/Numix/scalable/status/mail-read-symbolic.svg"
nr_new_mail=$(ls -1 ~/mail/my_email/INBOX/new | wc -l)
if test ${nr_new_mail} -gt 0
then
echo ${mail_unread}
else
echo ${mail_read}
fi
printf "%b\n" "You have ${nr_new_mail} new mail" >&2
Offline