You are not logged in.
Got the solution from the Yad-Command Google Group. Now, each checklist item has its own image.
https://groups.google.com/g/yad-common
@Misko: "There are two lists. The text in hidden column 6 is sent to the second list through pipe and straight to the column of type IMG. The fuction split_arg sends a form feed character to reset the second list and print the path of the image".
#!/bin/bash
split_arg () {
echo -e "\f"
echo "$6"
}
export -f split_arg
export fpipe="$(mktemp -u --tmpdir fvwmei.XXXXXXXX)"
mkfifo "$fpipe"
trap "rm "$fpipe"" EXIT
exec 3<> "$fpipe"
key=$RANDOM
yad --plug=$key --tabnum=1 \
--select-action='bash -c "split_arg %s >$fpipe"' \
--hide-column=6 \
--list --checklist \
--width=900 --height=650 \
--column=Y/N --column=No: --column="Ext type" \
--column=Extension --column=Description --column="" \
false 101 Functions "Auto Hide List" "Short description." "auto-hide.png" \
false 102 Functions "Auto Move Windows" "Short description." "auto-move.png" \
false 201 Styles "Diary Border Style" "Short description." "diary-style.png" \
false 202 Styles "DiaryThumbnails" "Short description." "diary-thumb.png" >inst.txt &
yad --plug=$key --tabnum=2 --list --no-headers --listen --cycle-read --column=":IMG" <&3 &
yad --paned --key=$key --title="Extension Installer" \
--center --orient=Horizontal --splitter=500 --width=800 --height=600
exec 3>&-
exit
Offline
I've been working on my random wallpaper changer, and am having an issue with killing the current instance before applying another.
Here is my current script based on one of the yad examples.
I want to basically add a killall (or pkill, whatever), to each selection so as not to have multiple running instances upon selection.
Here is the current script with the 5 minute timer set to 10 seconds to test.
#! /bin/bash
random=$(yad --width 300 --entry --title "Random Background" --center --window-icon=applications-system \
--image="/usr/share/icons/ld-icons/timer.png" \
--button="Fast Flip":"bash -c 'feh --bg-scale --randomize $HOME/Pictures/wallpapers/*'" \
--button="gtk-ok:0" --button="gtk-close:1" \
--text "Choose action:" \
--entry-text \
"Off" "5 Minutes" "10 Minutes" "30 Minutes" "60 Minutes" "2 Hours")
case $random in
Off*) while true;
do
killall "toggle-wallpaper-random"
done &
notify-send 'Random Wallpaper Off' ;;
5*) while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 10s
done &
notify-send 'Random Wallpaper Every 5 Minutes' ;;
10*) while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 600s
done &
notify-send 'Random Wallpaper Every 10 Minutes' ;;
30*) while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 1800s
done &
notify-send 'Random Wallpaper Every 30 Minutes' ;;
60*) while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 3600s
done &
notify-send 'Random Wallpaper Every 60 Minutes' ;;
2*) while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 7200
done &
notify-send 'Random Wallpaper Every 2 Hours' ;;
*) exit 1 ;;
esac
Something like this, though this does not work:(
5*) while true;
do
killall "toggle-wallpaper-random" && feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 10s
done &
notify-send 'Random Wallpaper Every 5 Minutes' ;;
So, how do I add a killall to each selection?
Offline
^ Any ideas to this? I think I may be approaching it a little wrong.
I would suppose the question at hand is, How can I add a Killall BEFORE any selection rather than with a selection? Currently any selection can be added to, causing numerous changes.
Any help here would be much appreciated. I'm making gains in these areas, and learn best from having the answer at hand and then applying it to other problems. Any clues appreciated.
Offline
@misco_2083 Thank you so much! You gave me exactly what I needed to get it working:) Essentially adding the 'find pid and kill' line to each selection. Awesome.
#!/bin/bash
#
#Feh random wallpaper changer
random=$(yad --width 300 --entry --title "Random Background" --borders=10 --center --window-icon=applications-system \
--image="preferences-system-time" \
--button="Fast Flip":"bash -c 'feh --bg-scale --randomize $HOME/Pictures/wallpapers/*'" \
--button="gtk-ok:0" --button="gtk-close:1" \
--text "Random BG Time Selection" \
--entry-text \
"Please Select Interval" "Off" "One Minute" "Five Minutes" "Ten Minutes" "Thirty Minutes" "Sixty Minutes" "Two Hours" "Four Hours" "Eight Hours" "Full 24 Hours")
[ $? -ne 0 ] && exit
## get pid and kill
# proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
# kill $proc_id
## can also wait untill the process exists
# wait $proc_id
case $random in
Off*) while true;
do
proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id
done &
notify-send 'Random Wallpaper Off' ;;
One*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 60s
done &
notify-send 'Random Wallpaper Every 1 minute' ;;
Five*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 5m
done &
notify-send 'Random Wallpaper Every 5 Minutes' ;;
Ten*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 10m
done &
notify-send 'Random Wallpaper Every 10 Minutes' ;;
Thirty*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 30m
done &
notify-send 'Random Wallpaper Every 30 Minutes' ;;
Sixty*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 60m
done &
notify-send 'Random Wallpaper Every 60 Minutes' ;;
Two*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 2h
done &
notify-send 'Random Wallpaper Every 2 Hours' ;;
Four*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 4h
done &
notify-send 'Random Wallpaper Every 4 Hours' ;;
Eight*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 8h
done &
notify-send 'Random Wallpaper Every 8 Hours' ;;
Full*) proc_id=$(ps -eo pid,cmd | grep 'toggle-wallpaper-random' | grep -v "grep" | awk '{ print $1 }')
kill $proc_id && while true;
do
feh --bg-scale "$(find "$HOME/Pictures/wallpapers" -type f -name '*.jpg' -o -name '*.png' | shuf -n 1)"
sleep 24h
done &
notify-send 'Random Wallpaper Every 24 Hours' ;;
*) exit 1 ;;
esac
Last edited by sleekmason (2022-03-23 12:50:43)
Offline
^ It was a lucky guess.
Can you make this script with the notification icon?
I do not understand, but sure! If I can:) What do you mean by notification icon? ( I changed the image path to usable by all). <-- Is this what you mean?
Offline
This sleep command is very persistent, doesn't want to terminate when run_cmd is killed.
https://imgur.com/pS6fJEj.png
Oh wow! I really like the tint2 addition;)
This is strange as the command terminates the interval countdown, but still shows "sleep" in top as active.
As any new time choice will replace any other without issue, we only need to find the final command to kill the whole thing. This should be simple, but obviously is not:)
Hold on . . . I think the command may terminate in top after it completes another cycle, but before making the next change. . . yep!
Start the one minute, kill it, and wait one minute for the action to complete the kill.
So, In the "Off" button, How do we kill the sleep after/during the main script is killed? Gonna try a few things . .
Okay, Using 'killall sleep' after the initial kill will end the sleep.
Yeah, using killall sleep did NOT work, just changed the color in top to throw me off. However, the below still applies.
So, How can we grab or assign (to kill later), the sleep command for the script itself without affecting anything else in the system that might be using 'sleep'
This can be added to just 'Off' with nothing more required.
I suppose anything like this should be solved. A one minute delay isn't an issue, but 24 hours in the cue afterwards seems a bit much if shutting off a 24 hour interval. However, it doesn't appear any resources are used either.
*Edit - If no resources are used, and it changes on any other selection so as not to be a repeating issue, does it truly matter if 'sleep' in this case is still an active single item? Is there a 'real world' problem with this? <-- Just thought of this and do not know the answer. In any event, of course it should be fixed if possible. Just wondering.
*Edit2 - The more I look at this, the less it seems to matter whether there is a pid running until completion, as it doesn't interfere with anything else, uses no resources, and affects no other operations that I can see. This, and being replaced when the script is called again, makes me think this is no big deal. Thoughts?
Last edited by sleekmason (2022-03-24 21:06:53)
Offline
@misco_1083 - I am so grateful you decided to take this on:)
In no way was I going to come close to this. Incredible and useful. Thank you for your hard work on this. It is really really cool.
Offline
^ Quick note for:
yad --notification --no-markup --text="Random Background Changer" \
To add the text to the notification icon.
So far so good elsewhere:)
Offline
@misco_1083 - I am so grateful you decided to take this on:)
In no way was I going to come close to this. Incredible and useful. Thank you for your hard work on this. It is really really cool.
+1
Thanks @misko_2083 for this script. It works wonderfully well on my mx-fluxbox system too.
The only thing puzzling me is how to get the icons displayed in the notification rightclick menu. Tried to set a full path to suitable icons, but the menu continues to show text entries only.
Is there a proven format other than: menu:[name]![action]![icon]|
Last edited by ceeslans (2022-03-26 10:12:44)
Offline
sleekmason wrote:@misco_1083 - I am so grateful you decided to take this on:)
In no way was I going to come close to this. Incredible and useful. Thank you for your hard work on this. It is really really cool.
+1
Thanks @misko_2083 for this script. It works wonderfully well on my mx-fluxbox system too.
The only thing puzzling me is how to get the icons displayed in the notification rightclick menu. Tried to set a full path to suitable icons, but the menu continues to show text entries only.
Is there a proven format other than: menu:[name]![action]![icon]|
Works here. Here is what I have now for that full section using gnome. Maybe that space on the last ".
# set notification right-click menu
echo "menu:Off! bash -c 'on_kill'!/usr/share/icons/gnome/22x22/actions/process-stop.png|| \
One Minute! bash -c 'wallpaper_shuffler 60'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png| \
Five Minutes! bash -c 'wallpaper_shuffler 5m'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png| \
Ten Minutes! bash -c 'wallpaper_shuffler 10m'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png| \
Thirty Minutes! bash -c 'wallpaper_shuffler 30m'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png| \
One Hour! bash -c 'wallpaper_shuffler 60m'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png| \
Two Hours! bash -c 'wallpaper_shuffler 2h'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png| \
Four Hours! bash -c 'wallpaper_shuffler 4h'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png| \
Eight Hours! bash -c 'wallpaper_shuffler 8h'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png| \
One Full Day! bash -c 'wallpaper_shuffler 24h'!/usr/share/icons/gnome/22x22/mimetypes/application-x-addon.png|| \
Exit!Quit!/usr/share/icons/gnome/22x22/actions/window-close.png " >&3
Last edited by sleekmason (2022-03-26 11:45:11)
Offline
Thanks misko, the "gtk-menu-images=1" did the trick!
The icons are now showing up nicely in the notification menu
Offline
Hey you great people out there!
I am a big fan of yad and allready managed to get some stuff done like a "frontend" for the kali-anonsurf tool with the help of the frindly people here
~/bin/anonsurf_helper
#!/bin/bash
#
# kali-anonsurf helper script
# provid a simple YAD-Interface for running Kali-Anonsurf
# provided under
# GNU General Public License v3.0
# like https://github.com/Und3rf10w/kali-anonsurf itself
# by Naik <naik@nachtlicht.one>
#
########################################################################
### Help message
function print_help {
echo "AnonSurf_Helper"
echo ""
echo "Usage: anonsurf_help [command] [logfile]"
echo ""
echo "[Command] could be one of the following"
echo "--help Show this help"
echo "--start Start system-wide anonymous"
echo " tunneling under TOR proxy through iptables"
echo "--stop Reset original iptables settings"
echo " and return to clear navigation"
echo "--restart Combines \"stop\" and \"start\" options"
echo "--change Changes identity restarting TOR"
echo "--status Check if AnonSurf is working properly"
echo "--myip Show your current IP address"
echo ""
echo "If run without arguments, one can be chosen from a yad dialogue later."
echo "All output will be written to a single logfile [logfile]."
echo "If none is specified its default is /tmp/anonsurf_helper.log"
echo ""
echo "GNU General Public License v3.0 like https://github.com/Und3rf10w/kali-anonsurf itself"
exit
}
### Choose action via GUI
function choose_action {
action=$(yad ---title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --posx=548 --height=184 --posy=133 --entry --button="gtk-ok:0" --button="gtk-close:1" --text "Was willst Du tun?:" --entry-text "Start" "Stop" "Change" "Restart" "Status" "MyIp")
echo $action
}
### Check requirements
if ! [ -x "$(command -v yad)" ]; then
echo 'Error: YAD is not installed.' >&2
exit 1
fi
if ! [ -x "$(command -v anonsurf)" ]; then
echo 'Error: git is not installed.' >&2
exit 1
fi
### check if /path/to/logfile is provided as second argument
### otherwise set default logfile to $HOME/tmp/anonsurf_helper.log
LOGFILE="/tmp/anonsurf_helper.log"
if touch $2; then
LOGFILE=$2
echo "Log will be written to "$LOGFILE"."
elif [ -f != $LOGFILE ]; then
touch $LOGFILE
echo "Log will be written to "$LOGFILE"."
fi
### choose action
if [ -z "$1" ]; then
choose_action
else
action=$1
fi
case $action in
--start|Start)
yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --posx=548 --height=84 --posy=333 --entry --hide-text | sudo -S anonsurf start > $LOGFILE 2>&1
yad --notification --image="/home/naik/.local/share/icons/anon.png" --text="You are under AnonSurf tunnel." --listen --command="bash -c anonsurf_helper" &
;;
--stop|Stop)
yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --height=84 --posx=548 --posy=333 --entry --hide-text | sudo -S anonsurf stop > $LOGFILE 2>&1 &&
killall yad 2>/dev/null
;;
--restart|Restart)
yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --height=84 --posx=548 --posy=333 --entry --hide-text | sudo -S anonsurf restart > $LOGFILE 2>&1
;;
--change|Change)
yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=294 --height=84 --posx=548 --posy=333 --entry --hide-text | sudo -S anonsurf change > $LOGFILE 2>&1
;;
--status|Status)
anonsurf status > $LOGFILE 2>&1
;;
--myip|MyIP)
anonsurf myip > $LOGFILE 2>&1
;;
*)
print_help
;;
esac
LOG=$( cat $LOGFILE| sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" )
yad --title="Anonsurf Helper" --window-icon="/home/naik/.local/share/icons/anon.png" --width=420 --posx=430 --height=230 --posy=190 --text="$LOG"
exit
But now I would like to provide a little mpv-frontend for the pi to run fullscreen on a 800x600 portrait touchscreen. It is supposed to provide a list of the files in the current mpv-playlist and a set of buttons to play/Paus/Next/Prev.. no Random/Shuffel etc just a list and some big shiny clickable icons.
But I am at a total loss and cannot think of a way to keep it up, when a button is clicked (or does it have to be reinvoked, which would be fine as well!)
May some is eager to have a take on it?
The problem is that every frontend known to me is intended as a web-frontend and I wouldnt like to run such a thing locally having the need to fire up a webbrowser when a simple gtk-window would suffice.
Thanks for hearing me out and in advance for any help.
Naik --greetz
"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen Codeberg
Offline
^ @Naik, If I read you correctly, in order to keep the choices on screen, you may need to use the button format like the example script below, or the BTN or FBTN format in a --field yad form. Either will allow for multiple selections of the same button until the dialog is closed.
Here is a small example of buttons that will stay until the dialog is closed.
#!/bin/bash
yad --title "Bunch O Buttons" --form --center --width=500 --height=52 --borders=4 --escape-ok \
--window-icon=preferences-system \
--form \
--button=" File Manager!system-file-manager!":"thunar" \
--button=" Editor!geany!":"geany" \
--button=" Browser!firefox-esr!":"firefox" \
--button=" Terminal!terminal!":"lxterminal" \
--button=" Notes!accessories-text-editor!":"mousepad" \
--button=gtk-close:1
Of course there are probably other ways as well.
Last edited by sleekmason (2022-04-25 15:43:02)
Offline
^Oh this is great, Sleekmason!
I'll try to get my head around this manipulating the commands for the buttons, add a list field for the content of mpd playlist and up we go... I'll back soon though I guess. Either to show-off or to ask for more help ;-)
Edit: may I ask for a icon refernece?
Last edited by Naik (2022-04-26 07:30:59)
"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen Codeberg
Offline
^ Good! Glad it may be useful:)
Are you talking best place to look for icons on your system? What I do is open Thunar --> edit --> configure custom actions --> (then pick any . .) --> edit the current theme --> click on the icon symbol for the searchable list. (cancel out of everything when finished).
I use this method for searching because it gives every icon for the theme, and the placement of the icon. (applications, actions, etc . . )
*edit - try the search word "back" for audio controls.
Last edited by sleekmason (2022-04-26 11:45:16)
Offline
^ WOW! Did You do this for me?
I will happily use this and I really thank you for sharing!
naik --greetz
"Kaum macht [Mensch]* es richtig, funktioniert es sofort!"
BL-Kitchen Codeberg
Offline
^^ Thanks for sharing Misko. How hard would it be to get alphabetical-sorting incorporated in the 'select to play' list ?
It so reminds me of your 'Poor Man's Radio Player' GUI script. I'm still running a customized and slightly modified version of your pmrp-gui script (dating back to 2017 or earlier?) almost every day.
Last edited by ceeslans (2022-04-29 11:22:19)
Offline
Well there is an open bug Maybe it'll get addressed one day.
Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me
Offline
MX is one of the very few debian-based distros that packaged yad v/7.3-0.1 from github -- and made it available in its MX19 (buster) test repo.
I installed it to MX21 and have yad 7.3 now running fine on such bullseye-based system
Last edited by ceeslans (2022-05-30 07:55:12)
Offline
One nice day on 30th or 31st February in a year when the grapes start to grow on willows.
Who knows? You posted bullsye having 0.40.0-1, bookworm/sid has 0.40.0-1+b1 so there's been at least *some* activity.. might have been an NMU though.
ceeslans wrote:MX is one of the very few debian-based distros that packaged yad v/7.3-0.1 from github -- and made it available in its MX19 (buster) test repo.
I installed it to MX21 and have yad 7.3 now running fine on such bullseye-based systemI fetch from github and build from source.
As could quite a few here, I don't think Bunsen has the amount of free Dev time it'd take for the approach MX took though.. you start with one package, then another feels justified & pretty soon you're maintaining a huge repo & spending all your time tracking & updating packages the main Debian repos are behind with.
Sort of thing you'd only take on if you need some feature the Debian version lacks to make the distro work properly.
Last edited by Bearded_Blunder (2022-05-30 21:13:57)
Blessed is he who expecteth nothing, for he shall not be disappointed...
If there's an obscure or silly way to break it, but you don't know what.. Just ask me
Offline