You are not logged in.
Pages: 1
TL;DR: How to increase the width/number of characters in the windowlist drop-down menu?
Hi All,
I am new to Xfce - Xubuntu 16.04 LTS - and I really like the "xfdesktop --windowlist" command. It is the same as a middle mouse click on the desktop. At work I have plenty of windows, so it would be great feature for me.... if I could make the list wider, so that more characters of the window titles are displayed. Unfortunately my windows have title like "Program name + file_name". For me the file name is important, but the program name is just so long, that the file name is not displayed anymore. I might have 5-10 different files open with the same program in different windows. Is there any way to set it up? There must be some way, if nothing else editing the script code for this feature manually.
Offline
Hello and welcome.
The gtk3 builds of xfdesktop don't have that limitation, only the gtk2 builds. I've had a look and I don't think you affect it via gtk overrides. The code that affects the label length seems to be here:
gtk_label_set_max_width_chars(label, 24);
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
@ToZ I came up with this bash script.
The only way (as far as I know) to display the same icons as in the xfce window list
is to scrape them and store them in some folder. Later use them in a yad dialog.
The path for icon cache is in this line:
TMPDIR="/path/to/$gtkIcons"
#!/bin/bash
#######################################################
# Description: #
# bash script to list and focus windows #
# via yad list UI #
#######################################################
ERR(){ echo "ERROR: $1" 1>&2; }
declare -i DEPCOUNT=0
for DEP in /usr/bin/{xdotool,perl,wmctrl,yad,convert,xprop,awk,xargs,iconv} /bin/{rm,echo,sed}; {
[ -x "$DEP" ] || {
ERR "$LINENO Dependency '$DEP' not met."
DEPCOUNT+=1
}
}
[ $DEPCOUNT -eq 0 ] || exit 1
# Ensure only one instance of this scipt can start
if [[ $(pgrep -c $(basename $0)) -ne 1 ]]; then
pids="$(xdotool search --class "wlist")"
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
exit 1
fi
done
fi
# Check if there are windows present
wmctrl -l | while read -a A; do
if [[ "${A[1]}" -ge "0" ]];then
exit 1
fi
done
if [[ "$?" -eq 0 ]]; then
yad --text="Window list:\nNo windows to show." \
--no-buttons \
--undecorated \
--close-on-unfocus \
--on-top \
--skip-taskbar \
--mouse \
--sticky \
--class="wlist"
exit 0
fi
#######################################################
# Note: #
# to show the icon for the "zathura" application #
# create a config file ~/.config/zathura/zathurarc #
# with contents: set window-icon /path/to/zathura.png #
# there is a manual page for zathurarc: man zathurarc #
#######################################################
# Activation method can be select or dclick
# select - focus window on selection
# dclick - focus window on double-click
ACTION=select
gtkIcons=Default
# Get Icon Theme name Mate desktop
#gtkIcons=$(gsettings get org.mate.interface icon-theme)
#gtkIcons=${gtkIcons//"'"}
# Get icon theme bunsen hidrogen
#gtkIcons="$(awk -F'"' '/^gtk-icon-theme-name/{print $2}' ~/.gtkrc-2.0)"
# Get Icon Theme Name Xfce Desktop
gtkIcons=$(xfconf-query -c xsettings -p /Net/IconThemeName)
# Temp dir to store the icon cache
TMPDIR="~/Desktop/window-icons/$gtkIcons"
if [[ ! -d "$TMPDIR" ]]
then
mkdir -p "$TMPDIR"
fi
# Get active window id
ACTIVE_WIN_ID=$(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | awk '{print $2}')
# With process substitution output from "wmctrl -l" is redirected here
# while loop reads "win_id" and "display" variables
while read -r win_id display app text
do
# Skip sticky windows with display id -1
[[ "$display" -eq "-1" ]] && continue
# Get WM_CLASS X window property
wm_class="$(xprop -id $win_id WM_CLASS | awk -F'"' '{print tolower($4)}')"
if [[ ! -f $TMPDIR/$wm_class.png ]]
then
#Convert icon to pam then use imagemagick to convert to png and resize
xprop -notype 32c -id $win_id _NET_WM_ICON \
| perl -0777 -pe '@_=/\d+/g;
printf "P7\nWIDTH %d\nHEIGHT %d\nDEPTH 4\nMAXVAL 255\nTUPLTYPE RGB_ALPHA\nENDHDR\n", splice@_,0,2;
$_=pack "N*", @_;
s/(.)(...)/$2$1/gs' \
| convert pam:- -resize 16x16 $TMPDIR/$wm_class.png 2>/dev/null
if [[ $? -ne 0 ]] && [[ ! -f "$TMPDIR/$wm_class" ]]
then
NET_NAME=$(xprop -id $win_id _NET_WM_NAME | awk -F '"' '{print $2}')
echo "$NET_NAME" > "$TMPDIR/$wm_class"
fi
fi
# Extract the application name from string
app="${app##*'.'}"
# make active window row bold
if [[ "$win_id" -eq "$ACTIVE_WIN_ID" ]]
then
#display="<b>$display</b>"
app="<b>$app</b>"
text="<b>$text</b>"
fi
# if WM_CLASS is a "Wrapper"
if [[ "${wm_class}" == "Wrapper" ]]
then
# Get WM_CLASS X window property _NET_WM_NAME
wm_class=$(xprop -id $win_id _NET_WM_NAME | awk -F '"' '{print $2}')
# print to yad columns
if [[ "$wm_class" -ne "" ]]
then
echo "$wm_class"
else
echo "xfwm4"
fi
echo "$win_id" # We use this one for select-action (hidden column)
echo "$text" | sed "s/\&/\&/g" | # escape ampersand
iconv -c -t UTF-8 # convert characters to utf-8
echo "$display ${wm_class}" | sed "s/\&/\&/g"
else
if [[ -f $TMPDIR/$wm_class.png ]]
then
echo "$TMPDIR/$wm_class.png"
elif [[ -s "$TMPDIR/$wm_class" ]]
then
cat "$TMPDIR/$wm_class"
else
echo "$wm_class"
fi
# print to yad columns
echo "$win_id" # We use this one for select-action (hidden column)
echo "$text" | sed "s/\&/\&/g" | # escape ampersand
iconv -c -t UTF-8 # convert characters to utf-8
echo "$display ${app}" | sed "s/\&/\&/g"
fi
done < <(wmctrl -l -x \
| awk '{$4="";
if($3=="zathura.Zathura")
print $1, $2, substr($0, index($0,$5), 50);
else
print $1, $2, $3, substr($0, index($0,$5), 50);}') \
| yad --list \
--title="WList" \
--column="icon":IMG \
--column="win_id" \
--column="title" \
--column="display / app" \
--width="500" \
--height="450" \
--hide-column="2" \
--$ACTION-action="sh -c \"echo %s | cut -d ' ' -f 2 2>&1 | xargs xdotool windowactivate -- \"" \
--no-buttons \
--search-column=3 \
--window-icon="mate-desktop" \
--undecorated \
--close-on-unfocus \
--on-top \
--skip-taskbar \
--mouse \
--sticky \
--class="wlist"
exit 0
dependancies:
xdotool,wmctrl,yad,convert,xprop,iconv
Note: Yad list doesn't like some characters so escaping the ampersand
and converting the characters to utf-8 is the reason iconv is used.
awk command trims the length of window name to 50 characters
in these lines:
| awk '{$4="";
if($3=="zathura.Zathura")
print $1, $2, substr($0, index($0,$5), 50);
else
print $1, $2, $3, substr($0, index($0,$5), 50);}') \
On selecting the item in the window list it will focus the window.
It's also working in mate desktop and openbox with small changes in the script to get the Icon Theme name.
By the way, it can be used in a custom panel launcher.
Last edited by Misko_2083 (2018-03-15 22:29:17)
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
Thanks ToZ! That sounds good. Unfortunately I do not know how to move forward with it. I have not found any "windowlist*" files in my system. I thought that I could recompile just that file. I do not want to reinstall my whole system. I have spent too much time setting it up.
Thanks Misko! It is impressive as well! I need to debug why I do not get the focus of the window when I click on its name in the list. Am I right, if say that this line do the printout into the terminal and also the window focus change?
--$ACTION-action="sh -c \"echo %s | cut -d ' ' -f 2 2>&1 | xargs xdotool windowactivate -- \"" \
I got outputs like this:
|0x05200010|Inbox - Mozilla Thunderbird|0 Thunderbird|
If I write the following into the terminal - i.e. I change the delimiter in cut from space to pipe - then I got the focus on my Thunderbird:
echo "|0x05200010|Inbox - Mozilla Thunderbird|0 Thunderbird|" | cut -d '|' -f 2 | xargs xdotool windowactivate
Unfortunately adding this change into the script does not work.
Could you help debugging this? I just hope that you understand it better what is happening.
Offline
I need to debug why I do not get the focus of the window when I click on its name in the list. Am I right, if say that this line do the printout into the terminal and also the window focus change?
--$ACTION-action="sh -c \"echo %s | cut -d ' ' -f 2 2>&1 | xargs xdotool windowactivate -- \"" \
Correct, that's the line that sets the window in focus. But there isn't suppose to be any printout.
Check the yad version. Maybe it's older and doesn't have and option to use --select-action and dclick-action in a list.
Mine is 0.40:
yad --version
0.40.0 (GTK+ 2.24.25)
Since 0.39 relese Victor move yad to github https://github.com/v1cont/yad/releases
Maybe you can compile it manually.
This is how xdotool works.
xdotool needs the window id to give it focus.
for example
xdotool windowactivate 0x05200010
xargs passes the string from the pipe as an argument to xdotool
echo 0x05200010 | xargs xdotool windowactivate --
What could be is --select-action isn't working. If that is the case, maybe double click is working:
--dclick-action="sh -c \"echo %s | cut -d ' ' -f 2 2>&1 | xargs xdotool windowactivate -- \"" \
If it still isn't working, you can print the list item as a string in the terminal with this change:
--$ACTION-action="sh -c \"echo %s\"" \
Do you want to exit the Circus?
https://www.youtube.com/watch?v=ZJwQicZHp_c
Offline
@Misko_2083, what a cool script. Thanks for sharing.
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.010 seconds, 7 queries executed - Memory usage: 586.7 KiB (Peak: 603.54 KiB) ]