YAD - Tips
Howabout using yad --file-selector (or MMview) as a wifi network connection display manager? Perform a scan and use data for each ssid to generate a .jpg (using 01mickos wallpaper generator) or .svg (maybe easier) to populate a directory in /tmp or on disk. This should be so easy to code and unique in the world of wifi connection tools! Are you up for this Fred? Misky? Mochi?
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Fair enough ... The main thing is the algorithm to convert/imbed selected scan data into the image, and have that algorithm function in reverse to extract scan data from the image back into usable text strings.
Any file selector/browser then becomes a Wifi/network connection app.
EDIT: completed ... a basic function
Any file selector/browser then becomes a Wifi/network connection app.
EDIT: completed ... a basic function
- Attachments
-
- 2018-06-10-170413_729x405_scrot.png
- (89.51 KiB) Downloaded 637 times
With rox and yad --file-selection --add-preview
- Attachments
-
- xscreenshot-20180611T113639.png
- (79.1 KiB) Downloaded 163 times
does anyone know why I am not getting any exit codes from this
It looks like this
Code: Select all
yad --image=$track/images/$line.svg --window-icon="$pics/wifi24.png" --geometry="$(cat $camino/geometry/$WINDOWTITLE)" --title="$WINDOWTITLE" --text "Yes to keep this connection\nNo try next open AP/nCancel to stop and exit!" --button=gtk-yes:0 --button=gtk-no:2 --button=gtk-cancel:1 --timeout-indicator=top --timeout=8
- Attachments
-
- 2018-06-30-110313_577x309_scrot.png
- (45.9 KiB) Downloaded 530 times
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
Don't know why it wouldn't work. How do you read the exit codes?stemsee wrote:does anyone know why I am not getting any exit codes from this
Works here as expected for this stripped down code:
Code: Select all
yad --button=gtk-yes:0 --button=gtk-no:2 --button=gtk-cancel:1 --timeout-indicator=top --timeout=8
echo $?
Thanks MochiMoppel
Firstly I associated the yad statemnet with a variable goOn=`yad ...`
and then ret=$?, followed by a case statement. When I first implemented these they seemed to work, but now not. i wonder if the extra variables confuse yad (ie yad has a bug).
Is there a constraint on how many functions bash can address? Or how many functions and variables a script may produce?
Firstly I associated the yad statemnet with a variable goOn=`yad ...`
and then ret=$?, followed by a case statement. When I first implemented these they seemed to work, but now not. i wonder if the extra variables confuse yad (ie yad has a bug).
Is there a constraint on how many functions bash can address? Or how many functions and variables a script may produce?
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
When exactly is "then"? If you add ret=$? after your yad statement, still within the command substitution (= the expression delimited by backtics), the value of ret will be lost as soon as you finish your assignment to variable goOn.stemsee wrote:Firstly I associated the yad statemnet with a variable goOn=`yad ...`
and then ret=$?, followed by a case statement.
If you add ret=$? after the goOn assignment, the value will always be 0.
You need to print the value of $ret to stdout within the command substitution:.
Code: Select all
goOn=$(yad --button=gtk-yes:0 --button=gtk-no:2 --button=gtk-cancel:1 --timeout-indicator=top --timeout=8; ret=$? ;echo $ret)
case $goOn in
0) echo you pressed yes ;;
1) echo you pressed cancel ;;
2) echo you pressed no ;;
*) echo you did not press a button;;
esac
- MochiMoppel
- Posts: 2084
- Joined: Wed 26 Jan 2011, 09:06
- Location: Japan
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
It's one of those internet memes. That is how Trump spells "coverage" on twitter.stemsee wrote:Since when does coffee have a 'v' in it? 'v' must be a sugar free sweetener!
In English or other languages, the brain can see the whole word at once as long as the first and the last letters are in the right possition. Although it takes more time to read such text.
As you can see, by the Mochi's word play, the brain can easily be tricked.
-----------------------------------------------------------------------
By the way, how does timeout indicator works?
If the timeout is set to 8 seconds, the progress bar can reach 9 or even 10 occasionally.
Code: Select all
#!/bin/bash
i=1
while true
do
echo "1:#$(date '+%T')"
echo "2:#$(date '+%D %a')"
echo "3:#${i}"
echo "3:$(( ${i}*100 /8 ))"
i=$(($i+1))
sleep 1
done | yad --multi-progress \
--bar="Time":NORM \
--bar="Date":NORM \
--bar="Countdown":NORM \
--window-icon="clock" \
--image="clock" \
--borders="20" \
--no-buttons \
--timeout-indicator=top \
--timeout=8
With both --watch-bar=3 and --auto-close included, the dialog will close before the timeout is reached.
Perhaps, yad applies a custom version of the the general theory of relativity. Time is relative to the length of the Gtk+ bar?
I have a list of network blocks, each assigned to variables in a text document, I can display the blocks with , and also display a selector with
However I cannot get the selected eg, 'Ag', even when written to a file as to expand as a variable, it remains treated as an object.
when I import the netblocks file with 26 blocks as variables as follows
They can be piped from a terminal which has imported the variables from the file, with
but not from the code which is
So what am I doing wrong?
Code: Select all
. $HOME/.wifi-connect/netblocks
echo $A{a..z}
Code: Select all
yad --plug=$$ --form --field="Selector:CBE" "`echo A{a..z}`"
Code: Select all
$Ag
when I import the netblocks file with 26 blocks as variables as follows
Code: Select all
# Only WPA-PSK is used. Any valid cipher combination is accepted.
Ac='$sect
proto=WPA
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40'
# WPA-Personal(PSK) with TKIP and enforcement for frequent PTK rekeying
Ad='$sect
proto=WPA
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
wpa_ptk_rekey=600'
# Only WPA-EAP is used. Both CCMP and TKIP is accepted. An AP that used WEP104
# or WEP40 as the group cipher will not be accepted.
Ae='ssid=$ssid
proto=RSN
key_mgmt=WPA-EAP
pairwise=CCMP TKIP
group=CCMP TKIP
eap=TLS
identity="$id"
ca_cert="/etc/cert/ca.pem"
client_cert="/etc/cert/user.pem"
private_key="/etc/cert/user.prv"
private_key_passwd="$password"'
Code: Select all
echo "$Ag" >/tmp/PIPE
Code: Select all
rm -f /tmp/PIPE
mkfifo -m 755 /tmp/PIPE
exec 4<> /tmp/PIPE
touch /tmp/net
. $HOME/.wifi-connect/netblocks
while read line
do
. $HOME/.wifi-connect/netblocks
echo "`cat /tmp/net`" >/tmp/PIPE
done &
yad --plug=$$ --tabnum=1 --list --columns=1 --item-separator=" " --column="NetBLocks:CBE" `echo A{a..z}` --select-action='bash -c "printf %s $1 | sed 's/^/\$/g' >/tmp/net"' &
yad --plug=$$ --tabnum=2 --text-info <&4 &
yad --window-icon=/usr/share/pixmaps/refdnd.png --width=400 --height=400 \
--no-buttons --on-top --paned --splitter=100 --key=$$ --title="NetBlocks" --tab="Preview" --tab="Selector" --orient=hori &
- Attachments
-
- 2018-07-06-123128_1218x308_scrot.png
- ow it should look
- (85.11 KiB) Downloaded 168 times
-
- 2018-07-06-122408_402x433_scrot.png
- (24.29 KiB) Downloaded 963 times
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
You learned the secret from Doctor Who.stemsee wrote:Perhaps, yad applies a custom version of the the general theory of relativity. Time is relative to the length of the Gtk+ bar?
So, that is why I look so young!
This is for bash 4.1 and above;stemsee wrote:I have a list of network blocks, each assigned to variables in a text document, I can display the blocks with
.... Long text.....
They can be piped from a terminal which has imported the variables from the file, withbut not from the code which isCode: Select all
echo "$Ag" >/tmp/PIPE
So what am I doing wrong?Code: Select all
rm -f /tmp/PIPE mkfifo -m 755 /tmp/PIPE exec 4<> /tmp/PIPE touch /tmp/net . $HOME/.wifi-connect/netblocks while read line do . $HOME/.wifi-connect/netblocks echo "`cat /tmp/net`" >/tmp/PIPE done & yad --plug=$$ --tabnum=1 --list --columns=1 --item-separator=" " --column="NetBLocks:CBE" `echo A{a..z}` --select-action='bash -c "printf %s $1 | sed 's/^/\$/g' >/tmp/net"' & yad --plug=$$ --tabnum=2 --text-info <&4 & yad --window-icon=/usr/share/pixmaps/refdnd.png --width=400 --height=400 \ --no-buttons --on-top --paned --splitter=100 --key=$$ --title="NetBlocks" --tab="Preview" --tab="Selector" --orient=hori &
Code: Select all
#!/bin/bash
rm -f /tmp/PIPE /tmp/net
mkfifo -m 755 /tmp/PIPE
exec 4<> /tmp/PIPE
mkfifo -m 755 /tmp/net
exec 5<> /tmp/net
. $HOME/.wifi-connect/netblocks
while read line || [ -n "$line" ]
do
# clear text-info
echo -e "\f" >/tmp/PIPE
echo "${!line}" >/tmp/PIPE
# For bash lower than 4.1 you can use case
# case $line in ...
done <&5 & MON_PID=$!
yad --plug=$$ --tabnum=1 --list --columns=1 --item-separator=" " --column="NetBLocks:CBE" `echo A{a..z}` \
--select-action='bash -c "foo=$(printf %s $1); echo "$foo" >/tmp/net"' &
yad --plug=$$ --tabnum=2 --text-info <&4 &
yad --window-icon=/usr/share/pixmaps/refdnd.png --width=400 --height=400 \
--no-buttons --on-top --paned --splitter=100 --key=$$ --title="NetBlocks" --tab="Preview" --tab="Selector" --orient=hori
# close file descriptoprs
4<&-
5<&-
kill -9 $MON_PID
Yad colour columns
I think someone shared this before, but I just (re) discovered it!
I think someone shared this before, but I just (re) discovered it!
Code: Select all
yad --list --column="Column Name" --column="@fore@" "red text" "#ff0000" "black text" "#000000" "yellow text" "#ffff00" "green text" "#90EE90"
yad --list --column="Column Name" --column="@back@" "red" "#ff0000" "yell" "#ffff00" "green" "#90EE90"
- Attachments
-
- 2018-07-17-113511_267x237_scrot.png
- (16.05 KiB) Downloaded 776 times
-
- 2018-07-17-113441_285x238_scrot.png
- (13.69 KiB) Downloaded 776 times