You are not logged in.
Im trying to create my own cancel button instead of using the gtk cancel button shipped with yad, i think i have it figured but i dont like the fact this command kills all instances of yad, i just want it to cancel the exit dialog only, so basically kill itself lol. Is that possible? Im using the --no-buttons flag so it doesn't show the cancel or ok buttons.
yad --no-buttons --form --width=250 --center --on-top --undecorated --text-align="center" --text="Exit Artix" \
--field="logout":fbtn "openbox --exit" \
--field="reboot":fbtn "sudo reboot" \
--field="poweroff":fbtn "sudo poweroff" \
--field="lock":fbtn "slock" \
--field="cancel":fbtn "yad-cancel" \
Edit:
Probably not the best solution but it works, find and kill a process in regex.
Found here: https://stackoverflow.com/questions/351 … -and-regex
script is called "yad-cancel" and gets called by last field fbtn in the yad script.
#!/bin/bash
kill $(ps aux | awk '/Exit Artix/ {print $2}')
Edit 2. No need for grep.
Last edited by S7.L (2019-02-04 14:35:15)
Offline
Ok so i figured it out in the one script instead of calling another with the use of a function. Very cool
#!/bin/bash
yad-cancel() {
kill $(ps aux | awk '/Exit Artix/ {print $2}')
}
yad --no-buttons --form --width=250 --center --on-top --undecorated --text-align="center" --text="Exit Artix" \
--field="logout":fbtn "openbox --exit" \
--field="reboot":fbtn "sudo reboot" \
--field="poweroff":fbtn "sudo poweroff" \
--field="lock":fbtn "slock" \
yad-cancel --field="cancel":fbtn ""\
Offline
Or get the process id when you first start yad, then use that to kill it
yad
yadPID=$!
...
kill $yadPID
Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt «» BunsenLabs on DeviantArt
Offline
^^ thanks for that damo and misko, seems my script was way off and stopped working which is weird because it was working yesterday.
I actually tried " Kill -USR1 $YAD_PID" in the functionbut was unsure how to call in the field button, so that helped me understand a bit better misko, thanks.
so export -f
Options
-f The names refer to shell functions;
otherwise the names refer to shell variables.
and bash -c
-c If the -c option is present, then commands are read from the
first non-option argument command_string. If there are
arguments after the command_string, the first argument is
assigned to $0 and any remaining arguments are assigned to
the positional parameters. The assignment to $0 sets the
name of the shell, which is used in warning and error
messages.
Offline
Back again, i love yad.
I cant take full credit for this as i found it here http://smokey01.com/yad/.
But i modified it to suit, so this is a feh wallpaper picker, unfortunatly it just shows you a list of where you keep your wallpapers and when you double click a directory item in the list it sets the background wallpaper in scale mode eg; --bg-scale.
This could be hacked so much more to be similar to nitrogen i think.
So once you set an image to background feh in its awesomeness created ~/.fehbg script you can autostart from .xinitrc or openbox autostart or where programs you autostart are.
#!/usr/bin/env bash
yad --title="--dclick-action=CMD" --width=700 --height=400 --separator=" " --list --dclick-action="feh --bg-scale" --column=Fehpicker $HOME/Pictures/Walls/*
scrot..
Offline
^ I didn't get that gtk warning when i run it from the terminal but i will definitely take your word for it and add it in.
Offline
The little installer/unpacker I'm making.
This script doesn't work with GTK3 YAD.
Displayed some bar only.
//upd
Adding "--fixed" to "yad --paned..." makes GTK3 version work.
//upd2
This is your GTK3 YAD modified script by me, but Cancel-quit button (fbtn) only abort unpacking :
#!/bin/bash
export main_proc_id="$(mktemp -u --tmpdir fpid.XXXXXXXX)"
export progress_pipe="$(mktemp -u --tmpdir ftd.XXXXXXXX)"
mkfifo "$progress_pipe"
export form_pipe="$(mktemp -u --tmpdir ftd2.XXXXXXXX)"
mkfifo "$form_pipe"
trap 'rm -f "$main_proc_id" "$progress_pipe" "$form_pipe"' "EXIT"
export key="$(($RANDOM * $$))"
export unpack='bash -c "install_app %1 %2 %3 %4"'
export cancel_quit='bash -c "get_pid_and_kill $1" 2>/dev/null'
function install_app
{
echo "@disabled@" > "$form_pipe"
echo "@disabled@" > "$form_pipe"
echo "@disabled@" > "$form_pipe"
echo "@disabled@" > "$form_pipe"
echo "@disabled@" > "$form_pipe"
echo "$cancel_quit &" > "$form_pipe"
# Unpacking package
#COMMAND HERE DEPENDS ON ARCHIVER
wait "$(<$main_proc_id)" 2>/dev/null
if [ "$?" = "0" ]; then
echo "#Installation completed" >> "$progress_pipe"
kill "$main_pid" 2>/dev/null
>"$main_proc_id"
else
echo "#Installation canceled" >> "$progress_pipe"
kill "$main_pid" 2>/dev/null
>"$main_proc_id"
fi
}
export -f install_app
function get_pid_and_kill
{
sure_command='"yad --title=" " --width=1 \
--text="Are you sure you want to cancel?" \
--text-align=center --on-top --center \
--window-icon="system-software-install" \
--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" == "" ]]; then
if yad --title=" " --width=1 \
--text="Are you sure you want to cancel?" \
--text-align=center --on-top --center \
--window-icon="system-software-install" \
--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
fi
fi
[[ "$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<> "$form_pipe"
yad --paned --key="$key" --no-buttons \
--window-icon="system-software-install" --fixed \
--center --no-escape --splash & main_pid="$!"
yad --plug="$key" --tabnum=1 --form \
--field=" Select the destination path::DIR" \
--field=" Create a launcher in the applications menu:CHK" \
--field=" Create a launcher on the desktop:CHK" \
--field=" Begin Installation!system-software-install:fbtn" \
--field=" Cancel Installation and quit!gtk-quit:fbtn" \
--cycle-read <&4 &
echo "$HOME" > "$form_pipe" # default directory
echo "TRUE" > "$form_pipe" # default first checkbox value
echo "FALSE" > "$form_pipe" # default second checkbox value
echo "$unpack &" > "$form_pipe" # progress bar value
yad --plug="$key" --tabnum=2 --progress <&3 &
wait "$main_pid" 2>/dev/null
exec 3>&-
exec 4>&-
How to make the button immediately cancel all processes and close the window after confirm dialog?
I made another working installer (similar on the screenshots above) with GTK2/3 YAD and percentage progress (without log expander), without pv etc, only YAD and archiver. But here is no way to give you a cloud link to its for testing.
I've a couple of questions for you about window manager. There is a script with pop-up dialog while close the window (after count actions):
#!/bin/bash
while true; do
Record=(`yad --text "Click Action button or close this window" \
--width=400 --height=300 --center --button="Action":1`)
Action=$?
if [[ $Action == 1 ]]; then
yad --width=300 --height=100 --title="Do you want to Action?" \
--text "Click OK to confirm Action" --center
ret=$?
# Cancel = 252, OK = 0
if [[ $ret == 0 ]]; then
((TransCount++))
let i=1
while [ $i -lt $ListArrCnt ]; do
if [ ${ListArr[$i]} -eq ${RecArr[1]} ]; then
# Matching record number
j=$(($i - 1))
k=$(($j + $RecArrCnt))
while [ $j -lt $k ] ; do
unset 'ListArr[$j]'
j=$(($j + 1))
done
for i in "${!ListArr[@]}"; do
NewArr+=( "${ListArr[$i]}" )
done
ListArr=("${NewArr[@]}")
unset NewArr
let i=$(($ListArrCnt + 1)) # force exit from while loop
else
let i=$(($i + $RecArrCnt)) # Check next entry
fi
done
fi
elif [[ $Action == CLOSE ]] || [[ $Action == 252 ]]; then
# Cancel-quit or X close the window or Escape
if [[ $TransCount -gt 0 ]]; then
yad --question --center --on-top --text "You have made $TransCount action(s). Do you really want to quit?"
rc=$?
if [[ $rc -eq 0 ]]; then
exit
fi
else
exit
fi
fi
done
But I don't figure out how to do this in installer script, i.e. WM close button action the same as Cancel-quit.
Last edited by Anton (2019-04-12 13:58:45)
Offline
Second issue
I add "--splash" instead "--undecorated" and now Alt+F4 don't close the window.
Good bye Alt+Tab/Taskbar But it'better than nothing. The window can now be closed only with Quit button.
Offline
Here it is. I hope it work with Gtk3.
Thank so much. I'll see it later.
//upd
The closing action window is working, but there is no filling of the progress bar, although the percentages are working.
//upd2
Hmm, it works completely (the progress bar is being filled) with the real unpacking, but if the window closes, the request dialog doesn't appear.
Here is an example: yadi.sk/d/07nC3KGxevzcYA
Last edited by Anton (2019-04-13 16:05:17)
Offline
Да си жив и здрав.
You'll figure it out eventually.I like to help but realy don't want to run those BLOBs in the archive.
It's more than enough having all those proprietary BLOBs in the linux kernel.
There is no proprietary BLOBs in the tar.
Except the game itself in the pak.arc (archive) file that I packed with the FreeArc archiver. See github links in readme.txt, encode.ru and others sites.
Of course, running the game is not necessary.
If you want, I can pack something else.
Last edited by Anton (2019-04-24 19:47:13)
Offline
tint2 and yad are ace. Not sure you could easily do that with another panel!
Offline
Hello misko_2083,
in another forum you have ever helped very well. Now I find you here again by chance and have a question: I have created a YAD code under Linux Mint 18.3 and would like to build a progress bar for the FFMPEG command. But I need help. Here is my code:
#!/bin/bash
# videoformat auf 16:9 einstellen
cd /
cd /home/achim/Videos/
TITLE="Videoformat auf 16:9 einstellen"
TEXT="<span foreground='red'><b><big><big>
Bitte eine beliebige Datei selektieren und mit 'OK' fortfahren!
</big></big></b></span>"
filename=$(yad --width=1500 --height=600 --window-icon="/home/achim/.icons/Movies-icon24.png" --title="$TITLE" --text="$TEXT" --file-selection \
--button=" Abbrechen!/home/achim/.icons/Button-stop-icon24.png":1 --button=" OK!/home/achim/.icons/Accept-icon24.png":0 \
--file-filter='*.mp4')
pfadname=${filename}
verz=${filename%/*}
datm=${pfadname##*/}
dato=${datm%.*}
[[ -z "$filename" ]] && exit 0
cd /
cd "$verz"
mediainfo --Output=file:///home/achim/.config/achim/medinfo.txt "$datm" > /home/achim/.config/achim/medlog.odt
va="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$datm")" # = 334.089000
va1=${vb%.*} # = 334
secs=va1 # 334
va2=$(printf '%H:%M:%S' $(($secs/3600)) $(($secs%3600/60)) $(($secs%60)))
#va3=`date +%00:%M:%S`
va3="$(date +%T)"
ffmpeg -hide_banner -i "$datm" -vf scale="1920:1080" -aspect 16:9 -b:a 320000 "${datm%.*}-169.mp4" | yad --progress \
--progress-text="DerVorgang startete um $va3 und dauert etwa $va2" --width=1200 --height=300 --center --window-icon="gtk-execute" \
--title="Die Konvertierung des Videos '$datm' läuft..." --timeout=$va1 --timeout-indicator=Bottom --no-button --auto-kill --auto-close
exit 0
# va1 (334 Sekunden) = Laufzeit der Fortschrittanzeige für dieses Beispiel
Do you have a tip for me? (Sorry for my bad English)
achim
Last edited by achim (2019-08-23 22:14:46)
Offline
^ all I can see is that ffmpeg itself does not know when it will be finished; where do you plan to get the percentages for the progress bar?
- Ok, answering my own question:
man ffmpeg
...
-stats (global)
Print encoding progress/statistics. It is on by default, to explicitly disable it you need to specify "-nostats".
-progress url (global)
Send program-friendly progress information to url.
Progress information is written approximately every second and at the end of the encoding process. It is made of "key=value" lines. key consists of only alphanumeric characters. The last key
of a sequence of progress information is always "progress".
Offline
In between I helped myself a little and changed the code accordingly. But the progress bar is still a bit inaccurate. I keep working on it.
achim
Offline
please use "$HOME" instead of /home/achim.
Makes it easier for others to test or use your script.
Offline
@ achim, Might be a few hints in this script from here http://smokey01.com/help/yad-tips-0.0.2.html
#!/bin/sh
eval exec yad --title="xdf" \
--image=drive-harddisk \
--text="Disk\ usage:" \
--buttons-layout=end \
--width=650 \
--multi-progress \
$(df -hT $1 | tail -n +2 | awk '{printf "--bar=\"<b>%s</b> (%s - %s) [%s/%s]\" %s ", $7, $1, $2, $4, $3, $6}')
Last edited by clusterF (2019-08-24 13:16:41)
Offline
Hello everybody,
I have the code ready now and it works quite well. With the variables vb, vc and vd I have adjusted the speed of the progress bar, since ffmpeg runs faster with me than the tool ffprobe has determined. With the variable the speed of the progress bar can be changed according to the speed of the system.
If you can still make suggestions for improvement, I am always grateful for it.
I thank the users @ohnonot and @clusterF for their help.
Here is the script:
#!/bin/bash
# videoformat auf 16:9 einstellen
cd /
cd $HOME/Videos/
TITLE="Videoformat auf 16:9 einstellen"
TEXT="<span foreground='red'><b><big><big>
Bitte eine beliebige Datei selektieren und mit 'OK' fortfahren!
</big></big></b></span>"
filename=$(yad --width=1500 --height=600 --window-icon="$HOME/.icons/Movies-icon24.png" --title="$TITLE" --text="$TEXT" --file-selection \
--button=" Abbrechen!$HOME/.icons/Button-stop-icon24.png":1 --button=" OK!$HOME/.icons/Accept-icon24.png":0 \
--file-filter='*.mp4')
pfadname=${filename}
verz=${filename%/*}
datm=${pfadname##*/}
dato=${datm%.*}
[[ -z "$filename" ]] && exit 0
cd /
cd "$verz"
mediainfo --Output=file:///$HOME/.config/achim/medinfo.txt "$datm" > $HOME/.config/achim/medlog.odt
va="$(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$datm")" # = 334.089000
vb=${va%.*} # = 334
vc=10
vd=6
((va1=$vb/$vc*$vd))
secs=vb # 334
va2=$(printf '%d Stunden, %d Minuten, %d Sekunden ' $(($secs/3600)) $(($secs%3600/60)) $(($secs%60)))
#va3=`date +%00:%M:%S`
va3="$(date +%T)"
ffmpeg -hide_banner -i "$datm" -vf scale="1920:1080" -aspect 16:9 -b:a 320000 "${datm%.*}-169.mp4" | yad --progress \
--progress-text="Der Vorgang startete um $va3 und dauert etwa $va2" --width=1200 --height=150 --center --window-icon="gtk-execute" \
--title="Die Konvertierung des Videos '$datm' läuft..." --timeout=$va1 --timeout-indicator=top --no-buttons --auto-kill --auto-close
yad --text-info --title="Die Mediainfos zu dem Video '$datm' " --width=1000 --height=800 --center --window-icon="gtk-execute" --wrap --back=gainsboro \
--fore=blue < $HOME//.config/achim/medlog.odt --fontname=" Monospace italic 12"
exit 0
# va1 (334 Sekunden) = Laufzeit der Fortschrittanzeige für dieses Beispiel
achim
Offline
^ Great!
A few things:
"cd /" is pointless. Remove it.
mediainfo files: are they temprary? are you planning on keeping them? If not, it might be a good idea to clean up after the script has finished. And use a folder that is present on all systems, not only yours.
Why is the input limited to .mp4 files?
I tested, the progress bar ran out before conversion was finished. Just a minute or so, but that's bad.
Offline
Thank you @ sononot
Top 1: done
Top 2: I will reconsider this point
Top 3: The selection can be extended (for example by changing the line 15 in --file-filter='*.mp4' --file-filter='*.m4a' --file-filter='*.avi')"
Top 4: Extend the runtime of the progress bar by increasing the variable vd (line 32) to 7, 8 or 9
Best regards
achim
Last edited by achim (2019-08-25 11:05:55)
Offline
Hello everybody,
I have created a YAD code to convert images. Now I want to make the fixed 50% but flexible. For this I need one, however, an additional input field. Can someone tell me if another query is needed or can I do everything with the following code?
#!/bin/bash
# Bilder konvertieren (Einzeln)
cd $HOME/Bilder/
TITLE="Bild konvertieren"
TEXT="<span foreground='red'><b><big><big>
Bitte das gewünschte Bildformat wählen, eine beliebige Datei selektieren und mit 'OK' fortfahren!
</big></big></b></span>"
filename=$(yad --width=1600 --height=600 --window-icon="$HOME/.icons/Movies-icon24.png" --title="$TITLE" --file-selection \
--text="$TEXT" --button=" Abbrechen!$HOME/.icons/Button-stop-icon24.png":1 --button=" OK!$HOME/.icons/Accept-icon24.png":0 \
--file-filter='*.png' --file-filter='*.jpg' --file-filter='*.tif')
pfadname=${filename}
verz=${filename%/*}
datm=${pfadname##*/}
dato=${datm%.*}
cd "$verz"
[[ -z "$filename" ]] && exit 0
case $filename in
*.png)
echo "Konvertierung des Bildes "$datm" läuft...";
convert "$datm" -resize 50% "$datm"-neu.png
yad --text="<span color='red'>Die Konvertierung des Bildes
$datm
wird erzeugt...</span>" --width=550 --window-icon="$HOME/.icons/Movies-icon24.png" \
--title="Verlaufskontrolle" --text-align=center --no-buttons --timeout=3;
;;
*.jpg)
echo "Konvertierung des Bildes "$datm" läuft...";
convert "$datm" -resize 50% "$datm"-neu.jpg
yad --text="<span color='red'>Die Konvertierung des Bildes
$datm
wird erzeugt...</span>" --width=550 --window-icon="$HOME/.icons/Movies-icon24.png" \
--title="Verlaufskontrolle" --text-align=center --no-buttons --timeout=3;
;;
*.tif)
echo "Konvertierung des Bildes "$datm" läuft...";
convert "$datm" -resize 50% "$datm"-neu.tif
yad --text="<span color='red'>Die Konvertierung des Bildes
$datm
wird erzeugt...</span>" --width=550 --window-icon="$HOME/.icons/Movies-icon24.png" \
--title="Verlaufskontrolle" --text-align=center --no-buttons --timeout=3;
;;
esac
exit 0
Offline