My notebook suffers from image persistence and I want to create a program that moves every second the whole screen just 1 pixel to left and in the next second to the right (one pixel offset every second shouldn't be noticable for the user, right?). I've already tried to create programs with wmctrl and xdotools, but it's nearly impossible to move a fullscreen window (with both of them).
With wmctrl it's not possible to minimize a certain window. (I've already asked that question here: wmctrl: moving a fullscreen window
And with xdotool it's possible to move a window, but that's not one pixel, it's way more.
#!/bin/bash
windowIds=$(xdotools search -class "")
for windowId in $windowIds; do
name=$(xdotool getwindowname $windowId)
geo=$(xdotool getwindowgeometry $windowId)
if [[ $name == *"Firefox"* ]]; then
foo=$(xdotool windowmove --relative $windowId -1 -1)
fi
done
If you have any idea how I can solve this issue, I would be very thankful.
Thank you very much.
Related
When running mintty on Cygwin with Windows 10, if I have two windows open that partially overlap, and neither has the focus, the bottom and non-scrollbar borders are invisible, and the text of both windows runs together.
Is there a way to make these borders a little wider ?
I use a workaround: I assign a different background colour to each window. This can be done via the "Options" context menu each time you open a new window.
However, you can also automate. I've added the code below to my ".bashrc" to select the "next available" colour. The list of colours is simply a list of RGB values.
# Set the next available background colour
for COLOUR in 0,0,0 100,0,0 0,100,0 0,0,100
do
PIDFILE=/var/run/mintty-bgcolour-${COLOUR}.pid
PID=`[ -e $PIDFILE ] && cat $PIDFILE`
if ! kill -0 "$PID" 2>/dev/null
then
echo $$ > $PIDFILE
echo -ne '\e]11;'$COLOUR'\a'
trap 'rm -f '$PIDFILE EXIT
break
fi
done
unset COLOUR PIDFILE
Another workaround is to set the transparency in "options" on the window to, say, "Medium" and then check the box "Opaque when focussed". This sort of gives you a different background colour on all the windows except the active one.
In your ~/.minttyrc file add a line that says:
Padding=8
This adds an 8px border on the inside of the window frame for all subsequently launched mintty terminals. Of course you can change the 8 to whatever size appeals to your eyes.
# xdotool --version
xdotool version 2.20110530.1
# wmctrl --version
1.07
# bash --version
GNU bash, version 4.1.10(1)-release (i586-suse-linux-gnu)
I have been playing around with the Commands wmctrl and xdotool for rearranging/moving windows around the desktop. And I was wondering if it's possible to use, for example, the bottom-left Corner as the transformation point for where I want that point to end up..?
For example, if wanted to move the current window to point 100,1000 (*i.e. X-Axis=100 and Y-Axis=1000), but instead of using the top-left corner as the point that will end-up at 100,1000, I want to use current window's Bottom-Left corner instead...
Is this possible to specify this with either of these commands?
I know I could probably do this with some math equations by getting the geometry of the window and then subtract or add the height of the window (*i.e. the y-axis) from the coordinate, in order to modify where the top-left corner would be, in essence putting the bottom-left corner where I want it. But in actuality I'm moving the top-left corner, but making it seem like I'm moving it using the bottom-left corner instead.
I know this isn't the same thing, but I saw you can use the "--polar" option (*moving with degrees instead of px) with the "--window" option to use the center of the window as the point of origin... But, nothing to really specify a different corner as the transformation point...
Or maybe there is another command other then the wmctrl or xdotool command to accomplish this...
Any thoughts or suggestions would be greatly appreciated!
Thanks in Advance,
Matt
I have a question that is hard to search for the answer (I always end up with answers for monitor manipulation). I am writing a bash shell script to help me with my code dev and I have two monitors.
When I run my executable that I have compiled I want to tell it to run on a particular monitor (i.e. different to the monitor that I have my terminal open on so I can view the debug on one screen and have the app on another).
How would I go about doing this? Something like:
./myProject > but run on monitor 2
Where myProject is my binary executable.
Thanks all.
If you run separate displays on each monitor (less likely these days), the DISPLAY environment variable is what you want.
If you use Xinerama (spreading one logical display across multiple monitors), however:
Aside: X11 vocabulary: A "display" is one or more "screens" with input devices; e.g. keyboard and mouse, a.k.a. a "seat." A "screen" is a logical canvas that is partially or completely displayed on one or more "monitors;" when using multiple monitors for one "screen," the windows can be partially displayed on each monitor, but share the same X11 DISPLAY identifier; this is called Xinerama. The DISPLAY format is host : display-number . screen-id, so e.g. on my Xinerama set-up both monitors are part of screen 0 on a display number that counts up from 0 with each logged-in user on the same host. "Seats" are logical groups of monitor+input that are using different hardware; multiple "displays" can occur using "virtual console" switching, which is how Gnome and KDE allow multiple users to sign in on a single "seat" machine.
Most GUI toolkits allow you to specify the window's geometry using the --geometry or -geometry switch.
Qt uses the older MIT-style -geometry form. GTK+/Gnome uses the GNU-style --geometry.
This assumes that you're allowing Qt to post-process your command-line, e.g. passing argv into QtApplication or similar.
The “logical display” will have a resolution which is the sum of the resolutions in each direction of the arrangement of your monitors. For example, I have 2 × 1920×1080 displays hooked up right now. xrandr reports:
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 8192 x 8192
To display a window on the right-hand monitor, I can give a geometry string that has its x co-ordinates between 1920…3839 (inclusive).
The usual format is: width x height ± x-offset ± y-offset — but the width and height are optional, if you prefer to take the defaults. The ± are + to count relative to the top/left, or - to count relative to the bottom/right.
So, for example:
gedit --geometry 800x600+1920+0 # set size at top-left of right screen
gedit --geometry +1920+100 # default size at top-left of right screen
gedit --geometry -0+0 # default size at top-right of entire display
Unfortunately, the only programmatic way I know of to determine the area of the display on each monitor from the shell would be to parse the output from xrandr; e.g.
$ xrandr
Screen 0: minimum 320 x 200, current 3840 x 1080, maximum 8192 x 8192
LVDS1 connected (normal left inverted right x axis y axis)
1366x768 60.0 +
1024x768 60.0
800x600 60.3 56.2
640x480 59.9
VGA1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 510mm x 287mm
1920x1080 60.0*+
1680x1050 60.0
1280x1024 60.0
1440x900 59.9
1280x720 60.0
1024x768 60.0
800x600 60.3
640x480 60.0
720x400 70.1
HDMI1 connected 1920x1080+1920+0 (normal left inverted right x axis y axis) 510mm x 287mm
1920x1080 60.0*+
1680x1050 59.9
1280x1024 60.0
1440x900 59.9
1280x720 60.0
1024x768 60.0
800x600 60.3
640x480 60.0
720x400 70.1
DP1 disconnected (normal left inverted right x axis y axis)
$ xrandr | perl -ne 'if (/(\d+)x(\d+)\+(\d+)\+(\d+)/) '\
> ' { print "$3,$4 - ", $3 + $1 - 1, ",", $4 + $2 - 1, "\n" }'
0,0 - 1919,1079
1920,0 - 3839,1079
(You'd normally want to avoid splitting the Perl one-liner across two lines in the shell, but the '\…' trick there is to make it legible on SO.)
The --geometry answer given above and accepted simply won't work in many cases...
There are a lot of near-identical questions like this floating around the various StackExchange sites & AskUbuntu, the answer I've eventually found (on a Linux Mint distro based on Ubuntu 14.04) is to use wmctrl. I'm leaving an answer just since no one else has mentioned it on this thread.
(There's another called Devil's Pie and another called Compiz if you search for those too you'll find the Q&A's I'm talking about)
wmctrl is the sort of simple unix tool you're probably looking for if you're writing Bash scripts. I also saw someone suggest using xdotool, depends what the specific goal is.
wmctrl offers window matching by window title or pid (not compatible with all types of X-managed windows)
Some helpful resources:
wmctrl man page
user doc 1
user doc 2
“How to shift applications from workspace 1 to 2 using command?"”
More specific answer RE: specifying the dimensions
“Both wmctrl and xdotool work fine if you set a window maximized.”
I connect a second monitor on the left or on the right depending on where I'm working each day, and I think the solution for me will involve
finding the dimensions from xrandr (as shown in BRPocock's answer),
parsing that to tell which is the external connected monitor (VGA/HDMI etc.) rather than the inbuilt one,
specifying a dimension to give to a maximised window on the connected screen (i.e. the left/right/top/bottom offset, which will change according to side of the screen being used)
Leaving my notes and [eventually] some code produced here in case it's useful to anyone else.
Use a fifo
open a terminal window on the monitor you want the output to appear on and do
mkfifo /tmp/myfifo
cat /tmp/myfifo
then on the source terminal do
./myProject >/tmp/myfifo
This assumes it is a console app. If it is graphical then you will need another approach, which will be dependent on what windowing manager + toolkit you are using.
All you need to do is set the DISPLAY environmental variable prior to running your application.
To find out what you need to set it to, run the following on the monitor you want it to show up on:
echo $DISPLAY
You should see, for example :0.1 or :0.0.
Then you can specify that you want your app to run on that display like so:
DISPLAY=:0.1 ./my_app
As your application uses QT, you are probably using KDE. In System Settings > Window Behavior > Advanced, set Placement to Under Mouse. Click the desired monitor, ALT+Tab to switch to your terminal, and start the program.
I am outputing some text on the screen in perl
However, I want to make sure that only 1 line fits on each screen line thus if I change screen the program would automatically adjust its output line size.
Is there a way to automatically do it without having user-interaction?
Thanks
perl -MTerm::ReadKey -E '($cols,$rows) = GetTerminalSize(); say "This screen has $rows rows and $cols columns."'
On Unix/Linux you should be able to use the Term family of modules to get the current screen size. You can even hook SIGWINCH with it and respond to a terminal window resize event by adjusting your output.
http://search.cpan.org/modlist/User_Interfaces/Term
I am trying to write a script to let me start a set of terminals of specific size at a specific position on screen (for instance, four terminals spread across my screen in a grid model each active). If there is already a tool that can do this, that would be great too... Any suggestions?
I'm sure there will be better answers but one thing I did find useful was this:
gnome-terminal --geometry=130x25+20+525
So on my large monitor, the following is giving me two nice terminals:
#!/bin/sh
gnome-terminal --geometry=150x125+20+25
gnome-terminal --geometry=150x125+1020+25
And the following is the explanation from the man page for quick reference:
-geometry WIDTHxHEIGHT+XOFF+YOFF
(where WIDTH, HEIGHT, XOFF,
and YOFF are numbers) for specifying a preferred size and location for
this application's main window.
The WIDTH and HEIGHT parts of the geometry specification are usually
measured in either pixels or characters, depending on the application.
The XOFF and YOFF parts are measured in pixels and are used to specify
the distance of the window from the left or right and top and bottom
edges of the screen, respectively. Both types of offsets are measured
from the indicated edge of the screen to the corresponding edge of the
window. The X offset may be specified in the following ways:
+XOFF The left edge of the window is to be placed XOFF pixels in from
the left edge of the screen (i.e., the X coordinate of the win-
dow's origin will be XOFF). XOFF may be negative, in which
case the window's left edge will be off the screen.
-XOFF The right edge of the window is to be placed XOFF pixels in
from the right edge of the screen. XOFF may be negative, in
which case the window's right edge will be off the screen.
The Y offset has similar meanings:
+YOFF The top edge of the window is to be YOFF pixels below the top
edge of the screen (i.e., the Y coordinate of the window's ori-
gin will be YOFF). YOFF may be negative, in which case the
window's top edge will be off the screen.
-YOFF The bottom edge of the window is to be YOFF pixels above the
bottom edge of the screen. YOFF may be negative, in which case
the window's bottom edge will be off the screen.
This approach is very simple and using a command like this:
gnome-terminal -x sh -c "ls|less"
In addition to the above commands, one can do even more fancy things :) For instance, you can make it launch itself into a specific directory (very useful if you're editing source code in one window and debugging using the other like I am).
Terminitor is a project that addresses this: https://github.com/achiu/terminitor
Unfortunately, it doesn't have gnome-terminal support yet (just OS X and Konsole).
Terminator has such a feature.