The radio stations are in a separate file, and should be in the same folder.
Otherwise, it can be this line in the script:
Code: Select all
export pmrp_stations="stations"
Code: Select all
export pmrp_stations="stations"
Code: Select all
yad --form --width=320 --height=240 --borders=5 --fixed --center \
--window-icon="system-software-install" --title="About ArchLinux Packages Viewer" \
--image="system-software-install" --image-on-top \
--text="<span font_size='medium' font_weight='bold'>View Lists of Installed Packages</span>\n\
These are packages from all enabled \nrepositories except for base and base-devel \nones. Also, you\'ll find packages that \nare locally installed such as AUR packages." \
--buttons-layout="center" \
--button=$"Κλείσιμο!window-close!Κλείνει το πα
Code: Select all
yad --form --width=320 --height=240 --borders=5 --fixed --center \
--window-icon="system-software-install" --title="About ArchLinux Packages Viewer" \
--image="system-software-install" --image-on-top \
--text="<span font_size='medium' font_weight='bold'>View Lists of Installed Packages</span>\n\
These are packages from all enabled \nrepositories except for base and base-devel \nones. Also, you\'ll find packages that \nare locally installed such as AUR packages." \
--buttons-layout="center" \
--button=$"Κλείσιμο!window-close!Κλείνει το πα
I'm running YAD 0.39.0 (GTK+ 3.22.18)smokey01 wrote:What version of Yad are you using? yad --version
Code: Select all
yad --form --width="350" --height="130" --borders=5 --center --window-icon="system-software-install" --title="About ArchLinux Packages Viewer" --image="system-software-install" --image-on-top --text="<span font_size='medium' font_weight='bold'>View Lists of Installed Packages</span>\nThese are packages from all enabled repositories except for base and base-devel ones. Also, you\'ll find packages that are locally installed such as AUR packages." --buttons-layout="center" --button='Κλείσιμο!window-close!Κλείνει το πα
Code: Select all
isitTheBlank=$(sed 's/[[:blank:]]*/·/g' <<<$"These are packages from all enabled repositories, except for base and base-devel ones. Also, you\'ll find packages that are locally installed, such as AUR packages.")
yad --form --width="350" --height="130" --borders=5 --center --window-icon="system-software-install" --title="About ArchLinux Packages Viewer" --image="system-software-install" --image-on-top --text="<span font_size='medium' font_weight='bold'>View Lists of Installed Packages</span>\n${isitTheBlank}" --buttons-layout="center" --button='Κλείσιμο!window-close!Κλείνει το πα
Code: Select all
PATTERN='s/^.*Address: ([0-9A-Z:]*)/\n\1/p
s/^.*Quality=([^ ]*).*Signal level=(.*)/\1 \2/p
s/^.*key:([onf]*)/~\1~/p
s/^.*ESSID://p'
mkfifo /tmp/pipe
exec 4<>/tmp/pipe
while true; do echo "`iwlist wlan0 scan | sed -rn "$PATTERN" | tac`" >&4; sleep 5; done &
yad --list --item-separator=';' --columns=5 --column=wlan0 --column=security --column=signal --column=mac --column=save:CHK <&4 &
Code: Select all
yad --columns=4
Code: Select all
#extract leftmost 15-items
awk -v RS="[|\n]" 'NR<=15' <<<"$file112" >Playlist2.play
Code: Select all
mkfifo -m 755 /tmp/PIPE9 2>/dev/null
exec 9<> /tmp/PIPE9
function scan (){
PATTERN='
s/^.*ESSID://p'
MENU=`iwlist wlan2 scan | sed -rn "$PATTERN" | tac | tr '\n' '|'`
list=`echo $MENU >/tmp/scan`
echo "menu:$MENU" >&9 &
}
export -f scan
yad --notification --icon=/usr/share/pixmaps/wireless.png --listen --text="Scanner" --command="geany /tmp/scan" <&9 &
while true
do
bash -c scan
sleep 4
done
Code: Select all
!bash -c connect1!/usr/share/pixmaps/wireless.png|
"AP1"|bash -c connect1|/usr/share/pixmaps/wireless.png|"AP2"!bash -c connect2!/usr/share/pixmaps/wireless.png|
Code: Select all
# yad --columns=2 --button=gtk-ok --button=gtk-cancel --button=gtk-yes --button=gtk-no &
Code: Select all
# yad --columns=2 --no-buttons --form --field=gtk-ok:FBTN '' --field=gtk-cancel:FBTN '' --field=gtk-yes:FBTN '' --field=gtk-no:FBTN '' &
This is an example that opens a text-info dialog when you click the item in the notification dialog's popup menu.stemsee wrote:Here is an idea I would like to get working.This uses yad --notification --listen to change menu items. In this usage the menu items are the APs found from iwlist scan. The APs are one per line, "AP1"|"AP2"|"AP3" how to interpolateCode: Select all
mkfifo -m 755 /tmp/PIPE9 2>/dev/null exec 9<> /tmp/PIPE9 function scan (){ PATTERN=' s/^.*ESSID://p' MENU=`iwlist wlan2 scan | sed -rn "$PATTERN" | tac | tr '\n' '|'` list=`echo $MENU >/tmp/scan` echo "menu:$MENU" >&9 & } export -f scan yad --notification --icon=/usr/share/pixmaps/wireless.png --listen --text="Scanner" --command="geany /tmp/scan" <&9 & while true do bash -c scan sleep 4 done
The problems I need to help to solve are 1) only scan on click.Code: Select all
!bash -c connect1!/usr/share/pixmaps/wireless.png| "AP1"|bash -c connect1|/usr/share/pixmaps/wireless.png|"AP2"!bash -c connect2!/usr/share/pixmaps/wireless.png|
2) click on menu item to select AP to connect with
3) show an icon next to each AP entry
Code: Select all
#!/bin/bash
mkfifo -m 755 /tmp/PIPE9 2>/dev/null
trap "rm -f /tmp/PIPE9" EXIT
exec 9<> /tmp/PIPE9
function scan (){
PATTERN='
s/^.*ESSID://p'
iwlist wlan2 scan | sed -rn "$PATTERN" | tac >/tmp/scan
MENU="$(while read -r line ;do
printf "%s" "Connect $line!bash -c "yad --text-info --width=400 --height=300 <<<$(echo $line)"!/usr/share/pixmaps/wireless.png|"
done < /tmp/scan)"
echo "icon:/usr/share/pixmaps/wireless.png" >/tmp/PIPE9
echo "tooltip:Tooltip" >/tmp/PIPE9
echo "menu:Refresh!bash -c scan!gtk-refresh|About!bash -c 'yad --about'!gtk-about||$MENU|Quit!quit!gtk-quit" >/tmp/PIPE9
}
export -f scan
yad --notification --listen --text="Scanner" --command="geany /tmp/scan" <&9 & NOTIF_ICON=$!
sleep 1
bash -c scan
wait $NOTIF_ICON
This is fantastic magic!misko_2083 wrote: This is an example that opens a text-info dialog when you click the item in the notification dialog's popup menu.
Code: Select all
#!/bin/sh
#
depsfn () { # check dependencies
dhclu=`busybox which udhcpc`
dhcld=`busybox which dhcpcd`
if [[ ! -z "${dhclu}" ]]; then
dhl1="udhcpc -A 8 -p /var/run/udhcpc.pid -s /usr/share/udhcpc/default.script -i"
dhl2="/usr/share/udhcpc/default.script deconfig"
dhl3="udhcpc"
elif [[ -z "${dhclu}" ]]; then
dhl1="dhcpcd -z"
dhl2="dhcpcd -k"
dhl3="dhcpcd"
elif [[ -z "${dhclu}" && -z "${dhcld}" ]]; then
zenity --info --text "$dhclu and $dhcld not found"
echo "$dhclu and $dhcld not found"
fi
export dhl1
export dhl2
export dhl3
}
depsfn
interfacefn () {
for wit in `ls /sys/class/net`
do
case $wit in
wl*) int=${wit};;
eth0|eth2|eth4|eth6|enp2s0f2) eth=${wit};;
eth1|eth3|eth5|eth7) eths=${wit};;
enp0s20u3|usb0|usb1) usb0=${wit};;
esac
done
}
interfacefn
if [[ "$1" = eth0-u ]]; then
ifconfig ${eth} up
${dhl1} ${eth}
exit
fi
if [[ "$1" = eth0-d ]]; then
ifconfig ${eth} down
${dhl2} ${eth}
exit
fi
if [[ "$1" = usb0-u ]]; then
ifconfig ${usb0} up
${dhl1} ${usb0}
exit
fi
if [[ "$1" = usb0-d ]]; then
ifconfig ${usb0} down
${dhl2} ${usb0}
exit
fi
mkfifo -m 755 /tmp/PIPE9 2>/dev/null
exec 9<> /tmp/PIPE9
if [[ -z "$int" ]]; then
int=`ls /sys/class/net/ | grep -v lo | grep -v eth | grep -v usb | head -1`
fi
export int
ifconfig $int up
touch /tmp/ap
function cleanfinish (){
rm -f /tmp/PIPE9
rm -f /tmp/netsel
rm -f /tmp/scan
rm -f /tmp/scan2
rm -f /tmp/n
ifconfig $int down
"$dhl2" $int
}
trap cleanfinish EXIT
function connectfn (){
details=$(yad --form --columns=2 --field="Password:H" -entry "" --field="ID" -entry "")
password=`echo $details | cut -f1 -d'|'`
id=`echo $details | cut -f2 -d'|'`
while read line
do
ssid="$line"
done < /tmp/ap
if [[ ! -z "$id" && ! -z "$password" ]]; then
echo "ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid='$ssid'
identity='$id'
password='$password'
key_mgmt=WPA-EAP
eap=PEAP
#ca_cert='$HOME/.wifi-connect/ca.pem'
#phase1='peaplabel=0'
phase2='auth=MSCHAPV2'
}
" | tr "'" '"' > /tmp/netsel
elif [[ ! -z "$password" && -z "$id" ]]; then
wpa_passphrase "$ssid" "$password" > /tmp/netsel
elif [[ -z "$password" && -z "$id" ]]; then
echo "ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1
network={
ssid='$ssid'
#bssid=$address
key_mgmt=NONE
}
" | tr "'" '"' > /tmp/netsel
fi
CURRENTIPS=$(ip addr show | grep $int | grep inet | awk '{print $2}')
ifconfig $int down
for I in ${CURRENTIPS}; do ip addr del $I dev ${int}; done 2> /dev/null
ip route flush dev $int 2> /dev/null
killall -9 $dhl3 2> /dev/null
killall -9 wpa_supplicant 2> /dev/null
rm -f /var/db/$dhl3-${int}.lease 2> /dev/null
rm -f /var/lib/$dhl3/$dhl3-${int}.lease 2> /dev/null
rm -f /var/run/wpa_supplicant/$int 2> /dev/null
ifconfig $int up 2> /dev/null
wpa_supplicant -Dwext -i$int -c/tmp/netsel -B
$dhl1 $int
}
export -f connectfn
function inotify (){
while inotifywait -e close_write /tmp/ap
do
bash -c connectfn
sleep 10
done
}
export -f inotify
bash -c inotify &
function scan (){
PATTERN='s/^.*key:([onf]*)/~\1~/p
s/^.*ESSID://p'
iwlist $int scan | sed -rn "$PATTERN" >/tmp/scan2
cat /tmp/scan2 | grep -v [onf] > /tmp/scan
cat /tmp/scan2 | grep -e'~on~' -e '~off~' > /tmp/encryption
MENU="$(while read -r line ;do
printf "%s" "$int ${line}!bash -c "echo "$line" > /tmp/ap"!/usr/share/pixmaps/wireless.png|"
done < /tmp/scan)"
sixth="Ethernet connect!netmenu eth0-u!/usr/share/icons/oxygen/22x22/devices/network-wired.png|"
seventh="Ethernet disconnect!netmenu eth0-d!/usr/share/icons/oxygen/22x22/devices/network-wiredx.png|"
tenth="Connect mobile!netmenu usb0-u!/usr/share/icons/oxygen/22x22/devices/phone.png|"
eleventh="Disconnect mobile!netmenu usb0-d!/usr/share/icons/oxygen/22x22/devices/phonex.png|"
echo "icon:/usr/share/pixmaps/wireless.png" >/tmp/PIPE9
echo "tooltip:$int" >/tmp/PIPE9
echo "menu:Refresh!bash -c scan!gtk-refresh|About!bash -c 'yad --about'!gtk-about||$MENU|$sixth$seventh$tenth$eleventh||Quit!quit!gtk-quit" >/tmp/PIPE9
}
export -f scan
yad --notification --listen --text="Scanner" --command="geany /tmp/encryption" <&9 & NOTIF_ICON=$!
sleep 1
bash -c scan
wait $NOTIF_ICON
Code: Select all
MENU="$(while read -r line ;do
printf %s "${line}!bash -c \"echo "$line" > /tmp/ap\"!/usr/share/pixmaps/wireless.png|"
done < /tmp/text)"
Code: Select all
MENU="$(while read -r line ;do
printf %s "${line}!bash -c \"$(echo "$line" > /tmp/ap)\"!/usr/share/pixmaps/wireless.png|"
done < /tmp/text)"
The problems are with escaping quotes and spaces.stemsee wrote:The MENU portion of this code preserves spaces for the yad menu, but when printed to the /tmp/ap file the space within quoted AP name disappears! i have tried variations of echo, printf, tee, redirections, bracketing, quoting ... but nothing I have tried works. There is one way that prints the desired format "My Way Cafe" but it does not print the selected item, just the first one slips through. Here is the suspect code that loses the spacethis is the variation that prints a line, not the selected line, in correct formatCode: Select all
MENU="$(while read -r line ;do printf %s "${line}!bash -c "echo "$line" > /tmp/ap"!/usr/share/pixmaps/wireless.png|" done < /tmp/text)"
/tmp/ap is being watched by inotifywait -e close_write which triggers 'bash -c connectfn'. It connects after first scan without selecting AP, because one slips through! I know this is more of a coding issue than a yad issue, although it is in a yad menu, but any further help appreciated.Code: Select all
MENU="$(while read -r line ;do printf %s "${line}!bash -c "$(echo "$line" > /tmp/ap)"!/usr/share/pixmaps/wireless.png|" done < /tmp/text)"
Code: Select all
$ echo -e "MC\ cm"\ ~on~
Code: Select all
MENU="$(while read -r line ;do
WIFI="$(printf %q "$line")"
printf "%s" "${line}!bash -c 'echo -e ${WIFI} > /tmp/ap'!/usr/share/pixmaps/wireless.png|"
done < /tmp/text)"
Code: Select all
MENU="$(while read -r line ;do
WIFI="$(printf %q "$line")"
echo -ne "${line}!bash -c 'echo -e ${WIFI} > /tmp/ap'!/usr/share/pixmaps/wireless.png|"
done < /tmp/text)"
Code: Select all
cat file | grep "something" > file2
Code: Select all
grep "something" file > file2