YAD - Tips

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
stemsee

#401 Post by stemsee »

@miskY

Beautiful artistic 'painting'. Which program did you use to achieve that? I have a friend called beverly greene who also has an account on deviantart.

How about a yad paint!?!

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#402 Post by fredx181 »

Hi Mike Walsh,
Unable to parse option --close on-unfocus
I see a whitespace where it should be a dash, this works maybe ?

Code: Select all

--close-on-unfocus
Fred

User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#403 Post by Mike Walsh »

Hi, Fred.

Well spotted, mate. Actually, I didn't perform a copy/paste for that one; I simply typed it in from memory.....and forgot one of the '-' symbols.

*smacked wrist* Bad Mike..! :lol:

But that definitely is a recent addition; it wasn't working in Precise 571, where I've been using v36.0 for some little while.....it simply doesn't recognise it.


Mike. :wink:

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#404 Post by fredx181 »

Mike Walsh wrote:Actually, I didn't perform a copy/paste for that one; I simply typed it in from memory.....and forgot one of the '-' symbols.
Ah, I see,
I did a little digging and I think the --close-on-unfocus option was added from 0.37 on.

Fred

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#405 Post by misko_2083 »

stemsee wrote:@miskY

Beautiful artistic 'painting'. Which program did you use to achieve that? I have a friend called beverly greene who also has an account on deviantart.

How about a yad paint!?!
I use Gimp mostly.
Making a paint application with yad is impossible.
Maybe some basic image manipulation like resizing and rotating or color efects can be scripted.

Those are more usefull with the file managers via context (right-click) menu.
https://ubuntu-mate.community/t/rotate- ... -menu/8762

stemsee

#406 Post by stemsee »

Well I know it is impossible ... but this is yad tips, afterall!
BTW
could you explain how NOTIF_ICON=$?
wait $NOTIF_ICON
functions and where else it can be used for example yad --list &

cheers
stemsee

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#407 Post by misko_2083 »

stemsee wrote:Well I know it is impossible ... but this is yad tips, afterall!
BTW
could you explain how NOTIF_ICON=$?
wait $NOTIF_ICON
functions and where else it can be used for example yad --list &

cheers
stemsee
Yes certainly.
you probably ment these lines from the previous script. I needed to set the icon only after the notification icon appears.

Code: Select all

# Calls yad notification icon that listens on stdandard input.
# the process starts in the background & so the script can continue
# File descriptor 3 is redirected to standard input <&3
# notifpid=$! - The process id is stored in a variable notifpid
yad --notification --command="bash -c 'YAD_AUDIO_audio'" \
 --listen <&3 & notifpid=$!
# Script continues...

# Needed to set the notification icon, that is only possible
# when the notification finish loading
# xdotool search --pid "$notifpid" - finds the window id based on the process id
# xdotool getwindowname $window_id - returns the window name
# Untill there is a window name do --> sleep 1
until xdotool getwindowname $(xdotool search --pid "$notifpid" 2>/dev/null | tail -1) &>/dev/null; do
        # sleep until the window opens
        sleep 1       
done

# Window is ready, time to set the intitial volume icon
# We call the function "get_volume" that returns CURVOL variable
get_volume
# Redirects stdout to file descriptor 3
set_notification_icon $(printf "%3d" "$CURVOL") >&3

# Now when that is done, we can wait for the process with the id $notifpid to finish
wait $notifpid
# wait also returns the exit status of the yad notification
# We can check the exit status
echo $?

#Script continues...
This can be used with the lists also, but can't remember a useful example where that was really necessary except in the case of notification icon.
Maybe if a window would have to be resized or moved or something similar. Not a great example but nothing else crossed my mind.:)

Code: Select all

#!/bin/bash
# Temp file
export temp_list=$(mktemp -u --tmpdir temp.XXXXXXXX)

# create a named pipe
mkfifo "$temp_list"

#Trap that removes named pipe on exit
trap "rm -f $temp_list" EXIT

# Opens named pipe for reading and writing on file descriptor 3
exec 3<> $temp_list

yad --list --column="1" --listen --button "exit 1":1 --button "exit 50":50 --button "exit 0":0  <&3 & list_pid=$!

#We can use just sleep instead of calling xdotool and hope it opens in 5 seconds :)
sleep 5

#populate the list
echo "1" >&3
echo -e "2\n3\n4" >&3

# get win id
WIN_ID=$(xdotool search --pid "$list_pid" 2>/dev/null | tail -1)

#Resize the window
xdotool windowsize $WIN_ID 800 600

wait $list_pid
exit_status=$?

   yad --width=500 --height=300 --text="exit status is $exit_status"

# close file descriptor 3
exec 3>&-

exit 0

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#408 Post by fredx181 »

stemsee wrote:How about a yad paint!?!
OK, pity, not possible, but maybe then a yad full Office-Suite !?? :lol:

Thanks misko for the valuable info !

Fred

wiak
Posts: 2040
Joined: Tue 11 Dec 2007, 05:12
Location: not Bulgaria

#409 Post by wiak »

fredx181 wrote:
stemsee wrote:How about a yad paint!?!
OK, pity, not possible, but maybe then a yad full Office-Suite !?? :lol:

Thanks misko for the valuable info !

Fred
Okay, not yad, but it is absolutely possible to do both with IUPLUA actually. At the moment, in the examples there is a notepad and also a Color Picker:

https://webserver2.tecgraf.puc-rio.br/i ... rial4.html

http://www.murga-linux.com/puppy/viewto ... 612#987612

https://webserver2.tecgraf.puc-rio.br/i ... rowser.lua

https://webserver2.tecgraf.puc-rio.br/i ... tcolor.lua

Or for something else Lua-related:

http://compasstech.com.au/TNS_Authoring ... rials.html

http://compasstech.com.au/TNS_Authoring ... _tut7.html

Anyway... back to on-topic yad...

wiak

stemsee

#410 Post by stemsee »

How to re-open a yad gui in the same last location? In other words how to export yad gui location to a variable/file and re-open same gui using that geometry? Not hard-coded but according to last moved to location?

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#411 Post by Geoffrey »

stemsee wrote:How to re-open a yad gui in the same last location? In other words how to export yad gui location to a variable/file and re-open same gui using that geometry? Not hard-coded but according to last moved to location?
stemsee, I used this to save window position info for gtkdialog, I haven't tried to do it with yad though.

Code: Select all

save_geometry (){
   XWININFO=`xwininfo -stats -name 'WINDOW'' ''NAME'`
   X1=`echo "$XWININFO" | grep 'Absolute upper-left X' | awk '{print $4}'`
   Y1=`echo "$XWININFO" | grep 'Absolute upper-left Y' | awk '{print $4}'`
   X2=`echo "$XWININFO" | grep 'Relative upper-left X' | awk '{print $4}'`
   Y2=`echo "$XWININFO" | grep 'Relative upper-left Y' | awk '{print $4}'`
   X=$(($X1-$X2))
   Y=$(($Y1-$Y2))
   echo "export X=$X" > ./geometry
   echo "export Y=$Y" >> ./geometry
   chmod 700 ./geometry
}

export -f save_geometry
[ -f ./geometry ] && ./geometry
[b]Carolina:[/b] [url=http://smokey01.com/carolina/pages/recent-repo.html]Recent Repository Additions[/url]
[img]https://dl.dropboxusercontent.com/s/ahfade8q4def1lq/signbot.gif[/img]

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#412 Post by misko_2083 »

stemsee wrote:How to re-open a yad gui in the same last location? In other words how to export yad gui location to a variable/file and re-open same gui using that geometry? Not hard-coded but according to last moved to location?
Here you go buddy:
just change this line DimFile="/home/misko/Desktop/yadXYWH"
xev monitors the window's absolute left X and y and width and height.
On destroy event we get those values. xev outputs window id in base seven and refuses to exit that easy. That's why it needs this kill $XevPID 2> /dev/null. :)

Code: Select all

#!/bin/bash

DimFile="/home/misko/Desktop/yadXYWH"

[[ ! -f "$DimFile" ]] && >"${DimFile}"

grep -q '[^[:space:]]' < "$DimFile" &&  readarray -t START <"$DimFile"

if [[ ${START[@]} == "" ]]; then
   # In case there are no dimensions
   yad --text="stemsee office - first edition" &
   yid="$!"
else
   # Run yad
   yad --text="stemsee office - first edition" --posx=${START[0]} --posy=${START[1]} --width=${START[2]} --height=${START[3]} &
   yid="$!"
fi


# until there is a window name do -> sleep
until xdotool getwindowname "$(xdotool search --pid $yid | tail -1 2>/dev/null)" &>/dev/null; do
        # sleep until the window opens
        sleep .1
done

#Decimal
WindowID="$(xdotool search --pid $yid | tail -1)"

#Hexadecimal
WindowIDHex=$(printf "0x%08x" ${WindowID})

#Base seven
WindowBSeven=$(printf "0x%07x" ${WindowID})

#Get starting position and size: x, y, width, height
 set $(xwininfo -id $WindowIDHex \
 |  sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/\1/p" \
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/\1/p" \
           -e "s/^ \+Width: \+\([0-9]\+\).*/\1/p" \
           -e "s/^ \+Height: \+\([0-9]\+\).*/\1/p")

 X="$1"
 Y="$2"
 W="$3"
 H="$4"

# This monitors the window absolute-top-left x, y, width and height for changes
# If the window is moved - this will set new pos and size
DIM=$(xev -event structure -id ${WindowIDHex} 2>/dev/null |
       while IFS=$',' read -a A;do
            if [[ "${A[0]#"${A%%[![:space:]]*}"}" =~ "event ${WindowBSeven}" && "${A[1]}${A[2]:1:1}${A[3]: -1}" =~ "window ${WindowBSeven}()" ]]; then
                  X="${A[2]//" ("/}"
                  Y="${A[3]%")"}"
                  W="${A[4]//" width "/}"
                  H="${A[5]//" height "/}"
            # On destroy event
            elif [[ "${A[0]}" =~ "DestroyNotify event" ]]; then
                  # Exports dimensions
                  echo "$X"
                  echo "$Y"
                  echo "$W"
                  echo "$H"
                  exit
            fi
             A=()
        done &)

wait $yid
EXIT_STATUS=$?

# xev dies hard
XevPID="$(ps -eo pid,cmd | grep "xev -event structure -id $WindowIDHex" | grep -v "grep" | awk '{ print $1 }')"
kill $XevPID 2> /dev/null

>"${DimFile}"

#Save dimensions
for D in "${DIM}"; do
    echo "${D}" >> "${DimFile}"
done

echo "stemsee office - exit status: $EXIT_STATUS"
exit 0
Edit: By the way, good luck with the Stemsee Office ;)

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#413 Post by MochiMoppel »

stemsee wrote:How to re-open a yad gui in the same last location? In other words how to export yad gui location to a variable/file and re-open same gui using that geometry? Not hard-coded but according to last moved to location?
OK, here is another variation, along the lines of Geoffrey's and misko's solutions.
There are many ways to get the geometry from the xwininfo command. I found that using an array is by far the fastest.
The sayonary function writes the geometry to a tmpfile and then closes the dialog with an exit code 0 (SIGUSR1). Strangely yad seems to ignore an exit command, so I had to resort to kill. Could be related to the yad behavior to keep the dialog open when a button with a non-numeric ID is pressed.

This demo should be fully functional. Unlike misko's approach (which does not work for me - I get "Can't consume 1 args" errors) the geometry is only saved when the user presses the "Close" button but not when he presses ESC or the window's X button:

Code: Select all

#!/bin/sh
function sayonara {
	XWININFO=$(xwininfo -id $YAD_XID)
	ARRAY=(${XWININFO#* X: })
	AX=${ARRAY[0]}
	AY=${ARRAY[4]}
	RX=${ARRAY[8]}
	RY=${ARRAY[12]}
	W=${ARRAY[14]}
	H=${ARRAY[16]}
	X=$((AX-RX))
	Y=$((AY-RY))
	echo "$W"x"$H"+"$X"+"$Y" > /tmp/yad_geometry
	kill -s SIGUSR1 $YAD_PID
}; export -f sayonara

yad --form --button gtk-close:"bash -c sayonara" --text ""Close" will save geometry" --geometry "$(cat /tmp/yad_geometry 2>/dev/null)"

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#414 Post by misko_2083 »

MochiMoppel wrote: The sayonary function writes the geometry to a tmpfile and then closes the dialog with an exit code 0 (SIGUSR1). Strangely yad seems to ignore an exit command, so I had to resort to kill. Could be related to the yad behavior to keep the dialog open when a button with a non-numeric ID is pressed.

This demo should be fully functional. Unlike misko's approach (which does not work for me - I get "Can't consume 1 args" errors) the geometry is only saved when the user presses the "Close" button but not when he presses ESC or the window's X button:
That's why I resorted to xev to find destroy event.
You may be experiencing buggy xdotool search behaviour.
https://github.com/jordansissel/xdotool/issues/14
Next line doesnt work with some distros
xdotool search --pid $yid
This should work.
xdotool search --pid $yid --class $class
Let's try with the window class set and redirect stderr to /dev/null just in case :D

Code: Select all

#!/bin/bash

DimFile="/home/misko/Desktop/yadXYWH"

# xdotool has a buggy behaviour when searching for pid
# https://github.com/jordansissel/xdotool/issues/14
# workaround could be to set the window class
YadClass="StemseeOffice"

[[ ! -f "$DimFile" ]] && >"${DimFile}"

grep -q '[^[:space:]]' < "$DimFile" &&  readarray -t START <"$DimFile"

if [[ ${START[@]} == "" ]]; then
   # In case there are no dimensions
   yad --class="$YadClass" --text="stemsee office - first edition" &
   yid="$!"
else
   # Run yad
   yad --class="$YadClass" --text="stemsee office - first edition" --posx=${START[0]} --posy=${START[1]} --width=${START[2]} --height=${START[3]} &
   yid="$!"
fi


# until there is a window name do -> sleep
until xdotool getwindowname "$(xdotool search --any --pid $yid --class "$YadClass" 2>/dev/null | tail -1 2>/dev/null)" &>/dev/null; do
        # sleep until the window opens
        sleep .1
done

#Decimal
WindowID="$(xdotool search --any --pid $yid --class "$YadClass" 2>/dev/null | tail -1)"

#Hexadecimal
WindowIDHex=$(printf "0x%08x" ${WindowID})

#Base seven
WindowBSeven=$(printf "0x%07x" ${WindowID})

#Get starting position and size: x, y, width, height
 set $(xwininfo -id $WindowIDHex \
 |  sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/\1/p" \
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/\1/p" \
           -e "s/^ \+Width: \+\([0-9]\+\).*/\1/p" \
           -e "s/^ \+Height: \+\([0-9]\+\).*/\1/p")

 X="$1"
 Y="$2"
 W="$3"
 H="$4"

# This monitors the window absolute-top-left x, y, width and height for changes
# If the window is moved - this will set new pos and size
DIM=$(xev -event structure -id ${WindowIDHex} 2>/dev/null |
       while IFS=$',' read -a A;do
            if [[ "${A[0]#"${A%%[![:space:]]*}"}" =~ "event ${WindowBSeven}" && "${A[1]}${A[2]:1:1}${A[3]: -1}" =~ "window ${WindowBSeven}()" ]]; then
                  X="${A[2]//" ("/}"
                  Y="${A[3]%")"}"
                  W="${A[4]//" width "/}"
                  H="${A[5]//" height "/}"
            # On destroy event
            elif [[ "${A[0]}" =~ "DestroyNotify event" ]]; then
                  # Exports dimensions
                  echo "$X"
                  echo "$Y"
                  echo "$W"
                  echo "$H"
                  exit
            fi
             A=()
        done &)

wait $yid
EXIT_STATUS=$?

# xev dies hard
XevPID="$(ps -eo pid,cmd | grep "xev -event structure -id $WindowIDHex" | grep -v "grep" | awk '{ print $1 }')"
kill $XevPID 2> /dev/null

>"${DimFile}"

#Save dimensions
for D in "${DIM}"; do
    echo "${D}" >> "${DimFile}"
done

echo "stemsee office - exit status: $EXIT_STATUS"
exit 0
Edit: Some suggest adding --any
xdotool search --any --pid "$1" --name "dummy"
I added that too.

stemsee

#415 Post by stemsee »

Thanks Geoffrey, Misko and Mochi!

I will continue testing these solutions and making adjustments to suit my needs.

stem's office is stationary!

User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#416 Post by misko_2083 »

stemsee wrote:Thanks Geoffrey, Misko and Mochi!

I will continue testing these solutions and making adjustments to suit my needs.

stem's office is stationary!
I think I got it, Mochi's way of getting the window geometry via xwininfo was perfect.

Combined with this script it also places window on the last workspace it was closed. In case you need that too.

Code: Select all

#!/bin/bash
# Temp file to store absolute position and dimensions
DimFile="/home/misko/Desktop/yadXYWH"
# Temp file to store workspace
WorkspFile="/home/misko/Desktop/yadworkspace"

YadClass="Stemsee"

[[ ! -f "$DimFile" ]] && >"${DimFile}"

grep -q '[^[:space:]]' < "$DimFile" &&  readarray -t START <"$DimFile"

# run yad
yad --class="$YadClass" --text="$(cat $DimFile)" &
yid="$!"

# xdotool has a buggy behaviour when searching for pid
# on certain distros set the dummy name or class
# in this format:
# xdotool --any --pid $yid --class="$Class"
# until there is a window name do -> sleep
until xdotool getwindowname "$(xdotool search --any --pid $yid --class "$YadClass" 2>/dev/null | tail -1 2>/dev/null)" &>/dev/null; do
        # sleep until the window opens
        sleep .1
done

#Decimal
WindowID="$(xdotool search --any --pid $yid --class "$YadClass" 2>/dev/null | tail -1)"

workspace="$(cat "${WorkspFile}" 2>/dev/null)"

if [[ ${workspace} != "" ]]; then
   # change desktop
   xdotool set_desktop "${workspace: -1}"
   
   # change desktop for window
   xdotool set_desktop_for_window $WindowID "${workspace: -1}"
fi

if [[ ${START[@]} != "" ]]; then
  xdotool windowsize --sync $WindowID ${START[2]} ${START[3]}
  xdotool windowmove --sync $WindowID ${START[0]} ${START[1]}
fi

#Hexadecimal
WindowIDHex=$(printf "0x%08x" ${WindowID})

#Base seven
WindowBSeven=$(printf "0x%07x" ${WindowID})

#Get starting position and size: x, y, width, height
# Mochi Mopel
   XWININFO=$(xwininfo -id $WindowIDHex)
   ARRAY=(${XWININFO#* X: })
   AX=${ARRAY[0]}
   AY=${ARRAY[4]}
   RX=${ARRAY[8]}
   RY=${ARRAY[12]}
   W=${ARRAY[14]}
   H=${ARRAY[16]}
   X=$((AX))
   Y=$((AY)) 

# This monitors the window absolute-top-left x, y, width and height for changes
# If the window is moved - this will get new pos and size
# On destroy event, saves X,Y, W, and H
xev -event structure -id ${WindowIDHex} 2>/dev/null |
       while IFS=$',' read -a A;do
            if [[ "${A[0]#"${A%%[![:space:]]*}"}" =~ "event ${WindowBSeven}" && "${A[1]}${A[2]:1:1}${A[3]: -1}" =~ "window ${WindowBSeven}()" ]]; then
                  X="${A[2]//" ("/}"
                  Y="${A[3]%")"}"
                  W="${A[4]//" width "/}"
                  H="${A[5]//" height "/}"
            # On destroy event
            elif [[ "${A[0]}" =~ "DestroyNotify event" ]]; then
                  >"${DimFile}"
                  X=$((X-RX))
                  Y=$((Y-RY)) 
                  # Exports dimensions
                  echo "$X" >> "${DimFile}"
                  echo "$Y" >> "${DimFile}"
                  echo "$W" >> "${DimFile}"
                  echo "$H" >> "${DimFile}"
                  # save current workspace
                  workspace="$(xprop -root -notype _NET_CURRENT_DESKTOP 2>/dev/null)"
                  echo "${workspace:-1}" > "${WorkspFile}"
                  exit
            fi
             A=()
        done &

wait $yid
EXIT_STATUS=$?

# xev dies hard
XevPID="$(ps -eo pid,cmd | grep "xev -event structure -id $WindowIDHex" | grep -v "grep" | awk '{ print $1 }')"
kill $XevPID 2> /dev/null

echo "Our exit status: $EXIT_STATUS"
exit 0
Now let's try this with thunar*.
*Not totally off topic because the script is very similar to the previous.

Code: Select all

#!/bin/bash

# Temp file to store absolute position and dimensions
DimFile="/home/misko/Desktop/ThunarXYWH"
WorkspFile="/home/misko/Desktop/Thunarworkspace"

[[ ! -f "$DimFile" ]] && >"${DimFile}"

grep -q '[^[:space:]]' < "$DimFile" &&  readarray -t START <"$DimFile"

app=thunar
$app

# Check for running instances of $app on current desktop/workspace.
until xdotool getwindowname "$(xdotool search --desktop $(xdotool get_desktop) --class $app 2>/dev/null | tail -1 2>/dev/null)" &>/dev/null; do
        # sleep until the window opens
        sleep .1
done

#Decimal
WindowID="$(xdotool search --desktop $(xdotool get_desktop) --class $app 2>/dev/null | tail -1)"

workspace="$(cat "${WorkspFile}" 2>/dev/null)"

if [[ ${workspace} != "" ]]; then
   # change desktop
   xdotool set_desktop "${workspace: -1}"
   
   # change desktop for window
   xdotool set_desktop_for_window $WindowID "${workspace: -1}"
fi

if [[ ${START[@]} != "" ]]; then
  xdotool windowsize --sync $WindowID ${START[2]} ${START[3]}
  xdotool windowmove --sync $WindowID ${START[0]} ${START[1]}
fi

#Hexadecimal
WindowIDHex=$(printf "0x%08x" ${WindowID})

#Base seven
WindowBSeven=$(printf "0x%07x" ${WindowID})

#Get starting position and size: x, y, width, height
   XWININFO=$(xwininfo -id $WindowIDHex)
   ARRAY=(${XWININFO#* X: })
   AX=${ARRAY[0]}
   AY=${ARRAY[4]}
   RX=${ARRAY[8]}
   RY=${ARRAY[12]}
   W=${ARRAY[14]}
   H=${ARRAY[16]}
   X=$((AX))
   Y=$((AY)) 

# This monitors the window absolute-top-left x, y, width and height for changes
# If the window is moved - this will get new pos and size
# On destroy event, saves X,Y, W, and H
xev -event structure -id ${WindowIDHex} 2>/dev/null |
       while IFS=$',' read -a A;do
            if [[ "${A[0]#"${A%%[![:space:]]*}"}" =~ "event ${WindowBSeven}" && "${A[1]}${A[2]:1:1}${A[3]: -1}" =~ "window ${WindowBSeven}()" ]]; then
                  X="${A[2]//" ("/}"
                  Y="${A[3]%")"}"
                  W="${A[4]//" width "/}"
                  H="${A[5]//" height "/}"
            # On destroy event
            elif [[ "${A[0]}" =~ "DestroyNotify event" ]]; then
                  >"${DimFile}"
                  X=$((X-RX))
                  Y=$((Y-RY)) 
                  # Exports dimensions
                  echo "$X" >> "${DimFile}"
                  echo "$Y" >> "${DimFile}"
                  echo "$W" >> "${DimFile}"
                  echo "$H" >> "${DimFile}"
                  # save current workspace
                  workspace="$(xprop -root -notype _NET_CURRENT_DESKTOP 2>/dev/null)"
                  echo "${workspace:-1}" > "${WorkspFile}"
                  # xev dies hard
                  XevPID="$(ps -eo pid,cmd | grep "xev -event structure -id $WindowIDHex" | grep -v "grep" | awk '{ print $1 }')"
                  kill $XevPID 2> /dev/null
            fi
             A=()
        done

exit 0
By the way PackRat from the other forum says that Fluxbox has a save on close option that can be set for per app settings. That's very handy.

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#417 Post by MochiMoppel »

Since when does xev have an -event option?
I've seen it in Dpup but not in earlier Puppies. Looks interesting but maybe not yet common.

stemsee

#418 Post by stemsee »

Finally I use this to get geometry of named yad window, which opens and closes cyclically, with varying $secs, values. The loop starts before the yad gui opens, by a few tenths of a second, I guess, and therefore gets the last geometry values.

EDIT: I got it to work for all windows that open in the script. Here is the basic mechanism.

Using this method allows system wide window geometry records per uniquely named window. Each window that opens needs to export WINDOWTITLE and possibly APP-CONFIG-PATH (TRACK), for writing records to. Works for both yad and gtkdialogs.

Code: Select all

	TRACK="/root/.geometry/"
	[[ ! -d "$TRACK" ]] && mkdir -p "$TRACK"
	export TRACK
function sayonara { #MochiMoppel
	[[ -f /tmp/geom ]] && exit
   yad --text "Geometry Recorder Countdown" --geometry=300x10+50+50 --no-focus --no-buttons --undecorated \
   --on-top --form --field=MoreTime:FBTN "bash -c sayonara" --timeout-indicator=top --timeout=8
   nought=`xwininfo -stats -name "$WINDOWTITLE" | grep "$WINDOWTITLE"`
   XWININFO=`xwininfo -stats -name "$WINDOWTITLE"`
   if [[ ! -z "$nought" ]]; then
	   ARRAY=(${XWININFO#* X: })
	   AX=${ARRAY[0]}
	   AY=${ARRAY[4]}
	   RX=${ARRAY[8]}
	   RY=${ARRAY[12]}
	   W=${ARRAY[14]}
	   H=${ARRAY[16]}
	   X=$((AX-RX))
	   Y=$((AY-RY))
	   echo "$W"x"$H"+"$X"+"$Y" > "${TRACK}$WINDOWTITLE"
   else
		exit
   fi
}; export -f sayonara
function switchgr (){
	if [[ -f /tmp/geom ]]; then
		rm -f /tmp/geom
	else
		touch /tmp/geom
	fi
}; export -f switchgr

function wpafn (){
WINDOWTITLE="WPA-CLI-WPS"
export WINDOWTITLE
TRACK="/root/.wifi-connect/"
export TRACK
bash -c sayonara &
options=`yad --window-icon=/usr/share/pixmaps/wifi24.png --title="$WINDOWTITLE" \
--item-separator="," --geometry="$(cat ${TRACK}yad_geometry-$WINDOWTITLE)" --form --field="Select Interfaces":CBE "$netwad" \
--field="Driver Options":CBE "wext,nl80211,wired" \
--field="MODE":CBE "managed,master,ad-hoc,monitor,wps" \
--field="frequency":CBE "2412,2417,2422,2427,2432,2437,2442,2447,2452,2457,2462,5180,5200,5805,5825" \
--field="wpa_supplicant.conf":TXT \
"ctrl_interface=/var/run/wpa_supplicant\nctrl_interface_group=0\nupdate_config=1"`
}; export -f wpafn

function facesfn (){
	faces=`ls /sys/class/net`
	WINDOWTITLE="Disconnect-Interface"
	export WINDOWTITLE
        TRACK="/root/.wifi-connect/"
        export TRACK
	bash -c sayonara &
	selfce=`yad --window-icon=/usr/share/pixmaps/wifi24.png \
	--geometry="$(cat ${TRACK}yad_geometry-$WINDOWTITLE)" --title="$WINDOWTITLE" \
	--list --multiple --item-separator=' ' \
	--column="select card to disconnect" $faces`
}; export -f facesfn

nanoymaster
Posts: 1
Joined: Tue 05 Jun 2018, 21:21

#419 Post by nanoymaster »

I'm wondering how I can get variables from comboboxes in tabs?

example: https://pastebin.com/95fXXSFC

also planning a textbox on it.. is there a way to populate that textbox with result from cmd response?

stemsee

#420 Post by stemsee »

If the result from the command is written to a pipe which the yad tab is set to --listen. Or Maybe if the result from the cmd is written to a file which is monitored with tail --fn0 and writes to the pipe.

example by Victor Ananjensky
https://groups.google.com/forum/#!topic ... Hf2L6STrgM

Post Reply