Code Monkey home page Code Monkey logo

movescreen's People

Contributors

calandoa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

movescreen's Issues

behaviour with 3 screens in 'inverted pyramidal' position

Hi,

This is not reaaly an issue, rather a 'weird situtation' due to my screen layout :

screen-layout

When on 'top row', using left right works perfectly.
But when asking to move down ... the movement moves the window below, which is expected, but does not 're' compute the position.
As a result, the window is 'cropped', I mean : it is not 'centered' on below screen. If it comes from the top-left screen, when it arrives at bottom screen the left part of the window is 'in the void'.

It works exactly as designed, that's why it's not reaaly an 'issue'.

I can use next / prev, works fine but is less 'natural'.

I'll probably tweak the program myself, and if I ever find something better I'll post a pull request.

Anyway thanks for the work !

Keep tiled window ratio

I have two monitors. The left one has a resolution of 1920x1080 pixels and the right one has a resolution of 1366x768 pixels.

Currently, if a window is tiled in one screen, say to the right of the right monitor, and then it's moved to the left screen, the window is not tiled any more. Its vertical size correctly adapts to the screen size, however its horizontal size doesn't change to account for the difference in screen resolution. Also it isn't positioned at the edge of the screen anymore. See screenshots below.

  • Example case 1:

Window tiled to the right of the right monitor.

Screenshot_2019-09-09_12-09-22

Window is not tiled when moved to the left monitor and has wrong horizontal ratio for this monitor.

Screenshot_2019-09-09_12-08-28

  • Example case 2:

Window tiled to the right of the left monitor.

Screenshot_2019-09-09_12-09-02

Window is not tiled when moved to the right monitor and has wrong horizontal ratio for this monitor.

Screenshot_2019-09-09_12-09-13

  • Expected behavior.

Window tiled to the right of the right monitor.

Screenshot_2019-09-09_12-08-10

Window is still tiled when moved to the left monitor and has the correct horizontal ratio for this monitor.

Screenshot_2019-09-09_12-09-02

Problem moving windows when monitors only "touch" at one corner

screenshot_2018-10-09_17-40-14
screenshot_2018-10-09_17-39-48

In the pictures you see two monitor placements. For one moving windows works (when monitors are touching at one border).
The other monitor configuration (where monitors touch only at one corner) does not work for moving windows.

Why only touch at one corner?

  1. If monitors touch at one side instead of corner: the mouse cursor unintentionally moves to the second monitor.
  2. If monitors touch at one side instead of corner: snapping windows to one side of a monitor does not work since snapping will result in moving the window to the next monitor

I would prefer this setup (although I don't know if this is possible):
Monitors are fully isolated.
There is no way to move the mouse pointer or a window manually to the second monitor.
The only way to move the mouse pointer of between monitors is using movescreen.py and a keyboard shortcut.

Is there a way to set it up like this?

Skips first monitor

I have 5 monitors. The first monitor in xrandr's output is being skipped. (It is the 4th monitor left to right, but judging on who the windows move, it is skipping the first one in the lsit).
xrandr output:
Screen 0: minimum 8 x 8, current 10160 x 1440, maximum 16384 x 16384
DP-0 connected 1440x900+7280+540 (normal left inverted right x axis y axis) 408mm x 255mm
1440x900 59.89*+
1280x1024 75.02 60.02
1280x960 60.00
1152x720 60.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 connected 1440x900+8720+540 (normal left inverted right x axis y axis) 408mm x 255mm
1440x900 59.89*+
1280x1024 75.02 60.02
1280x960 60.00
1152x720 60.00
1024x768 75.03 60.00
800x600 75.00 60.32
640x480 75.00 59.94
DP-4 disconnected (normal left inverted right x axis y axis)
DP-5 connected 3440x1440+3840+0 (normal left inverted right x axis y axis) 800mm x 335mm
3440x1440 59.97*+ 29.99
2560x1440 59.95
2560x1080 59.98
2048x1152 60.00
1920x1200 59.88
1920x1080 60.00 59.94 50.00
1680x1050 59.95
1600x1200 60.00
1280x1024 75.02 60.02
1280x800 59.81
1280x720 59.94 50.00
1152x864 75.00
1024x768 75.03 60.00
800x600 75.00 60.32
720x576 50.00
720x480 59.94
640x480 75.00 59.94 59.93
DP-6 disconnected (normal left inverted right x axis y axis)
DP-7 disconnected (normal left inverted right x axis y axis)
DVI-I-4-4 disconnected (normal left inverted right x axis y axis)
DVI-I-3-3 disconnected (normal left inverted right x axis y axis)
DVI-I-1-1 connected 1920x1080+0+360 (normal left inverted right x axis y axis) 598mm x 336mm
1920x1080 60.00*+ 50.00 59.94
1680x1050 59.88
1280x1024 75.02 60.02
1440x900 59.90
1280x960 60.00
1280x720 60.00 50.00 59.94
1024x768 75.03 70.07 60.00
832x624 74.55
800x600 72.19 75.00 60.32 56.25
720x576 50.00
720x480 60.00 59.94
640x480 75.00 72.81 66.67 60.00 59.94
720x400 70.08
DVI-I-2-2 connected 1920x1080+1920+360 (normal left inverted right x axis y axis) 0mm x 0mm
1280x1024 60.02 +
1920x1200 59.88
1920x1080 60.00*
1600x1200 60.00
1680x1050 59.95
1440x900 59.89
1366x768 59.88
1280x720 60.00
1024x768 60.00
800x600 72.19 75.00 60.32
720x480 59.71
640x480 59.94
1920x1080 (0x294) 148.500MHz +HSync +VSync
h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz
v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz
1920x1080 (0x296) 148.500MHz +HSync +VSync
h: width 1920 start 2448 end 2492 total 2640 skew 0 clock 56.25KHz
v: height 1080 start 1084 end 1089 total 1125 clock 50.00Hz
1280x1024 (0x27f) 135.000MHz +HSync +VSync
h: width 1280 start 1296 end 1440 total 1688 skew 0 clock 79.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 75.02Hz
1280x1024 (0x280) 108.000MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1280x960 (0x281) 108.000MHz +HSync +VSync
h: width 1280 start 1376 end 1488 total 1800 skew 0 clock 60.00KHz
v: height 960 start 961 end 964 total 1000 clock 60.00Hz
1280x720 (0x29b) 74.250MHz +HSync +VSync
h: width 1280 start 1720 end 1760 total 1980 skew 0 clock 37.50KHz
v: height 720 start 725 end 730 total 750 clock 50.00Hz
1024x768 (0x283) 78.750MHz +HSync +VSync
h: width 1024 start 1040 end 1136 total 1312 skew 0 clock 60.02KHz
v: height 768 start 769 end 772 total 800 clock 75.03Hz
1024x768 (0x284) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x285) 49.500MHz +HSync +VSync
h: width 800 start 816 end 896 total 1056 skew 0 clock 46.88KHz
v: height 600 start 601 end 604 total 625 clock 75.00Hz
800x600 (0x286) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
720x576 (0x29d) 27.000MHz -HSync -VSync
h: width 720 start 732 end 796 total 864 skew 0 clock 31.25KHz
v: height 576 start 581 end 586 total 625 clock 50.00Hz
720x480 (0x29e) 27.000MHz -HSync -VSync
h: width 720 start 736 end 798 total 858 skew 0 clock 31.47KHz
v: height 480 start 489 end 495 total 525 clock 59.94Hz
640x480 (0x287) 31.500MHz -HSync -VSync
h: width 640 start 656 end 720 total 840 skew 0 clock 37.50KHz
v: height 480 start 481 end 484 total 500 clock 75.00Hz
640x480 (0x288) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz
1280x1024 (0x280) 108.000MHz +HSync +VSync
h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz
v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz
1920x1200 (0x293) 193.250MHz -HSync +VSync
h: width 1920 start 2056 end 2256 total 2592 skew 0 clock 74.56KHz
v: height 1200 start 1203 end 1209 total 1245 clock 59.88Hz
1600x1200 (0x298) 162.000MHz +HSync +VSync
h: width 1600 start 1664 end 1856 total 2160 skew 0 clock 75.00KHz
v: height 1200 start 1201 end 1204 total 1250 clock 60.00Hz
1680x1050 (0x297) 146.250MHz -HSync +VSync
h: width 1680 start 1784 end 1960 total 2240 skew 0 clock 65.29KHz
v: height 1050 start 1053 end 1059 total 1089 clock 59.95Hz
1440x900 (0x27e) 106.500MHz -HSync +VSync
h: width 1440 start 1520 end 1672 total 1904 skew 0 clock 55.93KHz
v: height 900 start 903 end 909 total 934 clock 59.89Hz
1280x720 (0x2c7) 74.250MHz +HSync +VSync
h: width 1280 start 1390 end 1430 total 1650 skew 0 clock 45.00KHz
v: height 720 start 725 end 730 total 750 clock 60.00Hz
1024x768 (0x284) 65.000MHz -HSync -VSync
h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz
v: height 768 start 771 end 777 total 806 clock 60.00Hz
800x600 (0x2cb) 50.000MHz +HSync +VSync
h: width 800 start 856 end 976 total 1040 skew 0 clock 48.08KHz
v: height 600 start 637 end 643 total 666 clock 72.19Hz
800x600 (0x285) 49.500MHz +HSync +VSync
h: width 800 start 816 end 896 total 1056 skew 0 clock 46.88KHz
v: height 600 start 601 end 604 total 625 clock 75.00Hz
800x600 (0x286) 40.000MHz +HSync +VSync
h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz
v: height 600 start 601 end 605 total 628 clock 60.32Hz
640x480 (0x288) 25.175MHz -HSync -VSync
h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz
v: height 480 start 490 end 492 total 525 clock 59.94Hz

FileNotFoundError: [Errno 2] No such file or directory: 'xwininfo'

I have installed the script in EndeavourOS (arch-based distro), running XFCE.

I noticed the shortcuts weren't working, so I tried to run it in the terminal, and I got:

 /usr/local/bin  movescreen.py right
Traceback (most recent call last):
  File "/usr/local/bin/movescreen.py", line 95, in <module>
    out = subprocess.check_output(['xwininfo', '-id', id, '-all']).decode('ascii', 'ignore')
  File "/usr/lib/python3.10/subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.10/subprocess.py", line 501, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.10/subprocess.py", line 1845, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'xwininfo'

I hope that helps.
Great script, btw.

Add "previous" and "next" option

I would prefer only on shortcut which I can assign to movescreen.py next which will just moves me through the list of monitors.

Add option to move mouse pointer

I would love to be able to add a shortcut to only move the mouse to the "next" monitor. Something like:

movescreen.py next mouse

Sometimes the window is already on the correct screen, I just want to move the mouse there ;)

Petition to add "maximize" option.

I like it a ton, but it lacks maximization, in my opinion. Fill is useful for some applications/games, but maximization is better for all other cases.

Also, I realized the script just just uses pixels, would be better to change it to a percentage of the screen. So if you have a 1600x900 screen and 1920x1080, and you have something in the middle second screen and you pull it to the 1600x900 one, it now moves to 960x540 pixel position, and it'd be way nicer to have it in 800x450 position. Aka from 50% of 1920x1080 to 50% of 1600x900.

Issue with xmodmap

First, I'd like to thank you for creating this script, it works very well
However I did find an issue with my keyboard. I have a CM Devastator 2 keyboard and i use the following command to make i light up
sudo xmodmap -e 'add mod3 = Scroll_Lock'
I've noticed that when I have the keyboard lit up, the the movescreen.py script doesn't work
As for why, I'm not too sure, but if you require any additional information

OS: Ubuntu
DE: XFCE

Edit: I'll also note that I came across this same issue wit hall the rest of the answers from this stack overflow answer (which is how I found out about your script) https://unix.stackexchange.com/questions/48456/xfce-send-window-to-other-monitor-on-keystroke#198663

Suggest install of dependency 'wmctrl'

First of all, thanks a lot for this script!
To make it work on Deepin, I had to install wmctrl package first.

# apt install wmctrl

According to some random suggestion on the internet, I have to remove a comma too on this line:
id = re.search("window id # (0x[0-9a-f]+)", out).group(1)

Finally, when no monitor is up, the "regular" error I get is:

python movescreen.py left
Traceback (most recent call last):
  File "movescreen.py", line 111, in <module>
    nscr = scr[r[dir][sidx]]
TypeError: list indices must be integers, not NoneType

Perhaps it's better to catch it.

TypeError: list indices must be integers or slices, not float

Hi,

Thank you for this piece of code, works almost perfectly !
I'm back to xfce, finally :)

In my case (maybe due to python version in use : 3.7.1), I get the forementioned error at line 125.
A simple cast to int fixes it.

Here's the quick fix :

-- for xy in [[0], [1], [0,1]][dir_str.index(dir)/2]:

++ for xy in [[0], [1], [0,1]][int(dir_str.index(dir)/2)]:

could maybe even be better with an explicit call to 'floor' function but I didn't want to import 'math' for this,
I tested that casting to int does truncate anyway.

it don't work

/usr/bin/env: ‘python’: No such file or directory

most functional pissthon software

Incompatible with python3

A print statement on line 30 makes it so the program is no longer
compatible with python3.

$ ./movescreen2.py left
  File "./movescreen2.py", line 30
    print arg
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(arg)?

Patch is pretty simple

-     print arg
+     print(arg)

Although you should also probably delete this line.
After deleting it it seems to work, tested on two screens

[Errno 2] No such file or directory: 'xwininfo': 'xwininfo'

I'm getting the following error for some reason:
Traceback (most recent call last):
File "/usr/local/bin/movescreen.py", line 86, in
out = subprocess.check_output(['xwininfo', '-id', id, '-all']).decode('ascii', 'ignore')
File "/home/biographie/anaconda3/lib/python3.7/subprocess.py", line 395, in check_output
**kwargs).stdout
File "/home/biographie/anaconda3/lib/python3.7/subprocess.py", line 472, in run
with Popen(*popenargs, **kwargs) as process:
File "/home/biographie/anaconda3/lib/python3.7/subprocess.py", line 775, in init
restore_signals, start_new_session)
File "/home/biographie/anaconda3/lib/python3.7/subprocess.py", line 1522, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'xwininfo': 'xwininfo'

I have installed xwininfo and tried re-running the command, but still getting this error

Suggestion to solve 'first run' latency

Hi,

I was wondering about the 'first run' being slow as you mention in the README.

What I see in my case is that : it's slow at first call, then it's damn fast ... but only for a few seconds.
I mean : if I keep moving window around : it stays fast.
If I do nothing for, say, 10 seconds, then I call it again : slow again.
I thought it could be related to python being interpreted, so I compiled it and called the .pyc ... exact same behaviour.

After some experiment, it would appeat that it's the call to xrandr that causes the issue : indeed I can see the exact same behaviour when I loop-call xrandr command.

Then, I came accross another nifty utility called 'srandrd', you can find it on github.
It does listen to xrandr events.

So, what came to my mind would be :

  • use srandrd to create an 'xrandr' command output cache ( simply xrandr > file.txt)
  • make move-screen read this cache when available

I don't know if you already tried something to improve speed,
I'll give this idea a try and let you know.

I fear it won't be as reliable as calling xrandr each time, maybe would then need another argumebnt to force ignore cache file ... things like that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.