You are not logged in.
Pages: 1
How does the xfce4-panel stores position and coordinates?
With the xfconf-query on an 1920x1080 screen the output is:
xfconf-query -c xfce4-panel -p /panels -l -v
/panels/panel-1/position p=8;x=960;y=1064
What is p and where is this point with coordinates x,y?
wmctrl, xdotool and xwininfo give different values about the panel window position.
If I run this script while the mouse pointer is positioned on the panel...
#!/bin/bash
# Get current mouse position
out="$(xdotool getmouselocation)"
out=(${out//[^0-9 ]/})
# xdotool getmouselocation returns a decimal window id and wmctrl gives a hexadecimal id.
WindowID=$(printf "0x%08x" ${out[3]})
(echo wmctl; wmctrl -l -G | grep $WindowID; \
echo xdotool; xdotool getwindowgeometry $WindowID ; \
echo xwininfo; xwininfo -id $WindowID \
| sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p") |
yad --width=500 --height=500 --text-info
...The panel has absolute coordinates 0 1049 and with and height 1920 31.
wmctl
0x01600004 -1 0 1049 1920 31 p64 xfce4-panel
xdotool
Window 23068676
Position: 0,1049 (screen: 0)
Geometry: 1920x31
xwininfo
x=0
y=1049
w=1920
h=31
The xfconf-query ouputs panel legth in percentage and with the panel there size seems to be 1 pixel reserved for something (maybe border or auto-hide). Mode could be horizontal, vertical and deskbar (0,1,2)
xfconf-query -c xfce4-panel -p /panels -l -v
/panels <<UNSUPPORTED>>
/panels/panel-1/background-image /usr/share/images/desktop-base/Untitled2x.png
/panels/panel-1/background-style 0
/panels/panel-1/length 100
/panels/panel-1/mode 0
/panels/panel-1/plugin-ids <<UNSUPPORTED>>
/panels/panel-1/position p=8;x=960;y=1064
/panels/panel-1/position-locked true
/panels/panel-1/size 30
/panels/panel-2/autohide true
/panels/panel-2/background-alpha 0
/panels/panel-2/background-image /usr/share/images/desktop-base/Untitled2x-v.png
/panels/panel-2/background-style 0
/panels/panel-2/length 30
/panels/panel-2/length-adjust true
/panels/panel-2/mode 2
/panels/panel-2/nrows 1
/panels/panel-2/plugin-ids <<UNSUPPORTED>>
/panels/panel-2/position p=7;x=25;y=497
/panels/panel-2/position-locked true
/panels/panel-2/size 36
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
The p value is the position taken from this enum where 0 is none and the rest are filled in incrementally.
My understanding is that the x and y values are only relevant if the position is not fixed (ie. 0, 13 or 14).
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Thank you very much ToZ.
This "directional navigation" looks like relative positioning with numbers 1-12 on the screen edges or corners and 0, 13, 14 when the panel is floating.
I thought I can find out which panel has been under mouse pointer based on absolute position and size from xwininfo.
The yad dialogs are very hard to position close to notification icon.
It's much easier if I split the screen size into relative position boxes (zones), compare that with the notification icon position and make adjustments based on that info. Although not perfect.
#!/bin/bash
# alsa volume notification icon
ERR(){ echo "ERROR: $1" 1>&2; }
declare -i DEPCOUNT=0
for DEP in /usr/bin/{xdotool,yad,notify-send}; {
[ -x "$DEP" ] || {
ERR "$LINENO Dependency '$DEP' not met."
DEPCOUNT+=1
}
}
[ $DEPCOUNT -eq 0 ] || exit 1
export YAD_AUDIO=$(mktemp -u --tmpdir YAD_AUDIO.XXXXXXXX)
mkfifo "$YAD_AUDIO"
trap "rm -f $YAD_AUDIO" EXIT
function get_volume(){
vol=$(amixer get Master | grep "\[on\]\|\[off\]")
vol=( $vol )
# Fredx181 check for pulseaudio
[ $(pidof pulseaudio) ] && CURVOL=$(echo ${vol[4]} | sed 's/[][%]//g') || CURVOL=$(echo ${vol[3]} | sed 's/[][%]//g')
}
export -f get_volume
YAD_AUDIO_audio(){
# set window class
YAD_CLASS="YAD_AUDIO"
# Unmap the window if the script is relaunched
# This closes the window if notification icon is clicked while the popup window is in focus
pids="$(xdotool search --class "$YAD_CLASS")"
wpid="$(xdotool getwindowfocus)"
for pid in $pids; do
# Compares window class pid with the pid of a window in focus
if [[ "$pid" == "$wpid" ]]; then
xdotool windowunmap $pid &>/dev/null
exit 1
fi
done
get_volume
# Format xrandr output
xrandr="$(xrandr | grep -w "connected" | grep -o "[0-9]\+x[0-9]\++[0-9]\++[0-9]\+" | tr "x+" " " | sort -nk 4)"
# Get num of monitors
num_screens=$(echo "$xrandr" | wc -l)
[ "$num_screens" -gt 2 ] && echo "Script cannot deal with more than 2 monitors" >&2 && exit 1
# Get screen resolution
screen_left=($(echo "$xrandr" | head -1))
[ "$num_screens" -gt 1 ] && screen_right=($(echo "$xrandr" | tail -1))
# Get current mouse position
out="$(xdotool getmouselocation)"
out=(${out//[^0-9 ]/})
current_x="${out[0]}"
current_y="${out[1]}"
# Calculate current monitor and relative position to this monitor
if [ "$num_screens" -gt 1 ] && [ "$current_x" -gt "${screen_right[2]}" ]; then
current_screen=(${screen_right[*]})
current_x=$(($current_x-${screen_right[2]}))
else
current_screen=(${screen_left[*]})
fi
# Check relative position
if [ "$current_y" -lt "$((${current_screen[1]}*1/4))" ]; then # IN-TOP
var_key="top"
elif [ "$current_y" -gt "$((${current_screen[1]}*3/4))" ]; then # IN-BOTTOM
var_key="bottom"
fi
if [ "$current_x" -lt "$((${current_screen[0]}*1/4))" ]; then # IN-LEFT
var_key="${var_key}left"
elif [ "$current_x" -gt "$((${current_screen[0]}*3/4))" ]; then # IN-RIGHT
var_key="${var_key}right"
fi
[ ! "$var_key" ] && var_key="center"
#echo "$var_key"
case ${var_key} in
top) current_x=$(($current_x-250))
;;
topleft) : #skip
;;
topright) current_x=$(($current_x-295))
;;
bottom) current_x=$(($current_y-210))
;;
bottomleft) current_y=$(($current_y-210))
;;
bottomright) current_x=$(($current_x-295))
current_y=$(($current_y-210))
;;
left) :
;;
right) current_x=$(($current_x-310))
;;
center) :
;;
esac
PLUG=$(($RANDOM * $$))
yad --plug=$PLUG --tabnum=1 --scale \
--print-partial \
--text=" Volume Control " \
--min-value=0 --max-value=100 \
--image="preferences-desktop-sound" \
--borders="12" \
--value="$CURVOL" 2> /dev/null | \
while read VOL; do
set_notification_icon $(printf "%3d" "$VOL") 2>&1 >$YAD_AUDIO
amixer sset 'Master' "$VOL%" 2>&1 >/dev/null
done &
yad --plug=$PLUG --tabnum=2 --text="" --form --field="Mute/Unmute":fbtn "bash -c 'alsa_toggle'" &
yad --paned --key=$PLUG --tab="Tab 1" --tab="Tab 2" --width=300 --height=200 \
--posy=$current_y --posx=$current_x \
--no-buttons \
--undecorated \
--close-on-unfocus \
--on-top \
--skip-taskbar \
--sticky \
--class="$YAD_CLASS"
}
export -f YAD_AUDIO_audio
function set_notification_icon
{
LANG=C.UTF-8
if amixer | grep -E -A 6 -B 0 'Master|Headphone|Speaker' | grep '\[off\]'; then
amixer set Master unmute
amixer set Speaker unmute
amixer set Headphone unmute
get_volume
set_notification_icon $(printf "%3d" "$CURVOL") 2>&1 >$YAD_AUDIO
fi
if [[ "$1" -ge "68" ]]; then
echo "icon:notification-audio-volume-high"
elif [[ "$1" -ge "34" && "$1" -lt "68" ]]; then
echo "icon:notification-audio-volume-medium"
elif [[ "$1" -ge "1" && "$1" -lt "34" ]]; then
echo "icon:notification-audio-volume-low"
elif [[ "$1" -lt "1" ]]; then
echo "icon:notification-audio-volume-off"
fi
echo "tooltip:Volume $1 %"
echo "menu:About!sh -c 'notify-send -i notification-audio-volume-high -t 8000 \"Volume Control\" \"by Misko_2083\"'!gtk-about||Quit!quit!gtk-quit"
}
export -f set_notification_icon
function alsa_toggle(){
if amixer | grep -E -A 6 -B 0 'Master|Headphone|Speaker' | grep '\[off\]'; then
amixer set Master unmute
amixer set Speaker unmute
amixer set Headphone unmute
get_volume
set_notification_icon $(printf "%3d" "$CURVOL") 2>&1 >$YAD_AUDIO
else
echo "icon:notification-audio-volume-muted" 2>&1 >$YAD_AUDIO
amixer set Master mute
fi
}
export -f alsa_toggle
exec 3<> $YAD_AUDIO
yad --notification --command="bash -c 'YAD_AUDIO_audio'" \
--listen <&3 & notifpid=$!
# Don't set the icon untill the yad notification is ready
# until there is a window name do -> sleep
until xdotool getwindowname $(xdotool search --pid "$notifpid" 2>/dev/null | tail -1) &>/dev/null; do
# sleep until the window opens
sleep 1
done
# Set intitial volume icon
get_volume
set_notification_icon $(printf "%3d" "$CURVOL") >&3
# Waits for notification to exit
wait $notifpid
exec 3>&-
exit 0
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
That's not a bad implementation at all. Amazing what can be done with scripting languages (and the right tools).
Thanks for sharing the script.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
I agree, it's amazing what can be done with only a few lines of script and the right tools.
Fredx181 from the puppy forums made this small, but very good, radio player https://github.com/fredx181/yradio with yad --paned dialog.
Thanks for all of your help on the forum.
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
Fredx181 from the puppy forums made this small, but very good, radio player https://github.com/fredx181/yradio with yad --paned dialog.
Wow. Very nice.
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Pages: 1
[ Generated in 0.013 seconds, 7 queries executed - Memory usage: 586.45 KiB (Peak: 603.29 KiB) ]