YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#801 Post by fredx181 »

Hi all, another change to the alarm script, included now the earlier suggestion for setting "relative" time (thanks vovchik), attached yalarm2
(the config file is different: ~/.yalrm2, so not compatible with earlier versions).

EDIT 2019-12-05: Canceling from tray needed a fix, should work now, re-attached.
See also here:
http://murga-linux.com/puppy/viewtopic. ... 88#1043688

Fred
Attachments
yalarm2.tar.gz
yad alarm updated 2019-12-05, extract and run yalarm2
(3.01 KiB) Downloaded 175 times
2019-12-04-191247_686x218_scrot.png
yalarm2 with relative time option
(46.08 KiB) Downloaded 655 times
Last edited by fredx181 on Thu 05 Dec 2019, 10:40, edited 1 time in total.

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#802 Post by dancytron »

fredx181 wrote:A L A R M !! :lol: :lol:
Image

Hi, no need to be alarmed :wink: it's just about a new alarm script (attached) with changes and improvements.
/snip

Fred
Thank God. Finally a decent alarm clock that doesn't take 100 meg of dependencies.

I've literally been using a 7 hour long countdown video I downloaded off of youtube that plays music after 7 hours.

I will install immediately and report back.

slavvo67
Posts: 1610
Joined: Sat 13 Oct 2012, 02:07
Location: The other Mr. 305

#803 Post by slavvo67 »

Well, you didn't report back so I guess you overslept and the alarm didn't work. LOL

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#804 Post by dancytron »

slavvo67 wrote:Well, you didn't report back so I guess you overslept and the alarm didn't work. LOL
The big test is tomorrow morning. :D

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#805 Post by fredx181 »

Argolance wrote:When I cancel tray and exit from the right click menu, the systray icon is closed but the process not... and the bells ring!
Now I could reproduce that, but it's only sometimes that the canceling doesn't work, can't understand why yet, will look for a fix.

EDIT: The solution was actually quite simple, previously the code for cancelling was too complicated and therefore fragile, should be OK now, re-attached here:
http://murga-linux.com/puppy/viewtopic. ... 15#1043415
and here (v2):
http://murga-linux.com/puppy/viewtopic. ... 29#1043629

Fred

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#806 Post by Argolance »

Bonjour,
:arrow: [EDIT]: yalrm 0.5.1

Cordialement.
Last edited by Argolance on Fri 20 Dec 2019, 16:49, edited 2 times in total.

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#807 Post by dancytron »

fredx181 wrote:Hi all, another change to the alarm script, included now the earlier suggestion for setting "relative" time (thanks vovchik), attached yalarm2
(the config file is different: ~/.yalrm2, so not compatible with earlier versions).

EDIT 2019-12-05: Canceling from tray needed a fix, should work now, re-attached.
See also here:
http://murga-linux.com/puppy/viewtopic. ... 88#1043688

Fred
This is working great for me.

Is a snooze button (ideally the space bar but choosing from the task bar would be okay too) with a settable duration possible?

stemsee

#808 Post by stemsee »

Thanks Argolance

yalrm works well on dpupbuster64_8.0.0

User avatar
josejp2424
Posts: 556
Joined: Sun 01 Aug 2010, 22:35
Contact:

yalrm-gettex

#809 Post by josejp2424 »

Argolance wrote:Bonjour,
Here is yalrm 0.2 which incorporates the latest changes made by fredx181 without the countdown since other programs :arrow: like this one for example already exist.
I added the "Frequency" option which allows you to set the blinking (from 0.1 to 2 seconds) according to the type of icons you choose: 5 themes are available.
Internationalized: fr

[EDIT]: if already existing, the hidden /root/.yalrm file must be deleted for the script to run properly because it creates a directory with the same name at startup.

Cordialement.
hi Argolance.

It is very good.
there would be the possibility of adding gettex?.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#810 Post by Argolance »

Bonjour,
josejp2424 wrote:there would be the possibility of adding gettex?.
Yes obviously: the script is internationalized using gettext and the pot file is /usr/share/doc/2PDE/yalrm/yalrm.pot (I note I should have put it to /usr/share/doc/nls/yalrm) :oops: .
Thanks.

Additional note regarding the countdown option: I forgot to mention the excellent :arrow: pTiming by zigbert for "relative" time alarm.

Cordialement.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#811 Post by Argolance »

Bonjour,
Does anyone know how to have the standard yad buttons labels (ok, cancel, yes, no, close, quit, etc...) in the user's language? The old versions of yad did it right!
___________________________________________________
Something else, for those who would be interested in a way of customizing yad windows and widgets, :arrow: I found this...

Image
Cordialement.

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

Re: Alarm script

#812 Post by fredx181 »

dancytron wrote:
fredx181 wrote:Hi all, another change to the alarm script, included now the earlier suggestion for setting "relative" time (thanks vovchik), attached yalarm2
(the config file is different: ~/.yalrm2, so not compatible with earlier versions).

EDIT 2019-12-05: Canceling from tray needed a fix, should work now, re-attached.
See also here:
http://murga-linux.com/puppy/viewtopic. ... 88#1043688

Fred
This is working great for me.

Is a snooze button (ideally the space bar but choosing from the task bar would be okay too) with a settable duration possible?
I'm not sure if it's what you're looking for, but I added some sort of pause options to the "alarm running" icon menu.

Also made other improvements:
Now in any case when choosing Stop... from menu, the sound will stop immediately, also when selecting pause (but named "Stop alarm and restart after ... min", to avoid confusion)
Added 'Info' to "waiting" tray-icon menu with some explanation about duration interval etc..
Fixed that everytime when the function "alrm" (inside script) runs, that the process hangs, even when it seems to be finished (resulted in many zombie processes if you ran the script several times)

Fred
Attachments
2019-12-14-001220_771x460_scrot_671x400.jpg
(56.77 KiB) Downloaded 737 times
yalarm3.tar.gz
yalarm3
(3.86 KiB) Downloaded 161 times

achim
Posts: 48
Joined: Thu 13 Apr 2017, 19:36
Location: Germany

Manpages with yad

#813 Post by achim »

Hello experts,

the following script for displaying the man page via YAD works quite well so far. However, I would like to color the background of the browser page (something like this: # fef1e0). So far I have no working idea. So I want to ask if any of you have a suggestion.

Thank you in advance.

achim

Code: Select all

#! /bin/bash
#
function close_exit () {
    echo "close and exit"
    kill -s SIGUSR1 $YAD_PID
}
#
cd /usr/bin
brows="x-www-browser -new-tab"
asked="$1"
help="
Enter a command here for help on the function and options:"
m_del="/tmp/mpage"
if [[ -f "${m_del}" ]]; then
rm -f /tmp/mpage
fi
#
function y_brow () {
	/usr/bin/man $asked > /tmp/mpage
	$brows /tmp/mpage
}
export -f y_brow
while [ ! -n "$asked" ]
	do asked=$(yad --text="  $help" --entry --title="  Linux instructions" --width=500 --height=250  \
	--borders=10 --image=gtk-help --image-on-top --center --window-icon="gtk-help" --separator="\n")
	
	if [ "$?" = "1" ]
		then
		exit 1
	fi
done
man $asked | yad --text-info --title="  Help file too $asked" --width=950 --height=850 --button="break up":1 --button="Send to browser":0 \
--borders=10 --image=gtk-help --image-on-top --center --window-icon="gtk-help" --fore="black" --back="#fef1e0" --separator="\n"

	acd=$(echo $?)									# Exit-Code auswerten
	
	if [[ $acd == 1 ]] || [[ $acd == 9 ]] || [[ $acd == 252 ]]; then	# Taste Abbrechen gedrückt || Skript-Ende mit [X] || Skript-Ende mit [Esc]
	bash -c close_exit &>/dev/null
	exit
	else
	y_brow
	bash -c close_exit &>/dev/null
	exit
fi
Last edited by achim on Sat 14 Dec 2019, 21:26, edited 1 time in total.

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

Re: Alarm script

#814 Post by dancytron »

fredx181 wrote:
dancytron wrote:
fredx181 wrote:Hi all, another change to the alarm script, included now the earlier suggestion for setting "relative" time (thanks vovchik), attached yalarm2
(the config file is different: ~/.yalrm2, so not compatible with earlier versions).

EDIT 2019-12-05: Canceling from tray needed a fix, should work now, re-attached.
See also here:
http://murga-linux.com/puppy/viewtopic. ... 88#1043688

Fred
This is working great for me.

Is a snooze button (ideally the space bar but choosing from the task bar would be okay too) with a settable duration possible?
I'm not sure if it's what you're looking for, but I added some sort of pause options to the "alarm running" icon menu.

Also made other improvements:
Now in any case when choosing Stop... from menu, the sound will stop immediately, also when selecting pause (but named "Stop alarm and restart after ... min", to avoid confusion)
Added 'Info' to "waiting" tray-icon menu with some explanation about duration interval etc..
Fixed that everytime when the function "alrm" (inside script) runs, that the process hangs, even when it seems to be finished (resulted in many zombie processes if you ran the script several times)

Fred
Great. I'll test it out soon.

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#815 Post by fredx181 »

dancytron wrote:Great. I'll test it out soon.
And...? You didn't sleep all those days, I guess :lol:

Anyway here's a new yalarm, with some changes made to the yad dialog (thanks Argolance ! , for the digital time display setup ) and more.

Fred
Attachments
2019-12-19-171733_765x404_scrot.png
yalarm
(82.98 KiB) Downloaded 633 times
yalrm.tar.gz
Extract and run yalarm inside "yalrm" folder
(41.42 KiB) Downloaded 190 times

dancytron
Posts: 1519
Joined: Wed 18 Jul 2012, 19:20

#816 Post by dancytron »

Sorry, it worked fine.

Will install the new version.

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#817 Post by Argolance »

Bonjour,
Here are the internationalized version of yalarm script above, the *.pot and the French *.mo files.
Translations welcome!

:!: [EDIT]: Sorry, missing

Code: Select all

. gettext.sh
at line 147 to get the text of the popup window...

Cheers!
Attachments
yalarm-script_pot_mo-fr.tar.gz
Fixed
(7.01 KiB) Downloaded 158 times
191220_100602_792x391_easyshot.jpg
(37.45 KiB) Downloaded 573 times

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#818 Post by Argolance »

Bonsoir,
To understand and learn how some yad options work, I played with yalarm and made this version that fredx181 was kind enough to modify according to the latest improvements of its script.
Merci.

Cordialement.
Attachments
191212_225233_1064x611_easyshot.jpg
(108.48 KiB) Downloaded 555 times
yalrm-0.5.1.pet
(119.97 KiB) Downloaded 176 times

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#819 Post by Mike Walsh »

Afternoon, all.

Now then; I need a wee bit of instruction here, please.

I use variations on the following script to place icons in the 'system-tray' area, in order to have commonly-used items permanently available:-

Code: Select all

#!/bin/sh
#
#YAD 'one-liner' from musher0 / fredx181, to place executable tray icon in notification area
#
yad --notification --text="Brightness control" --command='./usr/local/bin/Bright' --image='/usr/local/lib/X11/pixmaps/Bright.png' 2>/dev/null
Which works very well for what I want it for.

What I would like to know is:-

What would be the easiest way possible to add a simple right-click command to this? All I want to be able to do is to right-click the tray icon, have 'Quit' (or 'Leave', or 'Exit', or something along those lines come up), and click on it, so that the tray-icon will then disappear again.

I found this thread from Stu91 (from several years back):-

http://www.murga-linux.com/puppy/viewto ... 1604b53c46

.....but it's rather too much like overkill for my needs. I simply want a right-click 'Quit' function. I've been trawling the 'net for a couple of hours or more, and can't really find anything that'll help; most of the stuff I'm getting up seems to be all about adding commands to an existing right-click context menu in the various Linux file-managers.....

Any advice/assistance will, as always, be very much appreciated. TIA.


Mike. :wink:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#820 Post by fredx181 »

Hi Mike, something like this ?

Using a named pipe and added --listen and --no-middle to the notification command.
(without --no-middle the icon quits by mouse middle click)

Code: Select all

#!/bin/sh

# function quit_tray
quit_tray () {
# quit tray
echo "quit" > $PIPE
# cleanup, remove $PIPE
rm -f $PIPE
}; export -f quit_tray 

# create PIPE
export PIPE="/tmp/Y_NOTI_BRIGHT.$RANDOM"
mkfifo $PIPE

# attach a file descriptor to the file
exec 3<> $PIPE

# send menu to $PIPE
echo menu:"Quit!bash -c quit_tray!gtk-quit" >$PIPE &

yad --notification --listen --no-middle --text="Brightness control" --command='./usr/local/bin/Bright' --image='/usr/local/lib/X11/pixmaps/Bright.png' <&3 
To make more menu entries it would be something like:

Code: Select all

echo menu:"Quit!bash -c quit_tray!gtk-quit| \
NAME!COMMAND!ICON| \
NAME!COMMAND!ICON" >$PIPE &
EDIT: Just thought that it can be much more simple with --menu option, so then as a one-liner only:

Code: Select all

yad --notification --item-separator=":" --no-middle --text="Brightness control" --command='./usr/local/bin/Bright' --image='/usr/local/lib/X11/pixmaps/Bright.png' --menu="Quit:quit:gtk-quit"
Fred

Post Reply