my purpose is to make a certain vim window as a dock (stay on all screens, fixed location, won't be affected by XMonad layout, etc). So i used xprop to set a window as dock type. But XMonad did not seem to honor it. What else should I do?
The xprop command:
$ xprop -id 0x2400001 -f _NET_WM_WINDOW_TYPE 32a -set _NET_WM_WINDOW_TYPE _NET_WM_WINDOW_TYPE_DOCK
$ xprop -id 0x2400001 | grep TYPE
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DOCK
https://askubuntu.com/a/732058/585364
You also need to set a strut property: xprop -f _NET_WM_STRUT 32c -set _NET_WM_STRUT 0,300,0,0
And you probably also need to 'move' the window to that location.
This does require an xmonad restart to take effect when I tested it.
Related
I am trying to force a particular window to be always on top:
xprop -id 0x3800154 -set _NET_WM_STATE\(ATOM\) = _NET_WM_STATE_ABOVE
Debian buster reports:
xprop: error: unsupported conversion for _NET_WM_STATE(ATOM)
I have read https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm45408774010480
but cannot get my head around it.
Your command is almost correct, it should be:
xprop -f _NET_WM_STATE 32a -id 0x3800154 -set _NET_WM_STATE _NET_WM_STATE_ABOVE
The most notable addition is the -f parameter. It specifies the format of the field _NET_WM_STATE. If this is not given, xprop does not know how to interpret the desired property value (_NET_WM_STATE_ABOVE).
According to the specification you provided, _NET_WM_STATE is a 32bit ATOM value (-f _NET_WM_STATE 32a).
The equals sign and \(ATOM\) are not required
A sidenote that might be useful: You can also specify multiple STATE values by comma-separating them, e.g.
xprop -f _NET_WM_STATE 32a -id 0x3800154 -set _NET_WM_STATE _NET_WM_STATE_ABOVE,_NET_WM_STATE_FULLSCREEN
I often run Vim in a tmux session to I can run tests in an adjacent pane. On a smaller monitor, I either have to sacrifice more Vim screen real estate than I'd like, or make the test pane too small to read the full results (which is fine if everything passes, but not when there are failures and I need to see the details).
Then my workflow becomes:
trigger tests from within Vim
switch to test pane (last-pane)
zoom pane to occupy full window (resize-pane -Z)
read the results
restore original layout (resize-pane -Z)
switch back to Vim pane (last-pane)
I wanted to add a key binding that I could use when I'm in the Vim pane to zoom the test pane (hiding Vim), and be able to use the same binding once zoomed to restore the original layout, returning me to Vim. This is what I came up with, but I wonder if there's a better way I can do it. I had to set, check, and unset an environment variable to save the state that would support toggling back and forth with the same key binding. I also haven't figured out how to make the toggle state specific to a window (right now, any multi-window session shares the state across all its windows, so this doesn't work correctly)
bind Space if-shell '[ -z "${ALT_PANE_ZOOM+x}" ]' \
'select-pane -t :.+; resize-pane -Z; set-environment ALT_PANE_ZOOM 1' \
'set-environment -u ALT_PANE_ZOOM; last-pane'
Update:
I found a simpler solution. Rather than relying on a per-window environment variable, I can leverage -F and the window_zoomed_flag format variable:
bind Space if-shell -F '#{window_zoomed_flag}' \
'last-pane' \
'select-pane -t :.+; resize-pane -Z'
In your tmux.conf, create a keybind which:
Saves the zoom state
Switch to the last pane, unzooming if a pane was zoomed in
Conditionally zooms depending on the zoomed state in #1
-
bind key run-shell "tmux setenv zoomed $(tmux display -p '#{window_zoomed_flag}')"\; \
last-pane\; \
run-shell "test $(tmux display -p '#{zoomed}') -ne 0 || tmux resize-pane -Z"
Note that the backslash escapes on the semicolons command separators are required.
I want to change top panel color and alpha when any window is maximized.
For now I have something like this:
#!/bin/bash
while [ 1 = 1 ]
do
if window_is_maximized
then
xfconf-query -c xfce4-panel -p /panels/panel-0/background-alpha -s 100
else
xfconf-query -c xfce4-panel -p /panels/panel-0/background-alpha -s 50
fi
done
Maximized windows in X do not have a special state that you can test reliably. From a script, you can use xwininfo:
You can check if the window happens to be the same size as the root (main) window, and its position is the upper-left corner.
If you happen to be using a window manager which supports certain EMWH properties (_NET_WM_STATE_FULLSCREEN, _NET_WM_STATE_MAXIMIZED_VERT, _NET_WM_STATE_MAXIMIZED_HORZ), your script could check for those. But in a quick check for window managers which might do that, I found none.
I need a tool similar to ClickOff but this tool can work on Linux.
I tried several tools such as xautoclick but it is not what I want, I want to tool that can automatically click OK button when a popup window shows up (such as a webbrowser popup).
ClickOff works fine for me but the point is it cannot run on Linux. So anybody who knows such a tool or suggest me an approach so that I can write a tool like that on Linux. My Linux experience is modest, so please help me.
This might work for you.
xdotool lets you programatically (or manually) simulate keyboard input
and mouse activity, move and resize windows, etc. It does this using
X11's XTEST extension and other Xlib functions.
There is some support for Extended Window Manager Hints (aka EWMH or
NetWM).
Something like this can be automated in a shell script BUT the bellow moves your cursor, so if you want it to run constantly like some background daemon you should save your original mouse coordinates and set it back afterwards... Personally I'd hate a something like this, as this steals your (window)focus...:
Search for the window by title:
export WINID=`xdotool --onlyvisible --name YOURAPP`
gather further window information
It is usually useful to know the window's height and width.
WIDTH=`xwininfo -all -int -id $WINID|grep Width|cut -d ':' -f2 |cut -d ' ' -f2`
HEIGHT=`xwininfo -all -int -id $WINID|grep Height|cut -d ':' -f2 |cut -d ' ' -f2`
Position mouse to window's top corner: to set the position of the mouse to 0,0 offset from the top-left of the window, first use
xwininfo to determine window position...
TOP_LEFT_X=`xwininfo -all -int -id $WINID|grep Absolute |grep X |cut -d ':' -f2 |sed 's/ //g'`
TOP_LEFT_Y=`xwininfo -all -int -id $WINID|grep Absolute |grep Y |cut -d ':' -f2 |sed 's/ //g'`
Now use those coordinates to position the mouse absolutely.
xdotool mousemove $TOP_LEFT_X $TOP_LEFT_Y
NOTE: With curved corner windows, clicking at this point may select another window, and de-focus
your target.
You can calculate relative positions based on percentages, eg: using the 'bc' tool on the
command line:
CENTER_X=`echo $WIDTH/2|bc`
CENTER_Y=`echo $HEIGHT/2|bc`
Move the cursor:
xdotool mousemove_relative $CENTER_X $CENTER_Y
If you wanted the pointer centered horizontally, but 135 pixels above the bottom of the
window:
xdotool mousemove_relative $CENTER_X `echo $HEIGHT-135|bc`
Perform input:
xdotool click 1
My xterm $prompt variable in my .tcshrc is:
set prompt="%{\033]0;%m:%~\007%}%{^[[;37;1m%}%B%{^[[;34;1m%}%m%{^[[;34;1m%}:%b%c%# "
The highlighted part above (%{\033]0;%m:%~\007%}) puts the hostname (%m) and the current directory (%~) in the title bar. (At least I think that that's what puts it in the title bar; it's been a while since I fiddled with this prompt).
When I run screen, however, the current directory stops getting updated when I change directories.
My questions:
How can I make this prompt work in screen?
Is there a better way to display the current directory in the title bar?
I am running linux with xterm and tcsh.
I think there is no direct way, because of the way screen works. However screen can display its own status bar, that you can define in .screenrc. Here's mine for instance :
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%=%{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c %{g}]'
Firstly, to make it work you must check where exactly is the line with set prompt=blah-blah in your .tcshrc. For example, the code below that perfectly works in plain xterm would not work under screen in xterm:
switch ($TERM)
case "xterm*":
set prompt="%{\033]0;${HOME:t}#%m:%l:%c08\007%}%{\033[36m%}%l:%c02%#%{\033[0m%} "
# update xterm title to display current cmd in it
alias postcmd 'echo -n "\033]0;${HOME:t}#`hostname`:${tty} \!#:q\007"'
...
because screen by default sets $TERM variable to screen and not xterm! So you must add:
case "screen":
# lame, but prevents an error in screen after 'su - root'
if (! $?WINDOW) setenv WINDOW 1
set prompt="%{\033]0;${HOME:t}#%m:${WINDOW}:%c08\007%}%{\033[36m%}%c02%#%{\033[0m%} "
alias postcmd 'echo -n "\033]0;${HOME:t}#`hostname`:${WINDOW} \!#:q\007"'
...
Secondly, make sure yo have this line in ~/.screenrc:
termcapinfo xterm* 'hs:ts=\E]2;:fs=\007:ds=\E]2;\007'