Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Tue 19 Sep 2017, 13:15
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
YAD - Tips
Post new topic   Reply to topic View previous topic :: View next topic
Page 20 of 22 [321 Posts]   Goto page: Previous 1, 2, 3, ..., 18, 19, 20, 21, 22 Next
Author Message
slavvo67

Joined: 12 Oct 2012
Posts: 1423
Location: The other Mr. 305

PostPosted: Thu 09 Feb 2017, 21:12    Post subject:  

I'm running 37.0 but sometimes Victor breaks a version when implementing new things.... Maybe I'll upgrade again ....


Thanks
Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1423
Location: The other Mr. 305

PostPosted: Tue 28 Feb 2017, 22:38    Post subject:  

Is there any way to pass the drag and drop to the next part of the script without requiring the ok box to be clicked? The no buttons option does not advance unless you close the actual window....

Thank you
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1348
Location: Japan

PostPosted: Wed 01 Mar 2017, 00:24    Post subject:  

slavvo67 wrote:
Is there any way to pass the drag and drop to the next part of the script without requiring the ok box to be clicked?
Which "ok box"? You should place the "next part" before the yad statement as a function:
Code:
function myfunction {
   Xdialog --msgbox "You dropped\n$0" x
}
export -f myfunction

yad --width=200 --height=200 --dnd --command="bash -c 'myfunction'"
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 1973
Location: In The Way

PostPosted: Fri 10 Mar 2017, 20:52    Post subject:  

solved!
Back to top
View user's profile Send private message MSN Messenger 
step

Joined: 04 May 2012
Posts: 916

PostPosted: Mon 20 Mar 2017, 13:43    Post subject:
Subject description: dndmate - yet another drag-and-drop yad script
 

Hi all, the conversation that we started, near page 16, about a drag-and-drop script has grown into yet-another script here --> screenshot.
_________________
Fatdog64-710|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 16

PostPosted: Mon 03 Apr 2017, 15:00    Post subject: Iconbox  

I have this folder /home/user/Desktop/yad_iconbox
in that folder, there is a script switch.sh and a deskop file
Code:
#!/bin/bash
#switch.sh

PARAM="$@"
case $PARAM in
   test)
      if [[ -f "/home/user/Desktop/yad_iconbox/icon-on.desktop" ]]; then
         sed -i 's/gtk\-yes/gtk\-no/g' /home/user/Desktop/yad_iconbox/icon-on.desktop
         mv /home/user/Desktop/yad_iconbox/icons-on.desktop /home/user/Desktop/yad_iconbox/icon-off.desktop
         #more commands here
       else
         sed -i 's/gtk\-no/gtk\-yes/g' /home/misko/Desktop/yad_iconbox/audacious-off.desktop
         mv /home/user/Desktop/yad_iconbox/icon-off.desktop /home/user/Desktop/yad_iconbox/icon-on.desktop
          #commands...
       fi
       ;;
   *) exit
   ;;     
esac


icon-off.desktop
Code:
[Desktop Entry]
Version=1.0
Type=Application
Name=Icon
GenericName=Icon
Comment=Test
Icon=gtk-no
Categories=GTK;
Exec=/home/user/Desktop/yad_iconbox/switch.sh test
TryExec=/home/user/Desktop/yad_iconbox/switch.sh test
Terminal=false


I launch the Iconbox with next
Code:
#!/bin/bash
yad --icons --single-click --monitor --height=300 \
    --width=500 --read-dir="/home/user/Desktop/yad_iconbox"

If I click on this icon, it will change.

I would like to know is there a way to do this using the stdin, since --icons dialog can read from stdin.
--listen
Read data from stdin. Data must be in order - Name, Tooltip,
Icon, Command, InTerm separated by newline. InTerm is a case
insensitive boolean constant (TRUE or FALSE).

Is there a way to force the dialog to reset the icons with something being sent to the pipe?
Example:
Code:
(echo -e "Name\nTooltip\ngtk-ok\necho \"\"\nFALSE"; sleep 1; echo "Reset the icons") | yad --icons --single-click --listen --monitor --height=300 --width=500
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1348
Location: Japan

PostPosted: Tue 04 Apr 2017, 01:13    Post subject: Re: Iconbox  

misko_2083 wrote:
If I click on this icon, it will change.
Really? First I needed to fix the switch.sh script:
- Change one instance of icons-on.desktop to icon-on.desktop and
- /home/misko/Desktop/yad_iconbox/audacious-off.desktop to /home/user/Desktop/yad_iconbox/icon-off.desktop

Quote:
Is there a way to force the dialog to reset the icons with something being sent to the pipe?

I don't think that this is possible. AFAIK you can only add icons this way but not change existing ones:
Code:
#!/bin/bash
export PIPE_03=/tmp/yadpipe03
mkfifo $PIPE_03
exec 3<> $PIPE_03

yad --icons --single-click --height=300 --width=500 --listen < $PIPE_03 &
echo -e "Name\nTooltip\ngtk-ok\nbeep\nFALSE" > $PIPE_03
sleep 1
echo -e "Yes\nTooltip\ngtk-yes\nbeep\nFALSE" > $PIPE_03
sleep 1
echo -e "No\nTooltip\ngtk-no\nbeep\nFALSE"   > $PIPE_03


I found no way to clear the icons box. Your original method, using --monitor and --read-dir, seems to be a .better approach.
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 16

PostPosted: Thu 06 Apr 2017, 11:55    Post subject: Re: Iconbox  

Thank you for the reply MochiMoppel
Sorry about the errors. Smile
I've seen the Yad source and there is only one way as you say.
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 14
Location: 45659, Germany

PostPosted: Fri 14 Apr 2017, 04:59    Post subject: birthday  

Hi,
6 months ago I switched to Ubuntu 4.16 and have now a lot of fun to yad. Now, however, I have a problem for days. I want you to read and display the result from the "Birthday" on yad. Since the result of more than one word, I get with the attached code, the result only with each displayed (word for word). Can somebody help me with it?

#! / bin / bash

yad --title = 'special events' \
--text = 'birthday' \
--text-align = center --geometry = 950x400 \
--list \
--scroll \
--column = " event "\
--buttons-layout = "center" \
--button =" <b> <span color = 'blue'> Close </ span> </ b> "\
--image-on-top \
- image = / home / hachims / .icons / drive-3-cb-system-dos-icon.png \
$ (birthday -f /home/hachims/Dokumente/b2.txt)

PS. I loaded a professional script with yad to download from youtube down from the net. Can I publish this?

Sorry, I just see that is the wrong forum. Please by YAD tips move. Thank you!
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1348
Location: Japan

PostPosted: Fri 14 Apr 2017, 05:50    Post subject: Re: birthday  

achim wrote:
Since the result of more than one word, I get with the attached code, the result only with each displayed (word for word)
You are not supposed you get any result at all with this code. Lots of spaces where there shouldn't be any, starting with the shebang '#! / bin / bash', followed by spaces around = and lastly by the space after $ in '$ (birthday -f /home/hachims/Dokumente/b2.txt)'

If this is fixed you need to send the result of your birthday command to yad, presumably with something like
<<< "$(birthday -f /home/hachims/Dokumente/b2.txt)". Mind the double quotation marks around your statement.

If this doesn't help we need to know the output of the birthday -f /home/hachims/Dokumente/b2.txt command.
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 14
Location: 45659, Germany

PostPosted: Fri 14 Apr 2017, 10:28    Post subject: Re: birthday  

Hi MochiMoppel

thank you for your help, with your suggestion does the YAD script now properly. Still my question remains whether interest in a very functional YAD script "Youtube downloader" is. It is not written by me, but recently downloaded from the Internet. I ask for a short answer.
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 14
Location: 45659, Germany

PostPosted: Sat 15 Apr 2017, 07:58    Post subject: execute order  

Hello,
I use the following script under Ubuntu as an alternative to the command known under Windows "Run". It works so far, but there is no message if the string is not found. This situation should be caught with a "not found" message and restart the script. Does somebody has any idea?

Code:
#! /bin/bash

XTERM="xterm"

# create history file
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/
HISTFILE=${XDG_CACHE_HOME:-$HOME/.cache}/ix-run.history
touch $HISTFILE

# create and run dialog
TITLE="Befehl ausführen"
TEXT="\nBefehl eingeben und Enter drücken:\n"
rcmd=$(yad --width=500 --center --window-icon="gtk-execute" --name="${0##/}" --title="$TITLE" --text="$TEXT" --image="gtk-execute" --editable --entry --rest $HISTFILE)

echo "tooltip:Beispielmenü"

[-z "$rcmd" ] && exit 0

# run command
case $rcmd in
    http://*|https://*|ftp://*)
        xdg-open $rcmd &
        ;;
    mailto://*)
        xdg-email $rcmd &
        ;;
    man://*)
        eval $XTERM -e "man ${rcmd#man://}" &
        ;;
    telnet*|ssh*)
        eval $XTERM -e "$rcmd" &
        ;;
    *)
        eval $rcmd &
        ;;
esac

# add command to history
head $HISTFILE | grep -qF "$rcmd" || echo -e "$rcmd\n$(<$HISTFILE)" > $HISTFILE

exit 0
Code:


Thanks in advance
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 2297
Location: Queensland

PostPosted: Sat 15 Apr 2017, 21:33    Post subject: Re: execute order  

achim wrote:
Hello,
I use the following script under Ubuntu as an alternative to the command known under Windows "Run". It works so far, but there is no message if the string is not found. This situation should be caught with a "not found" message and restart the script. Does somebody has any idea?


Some time back I used this script also, I modified it to give a error message if the command didn't exist and the option to clear the history, this uses exo-open not xdg-open hope this is of help.

Code:
#! /bin/bash
HISTFILE=${XDG_CACHE_HOME:-$HOME/.cache}/ix-run.history
# delete history file
Clear_History(){
   rm $HISTFILE
   yad --fixed --title="History" --window-icon="applications-system" --text="\n        History Cleared        \n" --timeout="2" --no-buttons
   `basename "$0"`
}
export -f  Clear_History
XTERM="xterm"
# create history file
if [ ! -f $HISTFILE ]; then
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/
echo 'Clear_History' > $HISTFILE
fi
# create and run dialog
TITLE="Run command"
TEXT="\nEnter command to execute:\n"
CMD='yad --fixed --width=400 --center --window-icon="applications-system" --buttons-layout=center --title="$TITLE" --text="$TEXT" --button="gtk-ok:0" --image="applications-system" --entry --editable'
ARGS=$(perl -pe 's/(^.*$)/"\1"/;s/\n/ /' $HISTFILE)
rcmd=$(eval $CMD $ARGS)

# run command
case $rcmd in
    www.*|http://*|https://*|ftp://*|mailto:*)
        exo-open $rcmd &
        ;;
    man://*)
        eval $XTERM -e "man ${rcmd#man://}" &
        ;;
    telnet*|ssh*)
        eval $XTERM -e "$rcmd" &
        ;;
    *)
        eval $rcmd 2> /tmp/run-command-error &
        ;;
esac
sleep .1
if grep -c 'command not found' /tmp/run-command-error; then
yad --fixed --title="Error" --window-icon="applications-system" --text="\n Command not found \n" --timeout="2" --no-buttons
sed 's/ $CMD// $HISTFILE'
rm /tmp/run-command-error
`basename "$0"`
else
# add command to history
grep -qF "$rcmd" $HISTFILE || echo $rcmd >> $HISTFILE
fi
exit 0


Edit: removed error in code.

_________________
Carolina: Recent Repository Additions


Last edited by Geoffrey on Mon 17 Apr 2017, 00:29; edited 1 time in total
Back to top
View user's profile Send private message 
achim

Joined: 13 Apr 2017
Posts: 14
Location: 45659, Germany

PostPosted: Sun 16 Apr 2017, 19:02    Post subject: Re: execute order  

Hi Geoffrey,
Thank you for your help. However, your modified variant does not report any errors, but terminates the script without comment. Basically, it runs with me just as the original. I use the YAD version 0.38.2 (GTK + 3.20.Cool. If you have something else to think about, then please contact me.
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 2297
Location: Queensland

PostPosted: Mon 17 Apr 2017, 00:02    Post subject: Re: execute order  

@achim, you are using your run script in puppy?

I'm unaware of any Puppy flavor that uses yad compiled with GTK + 3.20.

I've modified your script, works for me ok

The code outputs the error to file, then grep checks for the 'command not found', if true then displays the message.

`basename "$0"` runs a new instance of your script, provided that it's in the PATH.

Code:
#! /bin/bash

XTERM="xterm"

# create history file
mkdir -p ${XDG_CACHE_HOME:-$HOME/.cache}/
HISTFILE=${XDG_CACHE_HOME:-$HOME/.cache}/ix-run.history
touch $HISTFILE

# create and run dialog
TITLE="Befehl ausführen"
TEXT="\nBefehl eingeben und Enter drücken:\n"
rcmd=$(yad --width=500 --center --window-icon="gtk-execute" --name="${0##/}" --title="$TITLE" --text="$TEXT" --image="gtk-execute" --editable --entry --rest $HISTFILE)

echo "tooltip:Beispielmenü"

# run command
case $rcmd in
    http://*|https://*|ftp://*)
        xdg-open $rcmd &
        ;;
    mailto://*)
        xdg-email $rcmd &
        ;;
    man://*)
        eval $XTERM -e "man ${rcmd#man://}" &
        ;;
    telnet*|ssh*)
        eval $XTERM -e "$rcmd" &
        ;; *)
        eval $rcmd 2> /tmp/run-command-error &
        ;;
esac
sleep .1
if grep -c 'command not found' /tmp/run-command-error; then
yad --fixed --title="Error" --window-icon="applications-system" --text="\n Command $rcmd not found \n" --timeout="3" --no-buttons
rm /tmp/run-command-error
`basename "$0"`
else
# add command to history
head $HISTFILE | grep -qF "$rcmd" || echo -e "$rcmd\n$(<$HISTFILE)" > $HISTFILE
fi
exit 0

_________________
Carolina: Recent Repository Additions

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 20 of 22 [321 Posts]   Goto page: Previous 1, 2, 3, ..., 18, 19, 20, 21, 22 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1424s ][ Queries: 14 (0.0184s) ][ GZIP on ]