Page 22 of 42

Posted: Fri 08 Jun 2018, 09:11
by stemsee
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?

Posted: Sat 09 Jun 2018, 02:47
by MochiMoppel
stemsee wrote:Are you up for this Fred? Misky? Mochi?
Not me. I know nothing about wifi.

Posted: Sun 10 Jun 2018, 09:22
by stemsee
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

Posted: Mon 11 Jun 2018, 10:39
by stemsee
With rox and yad --file-selection --add-preview

Posted: Sat 30 Jun 2018, 10:04
by stemsee
does anyone know why I am not getting any exit codes from 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
It looks like this

Posted: Sat 30 Jun 2018, 10:44
by MochiMoppel
stemsee wrote:does anyone know why I am not getting any exit codes from this
Don't know why it wouldn't work. How do you read the exit codes?
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 $?
Returns exit codes 0,2,1,70 (timeout) or 252 (Alt+F4)

Posted: Sat 30 Jun 2018, 12:13
by stemsee
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?

Posted: Sat 30 Jun 2018, 13:41
by MochiMoppel
stemsee wrote:Firstly I associated the yad statemnet with a variable goOn=`yad ...`
and then ret=$?, followed by a case statement.
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.
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
Assigning $? to ret makes little sense here. You could echo $? directly.

Posted: Sat 30 Jun 2018, 14:51
by stemsee
That explains the results I was seeing perfectly!

Ervyreihtng is wronikg fnie aiagn! I can see taht I was mnixig dnefifret mhoteds!

Tnahks McohiMpoepl

semsete

Posted: Sat 30 Jun 2018, 15:04
by MochiMoppel
Yu'reo womelec!

Posted: Sat 30 Jun 2018, 15:13
by stemsee
MochiMoppel wrote:Yu'reo womelec!
Ha ha! The linguistic code is that the first and last letter of each word must be as the usual spelling but internal letters can be in any order! Native like level English reader's brains will get the correct reading!

smeetse

Posted: Sun 01 Jul 2018, 00:00
by MochiMoppel
I figured that a clever English brain would get the meaning with only the first letters in its usual place.
Of course the brain of a genius would need no specific order at all.
Covfefe!

Posted: Sun 01 Jul 2018, 04:57
by stemsee
Since when does coffee have a 'v' in it? 'v' must be a sugar free sweetener!

Posted: Tue 03 Jul 2018, 02:26
by misko_2083
stemsee wrote:Since when does coffee have a 'v' in it? 'v' must be a sugar free sweetener!
It's one of those internet memes. That is how Trump spells "coverage" on twitter. :D

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.
Image

-----------------------------------------------------------------------

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. :roll:

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? :lol:

Posted: Wed 04 Jul 2018, 08:28
by stemsee
misko_2083 wrote: It's one of those internet memes. That is how Trump spells "coverage" on twitter. :D
Something I would never have known!
Perhaps, yad applies a custom version of the the general theory of relativity. Time is relative to the length of the Gtk+ bar? :lol:
So, that is why I look so young!

Posted: Fri 06 Jul 2018, 14:02
by stemsee
I have a list of network blocks, each assigned to variables in a text document, I can display the blocks with

Code: Select all

. $HOME/.wifi-connect/netblocks
echo $A{a..z}
, and also display a selector with

Code: Select all

yad --plug=$$ --form --field="Selector:CBE" "`echo A{a..z}`"
However I cannot get the selected eg, 'Ag', even when written to a file as

Code: Select all

$Ag
to expand as a variable, it remains treated as an object.

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"'
They can be piped from a terminal which has imported the variables from the file, with

Code: Select all

echo "$Ag" >/tmp/PIPE
but not from the code which is

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  &
So what am I doing wrong?

Posted: Sat 07 Jul 2018, 14:59
by misko_2083
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!
:lol: You learned the secret from Doctor Who.
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, with

Code: Select all

echo "$Ag" >/tmp/PIPE
but not from the code which is

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  &
So what am I doing wrong?
This is for bash 4.1 and above;

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

Posted: Sun 08 Jul 2018, 16:39
by stemsee
Thanks misko

It works perfectly. At first I copied from the webpage and pasted into geany etc it didn't work until I reformatted it.

I see that using a pipe not a file is essential. I thought I was quite close!

thanks again
stemsee

Posted: Sun 08 Jul 2018, 20:58
by misko_2083


Posted: Tue 17 Jul 2018, 10:39
by stemsee
Yad colour columns
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"