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 Wed 13 Nov 2019, 12:12
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 50 of 51 [751 Posts]   Goto page: Previous 1, 2, 3, ..., 48, 49, 50, 51 Next
Author Message
misko_2083


Joined: 08 Nov 2016
Posts: 88

PostPosted: Mon 23 Sep 2019, 18:00    Post subject:  

rufwoof wrote:
This will do the same using yad, with the button labels you prefer. Just modify the SHUTDOWNCOMMAND to actually run your shutdown command instead of running geany
Code:
#!/bin/bash

SHUTDOWNCOMMAND=geany

(  echo "99" ; sleep 1
   echo "90" ; sleep 1
   echo "80" ; sleep 1
   echo "70" ; sleep 1
   echo "60" ; sleep 1
   echo "50" ; sleep 1
   echo "40" ; sleep 1
   echo "30" ; sleep 1
   echo "20" ; sleep 1
   echo "10" ; sleep 1 ) |
  yad --progress --title="$TITLE $VERSION" --text=" Are you sure you want to shutdown? \n\n Turning off computer in 10 seconds \n\n Press Cancel to abort shutdown " \
  --percentage=0 --auto-close --auto-kill --button=CANCEL:1 --button=SHUTDOWN:0
[[ $? -eq 0 ]] && $SHUTDOWNCOMMAND

Thanks but after 3.0 the progress bar no longer works.
So many changes as the newer versions are not backward compatible. No gtk-icons support, right-click notification menu no longer works, entry is deprecated...
It's in quiet unstable now. Probably even more stuff will be removed when the old obsolete code derived from zenity is removed.
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Mon 23 Sep 2019, 22:02    Post subject:  

Standalone yad based simple-savefile-creator (mksavefile.sh)
Code:

#!/bin/sh
#
export PROG=$(basename $0)
running=`ps -e | grep -w "$PROG" | wc -l`
[[ "$running" -gt 2 ]] && exit  # run only one instance
deps=`busybox which yad`
[[ -f /etc/DISTRO_SPECS ]] && . /etc/DISTRO_SPECS
if [[ ! -z "$deps" ]]; then
   all=`yad --center --on-top --width=500 --title="Simple-Savefile-Creator" --form --item-separator=" " --field=Size:CBE "512 1024 1534 2048" --field=Filesystem:CBE "ext4 ext2 ext3" --field=ByteSize:CBE "1024 512 64" --field=Name:CBE "changes live-rw fd64save ${DISTRO_FILE_PREFIX}save qsave." --field=Path1:CBE "mnt media" --field=Path2:CBE "sda1 mmcblk0p1 sdb1" --field=Path3:CBE "casper fatdog upupbb Slacko64 EasyOS Quirky"`
   size=`echo $all | cut -f1 -d'|'`
   fs=`echo $all | cut -f2 -d'|'`
   bs=`echo $all | cut -f3 -d'|'`
   savefile=`echo $all | cut -f4 -d'|'`
   Path1=`echo $all | cut -f5 -d'|'`
   PAth2=`echo $all | cut -f6 -d'|'`
   PATh3=`echo $all | cut -f7 -d'|'`
   if [[ "$savefile" == changes* ]]; then
    savefile="${savefile}.dat"
   elif [[ "$savefile" == fd64save* ]]; then
    savefile="${savefile}.${fs}"
   elif [[ "$savefile" == $DISTRO_FILE_PREFIX* ]]; then
    savefile="${savefile}save.`echo $fs | cut -c4`fs"
   fi

fi
if [ -z $(busybox which gxmessage) ]; then
   MESSAGE=xmessage
else
   MESSAGE=gxmessage
fi
[[ -f /tmp/missdeps ]] && rm -f /tmp/missdeps
# check paths....
[[ -z "$deps" ]] && echo "yad was not found" >> /tmp/missdeps
[[ ! -d "/$Path1" ]] && echo "directory /$Path1 not found" >> /tmp/missdeps
[[ -z `mount | grep "$PAth2"` ]] && echo "$PAth2 is not mounted" >> /tmp/missdeps
[[ ! -d "/${Path1}/${PAth2}/$PATh3" ]] && echo "directory not found /${Path1}/${PAth2}/$PATh3" >> /tmp/missdeps
[[ -f "/${Path1}/${PAth2}/$PATh3/$savefile" ]] && echo "/${Path1}/${PAth2}/$PATh3/$savefile already exists !!" >> /tmp/missdeps
missing=`cat /tmp/missdeps`
[[ ! -z "$missing" ]] && $MESSAGE -center "This part of the PATH is problematic
$missing

" -fore black -back green -timeout 6
[[ ! -z "$missing" ]] && exit
yad --center --on-top --text="Does this look right?
      dd if=/dev/zero of=/${Path1}/${PAth2}/${PATh3}/$savefile bs=${bs}k count=$size
      mkfs -t $fs -q -m 0 -F /${Path1}/${PAth2}/${PATh3}/$savefile
"
ret=$?
case $ret in
0) yad --listen --progress --text="Creating Savefile \nPlease Wait" --pulsate --no-buttons --on-top --undecorated --width=200 --height=140 --center &
export prog=$!
dd if=/dev/zero of=/${Path1}/${PAth2}/${PATh3}/$savefile bs=${bs}k count=${size}
mkfs -t $fs -q -m 0 -F /${Path1}/${PAth2}/${PATh3}/$savefile
chmod a+rw /${Path1}/${PAth2}/${PATh3}/$savefile
fsck -M -C -a -l /${Path1}/${PAth2}/${PATh3}/$savefile
kill $prog
[[ ! -z `du -h /${Path1}/${PAth2}/${PATh3}/$savefile | grep "$size"` ]] && yad --text="Savefile creation completed" --timeout=2 --center --no-buttons --undecorted --skip-taskbar --on-top
[[ -z `du -h /${Path1}/${PAth2}/${PATh3}/$savefile | grep "$size"` ]] && yad --text="Savefile creation incomplete" --timeout=2 --center --no-buttons --undecorted --skip-taskbar --on-top;;
1) exit;;
*) exec $0 &
exit;;
esac
Back to top
View user's profile Send private message MSN Messenger 
MochiMoppel


Joined: 26 Jan 2011
Posts: 1925
Location: Japan

PostPosted: Tue 24 Sep 2019, 02:16    Post subject:  

misko_2083 wrote:
Bit off topic
Way off topic Laughing , but that's OK. Gives me a good excuse for throwing in another solution .... with Xdialog (we don't have a dedicated thread, do we?)

Xdialog's infobox can be configured to work similar to yad's text-info. Though it accepts only one button and the syntax is a bit weird it is simple and can be quite useful:
Code:
for i in {5..0}; do
   echo  XXX
   echo "Turning off computer in $i seconds"
   echo XXX
   sleep 1
done | Xdialog --cancel-label "Abort shutdown"  -infobox "" 300x100 0
(($?)) && exit
Xdialog  -infobox "Continue now with shutdown commands" 300x100 4000
Screenshot.png
 Description   
 Filesize   4.63 KB
 Viewed   511 Time(s)

Screenshot.png

Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Wed 25 Sep 2019, 03:54    Post subject:  

How close can yad get to immitating a terminal? or swallowing one?
Back to top
View user's profile Send private message MSN Messenger 
misko_2083


Joined: 08 Nov 2016
Posts: 88

PostPosted: Wed 25 Sep 2019, 06:22    Post subject:  

MochiMoppel wrote:
misko_2083 wrote:
Bit off topic
Way off topic Laughing , but that's OK. Gives me a good excuse for throwing in another solution .... with Xdialog (we don't have a dedicated thread, do we?)

Aww, I lost the bet. I was betting on Fred the Netherlandian to be the first one to go off topic. Laughing
That's very minimal solution.
stemsee wrote:
How close can yad get to immitating a terminal? or swallowing one?

Why reinventing the hot water? Smile
Bobby Copper aka YadBashBobby had that idea.
https://www.youtube.com/watch?v=stPAWGXQyLY
Haven't seen him on the forums for a long time.
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4157
Location: holland

PostPosted: Wed 25 Sep 2019, 08:02    Post subject:  

misko_2083 wrote:

Aww, I lost the bet. I was betting on Fred the Netherlandian to be the first one to go off topic. Laughing


Me ??? I would never forgive myself, I'm not like you, bad guys ! Laughing

Quote:
How close can yad get to immitating a terminal? or swallowing one?

Why reinventing the hot water? Smile
Bobby Copper aka YadBashBobby had that idea.


Can't find Bobby's script anywhere, Maybe he removed it because it didn't work well ? Question .

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
misko_2083


Joined: 08 Nov 2016
Posts: 88

PostPosted: Mon 07 Oct 2019, 05:30    Post subject:  

fredx181 wrote:
misko_2083 wrote:

Aww, I lost the bet. I was betting on Fred the Netherlandian to be the first one to go off topic. Laughing


Me ??? I would never forgive myself, I'm not like you, bad guys ! Laughing

Don't know about MochiMopel but I'm terrible.
I even recommended Debian Administrator's Guide to a certain "dev" in a systemd related thread. Smile
fredx181 wrote:

Quote:
How close can yad get to immitating a terminal? or swallowing one?

Why reinventing the hot water? Smile
Bobby Copper aka YadBashBobby had that idea.


Can't find Bobby's script anywhere, Maybe he removed it because it didn't work well ? Question .

Fred

After some deep search.
Who knows where is the script. Didn't find it on either github or gitlab.
Maybe he keeps his repos private on gitlab.
Found a few forum posts but the script nowhere.
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Fri 18 Oct 2019, 07:12    Post subject:  

I finally understand how to get yad --progress working! (I'm slow! ok)
And also how to see the full 100%
Code:
export d=0; ( sleep 0.5; while [[ $d -lt 1024 ]]; do  d=$((d+10)); echo $d; sleep 0.1; done ) | yad --progress --percentage=$d --timeout=$((d+1)) --no-buttons --undecorated --progress-text="testing"


of course sleep integer could be a variable for a file size check. And also the -lt 1024 could be the total filesize in a variable.
Back to top
View user's profile Send private message MSN Messenger 
step

Joined: 04 May 2012
Posts: 1220

PostPosted: Fri 18 Oct 2019, 13:53    Post subject:  

Tip: avoid using option --auto-kill because it is too easy to end up killing the whole system by mistake.
_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Fri 18 Oct 2019, 14:56    Post subject:  

step wrote:
Tip: avoid using option --auto-kill because it is too easy to end up killing the whole system by mistake.
oh! I didn't know that Shocked

count files as %, and file name as progress text
Code:
cnt=0;tot=$(for i in $(ls /usr/sbin); do cnt=$((cnt + 1)); done; echo $cnt); for i in $(ls /usr/sbin); do echo "#$i"; cnt=$((cnt+1)); echo $((cnt*100/tot)); sleep 0.1; done | yad --progress --auto-close --undecorated --no-buttons
Back to top
View user's profile Send private message MSN Messenger 
step

Joined: 04 May 2012
Posts: 1220

PostPosted: Sat 19 Oct 2019, 15:24    Post subject:  

stemsee wrote:
step wrote:
Tip: avoid using option --auto-kill because it is too easy to end up killing the whole system by mistake.
oh! I didn't know that Shocked


Don't take me wrong; it isn't that yad kills the whole system on purpose. It is that --auto-kill and the similar --kill-parent options give your code the means to take the system down if your code isn't very careful. If specified, these two options will send a kill signal to the process that is the yad's parent **at the time** the yad dialog closes itself or is closed. Now, ask yourself if your code is designed to always know which is its **current** parent process. In the case of an orphaned yad dialog, its parent process becomes the init process, and when you close the dialog init is killed -- most likely not what your code intended to do - and the system will go down.

_________________
Fatdog64-802|+Packages|Kodi|Findnrun|+forum|gtkmenuplus
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Sun 20 Oct 2019, 08:29    Post subject:  

Thanks for the explanation step ... in fact I have never used --auto-kill .

Competition

who can come up with the code which generates a yad progress bar that starts and ends at the same point as the mksquashfs command!

I did a couple, but sometimes the mksquashfs progress races ahead, while the yad (measuring the created .sfs size) moves steadily.

What is mksquashfs progress actually counting? here is my closest effort.
first start mksquashfs fs in one term.
Code:
 mksquashfs /mnt/sdc3/lap/stems-apps /mnt/sdc3/lap/stems-app.sfs -comp xz

then in another term
Code:
tot=$(du -k /mnt/sdc3/lap/stems-apps | tail -1 | awk '{print $1}'); while sleep 1; do size=$(du -k /mnt/sdc3/lap/stems-appp.sfs | awk '{print $1}'); perc=$((size * 88 / (tot/4))); echo "$size"; echo $perc; done | yad --progress --percentage=0 --progress-text=""
 

I could not use --auto-close because 100% is frequently reached as mksquashfs rewrites the .sfs file on disk.
xscreenshot-20191020T124939.png
 Description   
 Filesize   16.6 KB
 Viewed   193 Time(s)

xscreenshot-20191020T124939.png

xscreenshot-20191020T125103.png
 Description   
 Filesize   14.95 KB
 Viewed   193 Time(s)

xscreenshot-20191020T125103.png

xscreenshot-20191020T125337.png
 Description   
 Filesize   14.29 KB
 Viewed   193 Time(s)

xscreenshot-20191020T125337.png

xscreenshot-20191020T125418.png
 Description   
 Filesize   13.3 KB
 Viewed   193 Time(s)

xscreenshot-20191020T125418.png


Last edited by stemsee on Tue 22 Oct 2019, 05:11; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4157
Location: holland

PostPosted: Mon 21 Oct 2019, 09:55    Post subject:  

Hi stemsee, maybe this can help ?
http://murga-linux.com/puppy/viewtopic.php?t=111674
But I think finally it turned out that Xdialog is more suitable than yad for this.

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

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

PostPosted: Mon 21 Oct 2019, 16:12    Post subject:  

Thanks Fred

I got the yad version working well!

cheers
stemsee

EDIT: improved
dir2sfs.gz
Description 
gz

 Download 
Filename  dir2sfs.gz 
Filesize  2.13 KB 
Downloaded  19 Time(s) 
xscreenshot-20191021T200553.png
 Description   
 Filesize   6.56 KB
 Viewed   150 Time(s)

xscreenshot-20191021T200553.png

Back to top
View user's profile Send private message MSN Messenger 
misko_2083


Joined: 08 Nov 2016
Posts: 88

PostPosted: Tue 29 Oct 2019, 14:15    Post subject:  


It's working.
https://www.youtube.com/watch?v=cwJMRKAQAMU
That is html and forms in an undecorated paned dialog.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 50 of 51 [751 Posts]   Goto page: Previous 1, 2, 3, ..., 48, 49, 50, 51 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.0819s ][ Queries: 12 (0.0066s) ][ GZIP on ]