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 23 Oct 2019, 17:16
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 40 of 50 [749 Posts]   Goto page: Previous 1, 2, 3, ..., 38, 39, 40, 41, 42, ..., 48, 49, 50 Next
Author Message
stemsee

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

PostPosted: Fri 08 Mar 2019, 16:29    Post subject:  

Hi step

That's a good solution for paned which is limited to two panes and the frame. I am thinking of 4 or more tabs. When a tab is selected yad internally sends signals so it is known which is the last tab selected, I really want to know how to get at that signal/info programmatically, internally without using xdotool. Maybe I will need to post a feature request with Victor.

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

Joined: 04 May 2012
Posts: 1214

PostPosted: Thu 14 Mar 2019, 04:03    Post subject:  

stemsee wrote:
Hi step

That's a good solution for paned which is limited to two panes and the frame. I am thinking of 4 or more tabs. When a tab is selected yad internally sends signals so it is known which is the last tab selected, I really want to know how to get at that signal/info programmatically, internally without using xdotool. Maybe I will need to post a feature request with Victor.

stemsee
If you do request a feature make sure to tell Victor it's for GTK2 because he's announced future versions won't support GTK2 anymore.

Fatdog64-800 still requires GTK2. Don't know about which Puppies and Dogs do too.

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

Joined: 06 Aug 2018
Posts: 7

PostPosted: Wed 27 Mar 2019, 12:33    Post subject:  

misko_2083 wrote:
Thanks fredx181, don't know why I thought that DIR field in the form dialog doesn't quote the path. Rolling Eyes

lika Added pv command to display the progress. One more dependancy to install but I see no other way for now.

X window button is managed by the window manager so intercepting it is impossible. It's only possible to get the exit status 252 when the window is closed via X.That's why I added undecoratzed to pprevent the paned dialog from closing and --no-escape to prevent closing the same dialog if Escape was pressed. That is the simplest solution. Anything else would be too complex.

To use the checkboxes in the function install_app you would need to check if $2 and $3 are true or false.

The script now displays extra dialogs and prevents them from opening multiple times e.g.if the cancel and abort buttons are clicked several times. This is working for me:
Code:
#!/bin/bash

if ! hash pv; then
   yad --text "install pv first"
   exit 1
fi

export faextraxt='bash -c "install_app %1 %2 %3 %4"'

# We need this to store the main proces ID
export main_proc_id=$(mktemp -u --tmpdir fpid.XXXXXXXX)

export progress_pipe=$(mktemp -u --tmpdir ftd.XXXXXXXX)
mkfifo "$progress_pipe"

export percentage_pipe=$(mktemp -u --tmpdir ftd2.XXXXXXXX)
mkfifo "$percentage_pipe"

export form_pipe=$(mktemp -u --tmpdir ftd3.XXXXXXXX)
mkfifo "$form_pipe"

trap "rm -f $progress_pipe $percentage_pipe $form_pipe $main_proc_id" EXIT

fakey=$(($RANDOM * $$))

function install_app
{
# Form fields are read in a cycle 1-4, each cycle sets new values

# Disables all the form fields when the install starts
echo "@disabled@" > "$form_pipe"
echo "@disabled@" > "$form_pipe"
echo "@disabled@" > "$form_pipe"
echo "@disabled@" > "$form_pipe"

echo "#Selected extraction path: $1" >> "$progress_pipe"
echo "#" >> "$progress_pipe"
echo "#Add a shortcut in the applications menu : $2" >> "$progress_pipe"
echo "#Add a desktop shortcut : $3" >> "$progress_pipe"
echo "#" >> "$progress_pipe"


  echo "#Preparing to extract..." >> "$progress_pipe"

   >"$main_proc_id"
   while read -r line; do
     # If line is a integer number
     if [[ "$line" == +([0-9]) ]];then
        echo "$line" >> "$progress_pipe"
     else
        echo "#$line" >> "$progress_pipe"
     fi

   done < "$percentage_pipe" &
   LOOP_PID="$!"

    # main process example for a demonstration purpose
    # for i in {1..100}; do echo "$i %" 2>&1 >> $percentage_pipe; sleep .1; done & echo $! > "$main_proc_id"

    pv -n archive.tar.xz 2>$percentage_pipe | xzcat | tar xp -C "$1" -v 2>&1 >> $percentage_pipe & echo $! > "$main_proc_id"

    # Wait here
    # Wait returns exit status ${?}
    # It's stderr is redirected to /dev/null to prevent kill command to print messages
    wait $(<$main_proc_id) 2>/dev/null

    if [[ "$?" = 0 ]]
    then
         echo "100%" >> "$progress_pipe"
         echo "#Install completed." >> "$progress_pipe"
         kill "$LOOP_PID"
         >$main_proc_id
         yad --text="Install successfull" --button="gtk-ok:0"  &
    elif [[ ! -s "$main_proc_id" ]]; then
         echo "#Install canceled." >> "$progress_pipe"
         kill "$LOOP_PID"
         >$main_proc_id
    else
         echo "#Install error." >> "$progress_pipe"
         kill "$LOOP_PID"
         >$main_proc_id
    fi

    # Resets the field values when the install ends
    echo "$1" > $form_pipe
    echo "$2" > $form_pipe
    echo "$3" > $form_pipe
    echo "$faextraxt &" > $form_pipe
}
export -f install_app

function get_pid_and_kill () {
Sure_Command='yad --text=Are you sure you want to cancel the installation? --button=gtk-yes:0 --button=gtk-no:1'
Sure_Command_PID="$(ps -eo pid,cmd | grep -F "$Sure_Command" | grep -v "grep" | awk '{ print $1 }')"

if [[ -s "$main_proc_id" ]] && [[ "$Sure_Command_PID" == "" ]] && yad --text="Are you sure you want to cancel the installation?" --button="gtk-yes:0" --button="gtk-no:1"; then
  if [[ -s "$main_proc_id" ]]; then
     BCKUPID="$(<$main_proc_id)"
     >"$main_proc_id"
     kill $BCKUPID 2>/dev/null
     sleep 1
  fi
   # The special yad variable $YAD_PID stores the main window PID
   # killing that PID closes the window
  [[ "$1" == "CLOSE" ]] && kill -s SIGUSR1 $YAD_PID
elif [[ ! -s "$main_proc_id" ]] ; then
  [[ "$1" == "CLOSE" ]] && kill -s SIGUSR1 $YAD_PID
fi

}
export -f get_pid_and_kill

exec 3<> $progress_pipe
exec 4<> $percentage_pipe
exec 5<> $form_pipe

yad --plug="$fakey" --tabnum=1 --form \
    --field="Choose a folder:DIR" \
    --field="Add a shortcut in the applications menu:CHK" \
    --field="Add a desktop shortcut:CHK" \
    --field="Install!system-software-install:fbtn" --cycle-read <&5 &

    # This is the initial cycle that sets the form field values
    echo "${HOME}" > $form_pipe         # set default folder in this line
    echo "TRUE" > $form_pipe               # default first checkbox value
    echo "FALSE" > $form_pipe              # default second checkbox value
    echo "$faextraxt &" > $form_pipe

yad --plug="$fakey" --tabnum=2 --window-icon="$ICON" --progress \
--enable-log="Show log" --log-height=100 --tail --borders=5 <&3 &


yad --paned --key="$fakey" --buttons-layout=edge \
    --button="gtk-close":'bash -c "get_pid_and_kill CLOSE" 2>/dev/null' \
    --button="Abort!gtk-stop":'bash -c "get_pid_and_kill" 2>/dev/null' \
    --text="" --title="TEST" --window-icon="$ICON" --center \
    --no-escape --undecorated & MAIN_PID=$!

# Redirecting kill output from get_pid_and_kill function to /dev/null
wait $MAIN_PID 2>/dev/null

exec 3>&-
exec 4>&-
exec 5>&-

Quote:
The script now displays extra dialogs and prevents them from opening multiple times e.g.if the cancel and abort buttons are clicked several times.

I tried this script, but the dialog opens every time if I click Cancel or Abort buttons.
Now I try to make a display progress and log output with 7z only (without tar), but it turns out only a log. Can you help how to do this?
This line:
Code:
pv -n | "$percentage_pipe" | 7za x archive.7z -bb3 -o"$1" 2>&1 >> "$percentage_pipe" & echo "$!" > "$main_proc_id"

-bb3 is output log level

Is there a way to make an Abort button inactive while unpacking? Even better to make one "Abort and Quit" button (fbtn) below the Install button and progress bar + log at the bottom of the window?
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3678
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Fri 05 Apr 2019, 16:28    Post subject:  

Bonsoir,
May be is there an answer among the 40 pages of this thread. If yes, just a link would be appreciated, if no:
For example, this works fine:
Code:
yad --text-info --back=red --fore=white < /root/\.history --fontname=Monospace

How could it work clicking a notification icon to display the text?
I tried this and many other combinations but without success:
Code:
yad --notification --text "TEXT TEST" --command="yad --text-info --back=red --fore=white < /root/\.history --fontname=Monospace" &

Thank you for your attention.

[EDIT] : when I couldn't believe it, I finally found a solution (for those who would be interested):
Code:
text () {
yad --text-info --back=red --fore=white < /root/\.history --fontname=Monospace
}
export -f text
yad --notification --icon-size=24 --auto-kill --text "TEXT TEST" --command="bash -c text" &

Cordialement.

_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
fredx181


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Sat 06 Apr 2019, 09:21    Post subject:  

Hi Argolance, I see you found solution, but just for info, it can work without function by using --filename= , e.g.:
Code:
yad --notification --text "TEXT TEST" --command="yad --text-info --back=red --fore=white --fontname=Monospace --filename=/root/\.history" &


Fred

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


Joined: 06 Jan 2008
Posts: 3678
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 06 Apr 2019, 09:31    Post subject:  

Bonjour,
Thanks fredx181!
It is why I said "a" solution but not "the" solution...
The more I use yad, the more I appreciate and discover the extent of what can be done with it. Not to mention the work of smokey01 and a few others: huge and so useful!

Cheers.

_________________

A second life for your PCs...

Last edited by Argolance on Sun 07 Apr 2019, 17:32; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
fredx181


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Sat 06 Apr 2019, 11:55    Post subject:  

@Argolance Ah, catched your avatar, now I know, you are fooling us all Laughing
Argolance-is-fooling-us.png
 Description   
 Filesize   2.56 KB
 Viewed   342 Time(s)

Argolance-is-fooling-us.png


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


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Sat 06 Apr 2019, 13:03    Post subject:  

Replying to question from here:
http://murga-linux.com/puppy/viewtopic.php?p=1024466#1024466

Hi achim, it looks like that the problem is that the commands are all on one line, separating them makes it work for me ( I've put an empty line between the command lines to make the separation more clear) :
Code:
#!/bin/bash

INPUT=$(yad --width=600 --height=400 --file-selection --file-filter='*.mp3 *.mp4 *.avi')
 
eval $(yad --width=400 --form --field=start --field=end --field=output:SFL "00:00:00" "00:00:00" "${INPUT/%.*}-out.${INPUT##*.}" | awk -F'|' '{printf "START=%s\nEND=%s\nOUTPUT=\"%s\"\n", $1, $2, $3}')
 
[[ -z $START || -z $END || -z $OUTPUT ]] && exit 1

DIFF=$(($(date +%s --date="$END")-$(date +%s --date="$START")))
 
OFFSET=""$(($DIFF / 3600)):$(($DIFF / 60 % 60)):$(($DIFF % 60))
 
ffmpeg -ss "$START" -t "$OFFSET" -i "$INPUT" "$OUTPUT"


The resulting quality is not the best IMO (from what I tested), but that's another story.

Fred

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

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Sat 06 Apr 2019, 13:43    Post subject:  

Hello Fred,

Thanks for your help, that's how it works for me.
I put the quality over the command "ffmpeg -ss", where you probably mean the audio result. Do you have a better suggestion for that?

achim
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Sat 06 Apr 2019, 14:12    Post subject:  

achim wrote:
Hello Fred,

Thanks for your help, that's how it works for me.
I put the quality over the command "ffmpeg -ss", where you probably mean the audio result. Do you have a better suggestion for that?

achim


Specially I found the video quality not good, is ok for me when using copy, then final ffmpeg line:
Code:
ffmpeg -i "$INPUT" -acodec copy -vcodec copy -ss "$START" -t "$OFFSET" "$OUTPUT"

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


Joined: 06 Jan 2008
Posts: 3678
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Sat 06 Apr 2019, 17:03    Post subject:  

fredx181 wrote:
@Argolance Ah, catched your avatar, now I know, you are fooling us all Laughing

Ah ah!
+1
Very Happy

_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
achim

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Sat 06 Apr 2019, 21:06    Post subject:  

Hello Fred,

that worked great. Thanks again for the support. Now I would like to adjust the selection of exact filter and possibly subsequently to the filter result via fi or esac different parameters for ffmpeg. So far, I've created the code like this:
Quote:
OUTFILETYPE=$(yad --list --title="Select File Type" --text="file type selection" \
--column="Select" --column="File Type" --radiolist false avi true mp4 false mp3)

I do not know how to connect it to the code above. Do you have a suggestion?

achim
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4125
Location: holland

PostPosted: Sun 07 Apr 2019, 03:43    Post subject:  

Hi achim, I'm not sure at which point in the script you'd like to add this selection dialog, anyway, maybe something like this ? (added --print-column=2) :

Code:
OUTFILETYPE=$(yad --list --title="Select File Type" --text="file type selection" \
--column="Select" --column="File Type" --radiolist --print-column=2 false avi true mp4 false mp3)
[ $? -ne 0 ] && exit

if [ "$OUTFILETYPE" = "avi|" ]; then
ffmpeg ... ...
fi
if [ "$OUTFILETYPE" = "mp4|" ]; then
ffmpeg ... ...
fi
if [ "$OUTFILETYPE" = "mp3|" ]; then
ffmpeg ... ...
fi


EDIT:
Or maybe just this (no selection dialog, if condition based on the extension of $OUTPUT, e.g. avi ):
Code:
if [ "${OUTPUT##*.}" = "avi" ]; then
ffmpeg ... ...
fi
if [ "${OUTPUT##*.}" = "mp4" ]; then
ffmpeg ... ...
fi
if [ "${OUTPUT##*.}" = "mp3" ]; then
ffmpeg ... ...
fi


Fred

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

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Sun 07 Apr 2019, 13:41    Post subject:  

Hello Fred,

I have now decided once for this variant:

Quote:
#!/bin/bash

INPUT=$(yad --width=1000 --height=600 --file-selection --file-filter='*.avi' --file-filter='*.mp3' --file-filter='*.mp4')

eval $(yad --width=400 --form --field=start --field=end --field=output:SFL "00:00:00" "00:00:00" "${INPUT/%.*}-out.${INPUT##*.}" | awk -F'|' '{printf "START=%s\nEND=%s\nOUTPUT=\"%s\"\n", $1, $2, $3}')

[[ -z $START || -z $END || -z $OUTPUT ]] && exit 1

DIFF=$(($(date +%s --date="$END")-$(date +%s --date="$START")))

OFFSET=""$(($DIFF / 3600)):$(($DIFF / 60 % 60)):$(($DIFF % 60))

if [ "${OUTPUT##*.}" = "avi" ]; then
ffmpeg ... ...
fi
if [ "${OUTPUT##*.}" = "mp4" ]; then
ffmpeg -ss "$START" -t "$OFFSET" -i "$INPUT" "$OUTPUT"
fi
if [ "${OUTPUT##*.}" = "mp3" ]; then
ffmpeg ... ...
fi
exit 1


Gladly I would have your suggestion with the parameter choice for FFMPEG taken over, however, then each time with the new video file the first 4-5 seconds without picture, but with sound. Of course, the code is not finished yet, I can think of a lot more. If you have any other suggestions, feel free to sign up again. I was very happy about your help and hope that I can return the favor.

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

Joined: 13 Apr 2017
Posts: 47
Location: Germany

PostPosted: Mon 08 Apr 2019, 03:57    Post subject:  

Hi Fred,

if you're interested, I changed the parameter order for the FFMPEG command as follows:
Code:
ffmpeg -ss "$START" -t "$OFFSET" -i "$INPUT" -acodec copy -vcodec copy "$OUTPUT"


So everything works to my satisfaction.

Best regards

achim
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 40 of 50 [749 Posts]   Goto page: Previous 1, 2, 3, ..., 38, 39, 40, 41, 42, ..., 48, 49, 50 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.2422s ][ Queries: 13 (0.1293s) ][ GZIP on ]