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
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#821 Post by Mike Walsh »

Hiya, Fred.
fredx181 wrote: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 &
Fred
I like option 2, mate. With a head like mine, 'simple' is good, in my book..! :lol:

No, the modified 'one-liner' is exactly what I was looking for. It means that for some of my commonly-used tray 'utilities', if I don't want 'em there permanent, like, I can just dismiss 'em when I want to.

I want to re-build a few of my small 'tray-based' utilities as ROX-Apps - using your build-scripts - so I can dismiss 'em when required, in the same way that I can clear bigger self-extracters/portables by clicking the window 'X' (or click 'Cancel', or 'Quit' if it exists in the app itself).

Until now, the only way to get rid of the tray icon has been to re-start 'X'.....which isn't always convenient (especially if you're in the middle of summat important, y'know)? I remember I rebuilt a couple of 'em with a pinstall.sh for greengeek, but the way he runs his custom Slacko 560 is as a permanent 'Live' session, never saving except to external media.....so for him it all resets at every boot anyway.

Looking at stu91's script, I didn't think the one-liner could be quite that simple. That is very much appreciated.

Thanks, Fred!


Mike. Image Image

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

#822 Post by fredx181 »

You're welcome Mike !
Until now, the only way to get rid of the tray icon has been to re-start 'X'
Just for info, if you have a middle mouse button (scroll wheel) then you can always quit the tray icon by 'middle' clicking on it.
(that is: if the yad --notification command is without the --no-middle option).

Fred

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

#823 Post by Mike Walsh »

@ Fred:-
fredx181 wrote:Just for info, if you have a middle mouse button (scroll wheel) then you can always quit the tray icon by 'middle' clicking on it.
(that is: if the yad --notification command is without the --no-middle option).
A-ha. Nope, I wasn't aware of that. Shall have to experiment in a few of the other Pups.....see what happens.

Thanks for the tip.


Mike. :wink:

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

#824 Post by fredx181 »

Hi All, Re: Alarm again :)

As I like the themed version by Argolance and want to be able to use setting alarm to "relative" time (checkbox 'Set alarm after minutes/seconds') , I modified his version (hope you don't mind Argolance !).
Because of adding 3 more fields for that, I went for the horizontal view (otherwise the height would be too large).

Fred
Attachments
yalrm-0.6.0.pet
(118.72 KiB) Downloaded 212 times
2019-12-21-203436_741x369_scrot.png
(77.41 KiB) Downloaded 455 times

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

#825 Post by Argolance »

Hello,
(hope you don't mind Argolance !).
Absolutely not! On the contrary, this is very enjoyable and maybe the two versions will end up coming together, which would be the happiest ending! :wink:

Cordialement.

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

#826 Post by fredx181 »

Argolance wrote:maybe the two versions will end up coming together, which would be the happiest ending!
If it comes to an ending EVER ! :lol:

Both versions updated ("yalarm" and Argolance's modified "yalrm") with added to the GUI a "Postpone" spin-button.
This way the exact amount of minutes to postpone can be pre-set from the main GUI.

Both versions have "gettext" for the text strings, but yalrm.mo translation file is not updated (in yalrm-0.6.1.pet).

Fred
Attachments
yalrm.tar.gz
Added postpone adjustment, extract and run yalarm from yalrm folder
(41.76 KiB) Downloaded 234 times
yalrm-0.6.1.pet
Modified from Argolance's version, added postpone adjustment
(118.84 KiB) Downloaded 215 times
2019-12-23-221435_739x369_scrot.png
yalrm v0.6.1, added postpone adjustment
(77 KiB) Downloaded 1700 times
2019-12-23-215209_765x447_scrot.png
yalarm, added postpone adjustment
(89.91 KiB) Downloaded 1701 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#827 Post by vovchik »

Dear Fred,

Here are two svgs that could be placed inside the script (i.e. self-contained) in place of the pngs. Next, I have to use hexdump or od to create a variable for the ttf - which could also be placed inside the script and copied into to $HOME/.local/share/fonts if it doesn't exist already. A desktop file could also be produced in the same way and copied ito $HOME/.local/share/applications/yalarm.desktop.

Happy holidays to all...

With kind regards,
vovchik

PS. base64 will do the variable encode/decode work nicely, enabling the font to be embedded in the script.
Attachments
yalarm-svg.tar.gz
(2.43 KiB) Downloaded 205 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#828 Post by vovchik »

Dear Fred,

Here is that ticker ttf within a script. I used base64. It works nicely.

With kind regards,
vovchik
Attachments
ttfb64.tar.gz
(19.76 KiB) Downloaded 205 times

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

#829 Post by fredx181 »

Ha ! Thanks very much vovchik !
Now... of course I couldn't resist putting together a completely self-contained 8) script (attached) which will create all icons (.svg) and the ticking.ttf font for the current time display.
Also (if yalarm is placed in PATH, e.g. in /usr/bin) it will create a .desktop launcher in $HOME/.local/share/applications/ (after first time running the script), so it should appear then in the menu under "Utility".

Merry Christmas to everyone !

Fred
Attachments
yalarm.tar.gz
Extract (recommended in PATH) and run yalarm, cheers vovchik :)
(26.68 KiB) Downloaded 239 times

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#830 Post by vovchik »

Dear Fred,

Thanks. Very nice work - installed and functions as it should - with the nice font display and all icons. I like the self-contained script idea. Everything is there, so, if you have the script, it will just work and even perform the installation of needed bits and pieces if they are missing, including a menu entry. I like it!

With kind regards,
vovchik

enrique
Posts: 595
Joined: Sun 10 Nov 2019, 00:10
Location: Planet Earth

#831 Post by enrique »

@fredx181 is this an update/improve of what you post me before?
Some time I do cook rice. And I am starting to use it to remind me of the next step while cooking. See put it in to use.

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

#832 Post by fredx181 »

enrique wrote:@fredx181 is this an update/improve of what you post me before?
Some time I do cook rice. And I am starting to use it to remind me of the next step while cooking. See put it in to use.
Yes, little bit improved with the postpone setting, here's a updated deb with the same changes:
https://github.com/doglinux/busterdog/r ... .2_all.deb

Fred

enrique
Posts: 595
Joined: Sun 10 Nov 2019, 00:10
Location: Planet Earth

#833 Post by enrique »

Thanks I will try it. HEHEHE I just trip my smoke alarm doing Hamburgers. Se you later

stemsee

#834 Post by stemsee »

I am not sure if others are aware of this, but concerning yad options; '--button' '--select-action' '--dclick-action' and '--form --field=:FBTN ""'
I have found that stringing multiple commands is reliable. Contrary to the yad manpage. I think misko does this, but anyway my findings are...

For example

Code: Select all

 yad --form --field="Strung Functions:FBTN" "bash -c 'apulse firefox; bash -c geany; bash -c trans_tray'"
So when the extra code is within the single quotes they work as expected for all the above options. using & doesn't work. using && between executables does.

Calling functions proceeds through all calls. executtables may need closing before succeeding commands execute, but this depends wether or not there is already an open process....eg firefox and geany, new windows will open without waiting for exit code (i guess).

I tried some other syntactical options, but these above were reliable.

This also worked for yad --plug=$$ --list --select-action, in a yad --paned

Happy 2020, Visionary Year

stemsee

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#835 Post by step »


[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

stemsee

#836 Post by stemsee »

OK.....I should read the manpage ... finally! :roll:

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#837 Post by misko_2083 »

stemsee wrote:OK.....I should read the manpage ... finally! :roll:
Noooo! Don't do it! If my calculations are correct, there is 89% chance you'll cause a blizzard via butterfly effect... :wink: https://en.wikipedia.org/wiki/Butterfly_effect

here's a video of my fancy yad alarm with at command:
https://www.youtube.com/watch?v=KGNV2cLfF_I
It is designed for xfce since I use the fake window bar.
Nothing special with move/resize buttons: on click "xdotool key alt+F7" and alt+F8 respectively.
I'm not sure what keyboard combinations other window managers use to move windows.
However, Minimize, Maximize and Close should work with all wm's.
If not remove them and remove '--undecorate' option in the main dialog.

Since at command is used alarm will open after restart.

I borrowed a few lines from Fredx's script. :oops:
Requires: at, xfce4, wmctrl, xdotool, yad 0.42 (with html dialog), mpv
So install what is needed.

You can choose between running the file in mpv or a custom command.
If you type in custom command, don't use "@" character. This is the limitation.
Custom command can be firefox "www.youtube.com" for example.
Leave the custom blank for mpv.
Ticking "Loop forever" overides "repeat".
Job can be listed and removed via "List at Job" button.

Any open child windows will be killed after the main window is closed.

I've (ab)used DOM2 events in JavaScript to create a link and emulate mouseclick on that link to make yad to print the output.

Code: Select all

#!/bin/bash
# Fancy alarm Misko_2083 @ 2020
# Requires: at, xfce4, wmctrl, xdotool, yad 0.42 (with html dialog), mpv

#########################
# Begin User Interface  #
#########################

# JavaScript, HTML and CSS

YURI="$(cat << EOF
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">

<!--CSS for the page-->
<style>
.body, .html {
  overflow-y: hidden;
  cursor: default;
  background-color: #CECECE;
}

.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  width: 120px;
  background-color: black;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 5px 0;
  position: absolute;
  z-index: 1;
  top: 180%;
  left: 50%;
  margin-left: -60px;
  opacity: 0;
  transition: opacity 1s;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

.tooltip .tooltiptext::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent black transparent;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
}

#jsalarmclock{
font-weight: bold;
font-size: 14px;
}

#jsalarmclock div{
margin-bottom: 0.8em;
}

#jsalarmclock div.leftcolumn{
float: left;
width: 150px;
font-size: 14px;
clear: left;
}

#jsalarmclock span{
 margin-right: 10px;
}

#jsalarmclock input[type=number]{
 width: 50px;
}

p {
 font-weight: bold;
 font-size: 11px;
}

.btn {
  border: 2px solid black;
  background-color: white;
  color: black;
  padding: 8px 16px;
  position: sticky;
  font-size: 12px;
  cursor: default;
}

/* Green */
.bar {
  border-color: #4CAF50;
  color: green;
  text-decoration: none;
}

.bar:hover {
  background-color: #4CAF50;
  color: white;
}

/* Blue */
.bl {
  border-color: #2196F3;
  color: dodgerblue;
  text-decoration: none;
}

.bl:hover {
  background: #2196F3;
  color: white;
  text-decoration: none;
}

/* Orange */
.bltop {
  border-color: #ff9800;
  color: orange;
  text-decoration: none;
}

.bltop:hover {
  background: #ff9800;
  color: white;
  text-decoration: none;
}

/* Red */
.restart{
  border-color: #f44336;
  color: red;
  text-decoration: none;
}

.restart:hover {
  background: #f44336;
  color: white;
}

/* Gray */
.default {
  border-color: #000000;
  color: black;
  text-decoration: none;
}

.default:hover {
  background: #000000;
  color: white;
  text-decoration: none;
}

.title {
 font-size: 10px
 cursor: default;
}
</style>

<!--Script to prevent right click menu-->
<script type="text/javascript">
    if (document.addEventListener) { // IE >= 9; other browsers
        document.addEventListener('contextmenu', function(e) {
            //here you do nothing
            e.preventDefault();
        }, false);
    } else { // IE < 9
        document.attachEvent('oncontextmenu', function() {
            alert("You've tried to open context menu");
            window.event.returnValue = false;
        });
    }
</script>


<script type="text/javascript">

/***********************************************

* JavaScript Alarm Clock- by JavaScript Kit (www.javascriptkit.com)
* This notice must stay intact for usage
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more

***********************************************/

/* Modified for my needs Misko_2083 */

var jsalarm={
	padfield:function(f){
		return (f<10)? "0"+f : f
	},
	showcurrenttime:function(){
		var dateobj=new Date()
		var ct=this.padfield(dateobj.getHours())+":"+this.padfield(dateobj.getMinutes())+":"+this.padfield(dateobj.getSeconds())
		this.ctref.innerHTML=ct
		this.ctref.setAttribute("title", ct)
	},
	init:function(){
		var dateobj=new Date()
		this.ctref=document.getElementById("jsalarm_ct")
		this.submitref=document.getElementById("submitbutton")
		this.submitref.onclick=function(){
			jsalarm.setalarm()
			//this.value="Alarm Set"
			this.disabled=false
			return false
		}
		var selections=document.getElementsByTagName("select")
		this.hourselect=selections[0]
		this.minuteselect=selections[1]
		for (var i=0; i<60; i++){
			if (i<24) //If still within range of hours field: 0-23
			this.hourselect[i]=new Option(this.padfield(i), this.padfield(i), false, dateobj.getHours()==i)
			this.minuteselect[i]=new Option(this.padfield(i), this.padfield(i), false, dateobj.getMinutes()+1==i)

		}
		jsalarm.showcurrenttime()
		jsalarm.timer=setInterval(function(){jsalarm.showcurrenttime()}, 1000)
	},
        info:function(a) {
                var h = document.createElement("p");
                var filename = String(a).replace(/^.*[\\\/]/, '');
                var t = document.createTextNode("Alarm "+filename);
                h.appendChild(t);
                document.body.appendChild(h);
                h.setAttribute("id", "info");
        },
        dom:function(a){
                // DOM 2 Events
                var dispatchMouseEvent = function(target, var_args) {
                  var e = document.createEvent("MouseEvents");
                  // If you need clientX, clientY, etc., you can call
                  // initMouseEvent instead of initEvent
                  e.initEvent.apply(e, Array.prototype.slice.call(arguments, 1));
                  target.dispatchEvent(e);
                };
                dispatchMouseEvent(a, 'mouseover', true, true);
                dispatchMouseEvent(a, 'mousedown', true, true);
                dispatchMouseEvent(a, 'click', true, true);
                dispatchMouseEvent(a, 'mouseup', true, true);
        },
	setalarm:function(){
		this.hourwake=this.hourselect.options[this.hourselect.selectedIndex].value
		this.minutewake=this.minuteselect.options[this.minuteselect.selectedIndex].value
                var a = document.createElement('a');
                var linkText = document.createTextNode("Go");
                a.appendChild(linkText);
                a.title = "fake link";

                a.href = this.hourselect.options[this.hourselect.selectedIndex].value+":"+this.minuteselect.options[this.minuteselect.selectedIndex].value;
                jsalarm.dom(a)
                jsalarm.info(a)
                a.href = "repeat@"+document.getElementById("repeat").value;
                jsalarm.dom(a)
                if(document.getElementById("forever").checked == true) {
                  a.href = "repeat@"+document.getElementById("forever").value;
                  jsalarm.dom(a)
                }
                a.href = "command@"+document.getElementById("command").value;
                jsalarm.dom(a)
                //a.parentNode.removeChild(linkText);
		//this.hourselect.disabled=true
		//this.minuteselect.disabled=true
	}

}

</script>
</head>
<body class="body">

<!--left-->
<div 
 style="-moz-user-select: none; -webkit-user-select: none; -ms-user-select:none; user-select:none;-o-user-select:none;position:absolute;left:0;" 
 unselectable="on"
 onselectstart="return false;" 
 onmousedown="return false;">
<div class="tooltip">
   <a href="move" class="btn default">#</a>
   <span class="tooltiptext">Move</span>
</div>
<text class="title"> Alarm </text>

</div>

<!--right-->
<div 
 style="-moz-user-select: none; -webkit-user-select: none; -ms-user-select:none; user-select:none;-o-user-select:none;position:absolute;right:0;" 
 unselectable="on"
 onselectstart="return false;" 
 onmousedown="return false;">

<!--Here you define window button links and text-->
<div class="tooltip">
   <a href="resize" class="btn bar">+</a>
   <span class="tooltiptext">Resize</span>
</div>
<div class="tooltip">
   <a href="minimize" class="btn bltop">_</a>
   <span class="tooltiptext">Minimize</span>
</div>
<div class="tooltip">
   <a href="maximize" class="btn bl">[]</a>
   <span class="tooltiptext">Maximize</span>
</div>
<a href="exit" class="btn restart">X</a>


</div>

<br />
<br />
 <form action="" method="">
  <div id="jsalarmclock">
  <div><div class="leftcolumn">Current Time:</div> <span id="jsalarm_ct" style="letter-spacing: 2px"></span></div>
  <div><div class="leftcolumn">Set Alarm:</div> <span><select></select> Hour</span> <span><select></select> Minutes</span> </div>

  <div><div class="leftcolumn">Repeat:</div><input size="5" type="number" id="repeat" min="1" value="1"/>  <br>
        <div class="leftcolumn">Loop forever</div> <input type="checkbox" id="forever" value="forever"/>
       <span style="font: normal 11px Tahoma">Loop forever overides repeat</span> <br>
  <div><div class="leftcolumn">Set file:</div><a href="file:///musicfile@"><button type="button">Select a file to play</button></a>
             <span style="font: normal 11px Tahoma">Select a file to run with mpv or type in a custom action</span></div>
  <div><div class="leftcolumn">Set Custom Action:</div> <input type="text" id="command" size="55" value="" /> <br>
       <span style="font: normal 11px Tahoma">*Command to launch, if empty mpv will be used (do not use "@" character here)</span></div>
  <input type="submit" value="Set Alarm!" id="submitbutton" />

  </div>
</form>

<a href="file:///atq@"><button type="button">At Job List</button></a>

<script type="text/javascript">

jsalarm.init()

</script>
</body>
</html>
EOF
)"
#########################
# End of User interface #
#########################

#########################
# Bash functions        #
#########################
# fuction to recursively kill all descendants
function _kill_descendant_processes() {
    local pid="$1"
    local and_self="${2:-false}"
    if children="$(pgrep -P "$pid")"; then
        for child in $children; do
            _kill_descendant_processes "$child" true
        done
    fi
    if [[ "$and_self" == true ]]; then
        kill -SIGTERM "$pid"
    fi
}

# Main window
function _yad_ui(){
    # Set the line buffering with stdbuf
    echo "${YURI}" | stdbuf -oL -eL yad --title="Set Alarm" --width=650 --height=500 --no-escape \
    --html --no-buttons --print-uri --undecorated --borders=0 --window-icon="alarm1c.png" 2>&1 & echo $!
}

# Main Function
function _do_stuff(){
    # fetch yad process id
    read YAD_PID

    # read yad stdout line by line
    while read -r line
    do
        case ${line##*/} in
            resize) xdotool key alt+F8 ;;
            move) xdotool key alt+F7 ;;
            exit) if yad --width=400 --title="Set Alarm" --height=100 --text="Exit?" --button="No:1" --button="Yes:0" --window-icon="alarm1c.png" 2>/dev/null; then
                      kill -SIGUSR1 $YAD_PID ;
                     _kill_descendant_processes $$ 2>/dev/null;
                     break
                  fi
                  ;;
            minimize) xdotool getactivewindow windowminimize ;;
            maximize)    if xprop -id $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) _NET_WM_STATE | grep -E "MAXIMIZED_HORZ.*MAXIMIZED_VERT|MAXIMIZED_VERT.*MAXIMIZED_HORZ" > /dev/null 2>&1
                         then
                             wmctrl -ir $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) -b remove,maximized_vert,maximized_horz
                         else
                             wmctrl -ir $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) -b add,maximized_vert,maximized_horz
                         fi ;;
         [0-9][0-9]:[0-9][0-9]*)
            #kill -SIGUSR1 $YAD_PID
            echo "Alarm set to: ${line##*/}"
            alarm_time="${line##*/}"           
;;
                   repeat@*) REPEAT="$(echo  "${line##*@}" | sed 's/%20/ /g')"
;;
                   command@*) COMMAND="$(echo  "${line##*@}" | sed 's/%20/ /g')"

if [ ! -e "/tmp/yalarm.$$" ] ; then
      MUSIC="$(yad --width=600 --height=500 \
                    --title="Alarm" --text="Select a file to play in mpv" \
                    --file-filter="Audio | *.mp3 *.MP3 *.wav *.WAV *.ogg *.OGG" \
                    --file 2>/dev/null)"
      [ $? != 0 ] && continue
       echo "${MUSIC}" > /tmp/yalarm.$$
fi

# Fredx181
hrnow=$(echo $(date +"%k"))

# For when trying to set alarm for next day e.g. from current 21:00 to target 6:00
if [ "${alarm_time%%:*}" -eq "$hrnow" ] &&  [ "${alarm_time##*:}" -le "$(date +"%M")" ]; then
    # prompt yes/no in case accidentally chosen current hour but less than current minute
    yad --center --title="Are you sure?" --text="Are you sure to set the alarm to ${alarm_time} - tomorrow ?" --width=400 --button="Yes:0"  --button="No:1"
[ $? -ne 0 ] &&  continue 
fi

if [ ! "${COMMAND}" = "" ]; then
at "${alarm_time}" << EOF
exec env DISPLAY="$DISPLAY" $(echo  "${line##*@}" | sed 's/%20/ /g') &
EOF
else
    if [  "${REPEAT}" = "forever" ]; then
at "${alarm_time}" << EOF
exec env DISPLAY="$DISPLAY" mpv --force-window --loop inf "$(cat /tmp/yalarm.$$)"
EOF
    else
at "${alarm_time}" << EOF
exec env DISPLAY="$DISPLAY" mpv --force-window --loop "${REPEAT}" "$(cat /tmp/yalarm.$$)"
EOF
   fi
fi

# Here we set alarm
#at "${alarm_time}" << EOF
#exec env DISPLAY="$DISPLAY" $(echo  "${line##*@}" | sed 's/%20/ /g')
#EOF
;;
                   atq@*) (REMOVE_JOB="$(atq | yad --list --width=600 --height=500 \
                                                  --text="Select 'at' job to remove or close this window" \
                                                  --column "Job List" \
                                                  --button="Remove at Job" 2>/dev/null \
                                            | awk '{print $1}')"
                          if [[ "${REMOVE_JOB}" == [0-9]* ]]; then
                             echo "${REMOVE_JOB}"
                             atrm "${REMOVE_JOB}"
                             killall mpv
                          fi) &                      
;;
                   musicfile@*) (MUSIC="$(yad --width=600 --height=500 \
                                              --title="Alarm" --text="Select a file to play in mpv" \
                                              --file-filter="Audio | *.mp3 *.wav" \
                                              --file 2>/dev/null)" \
                                               [ $? = 0 ] && echo "${MUSIC}" > /tmp/yalarm.$$) &
;;
       esac 
    done
rm /tmp/yalarm.$$
exit
}

_yad_ui | _do_stuff & wait $! 2>/dev/null


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

#838 Post by Argolance »

Bonjour,
:arrow: XkbSS 0.1 - Xkb Systray Layout Switcher using:

Code: Select all

yad --notification.
Cordialement.

Post Reply