SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2015-08-28 19:14:26

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Python coder needed for bl-aerosnap script!

Calling all python coders!

Due to various problems with bl-aerosnap (which is actually the cb-aerosnap that was included in Waldorf), it has been decided that it will be dropped from rc.xml in BunsenLabs, until the issues have been fixed.

The script will still be included, but the keybinds will no longer be there.

Bug issues on github are as follows:

1) bl-aerosnap fails if window is undecorated
    Probably because the window size isn't including the frame borders added by the WM
   
2) Repeated snapping causes a cumulative offset
    Same as 1) I think
   
3) aerosnap limping on deprecated syntax
(Apologies to @junkmechanic, but that patch hasn't been included yet)

And also
4) User-defined Openbox screen margins aren't honoured

So if there is anyone who would like to have a go at fixing these problems, then please do so smile

The script is in Waldorf as cb-aerosnap, and in BL as bl-aerosnap;
or get it from github: https://raw.githubusercontent.com/Bunse … l-aerosnap


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

Help fund CrunchBang, donate to the project!

#2 2015-08-29 11:43:58

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

I'm not really a python coder, but I'll have a go at this because it seems fun smile

Besides the issues you mention, I'll look into actually using Xlib instead of spawning so many subprocesses for such simple tasks. I'll fork the utilities repository soon and will push my changes there for you to follow, comment and test.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#3 2015-08-29 17:15:12

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: Python coder needed for bl-aerosnap script!

Just change the line

#!/usr/bin/env python

to

#!/usr/bin/env python2

Offline

#4 2015-08-29 17:19:41

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

Lol wut? That might solve the syntax issues, but not the rest.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#5 2015-08-29 18:07:21

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: Python coder needed for bl-aerosnap script!

Unia wrote:

Lol wut? That might solve the syntax issues, but not the rest.

If bl-aerosnap is just the same as cb-aerosnap, then it should work. This script doesn't like python 3. smile

Offline

#6 2015-08-29 18:11:11

brontosaurusrex
#! Red Menace
Registered: 2012-06-15
Posts: 1,643

Re: Python coder needed for bl-aerosnap script!

Is there a readme/reminder on what is this script supposed to do? (No, I do not remember)

Last edited by brontosaurusrex (2015-08-29 18:11:28)

Offline

#7 2015-08-29 18:29:44

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

It's a script for adding aero style window snapping to Openbox, or any window manager now really. As long as it is somewhat EWMH compliant (my new version uses _NET_ACTIVE_WINDOW and _NET_WM_PID only)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#8 2015-08-29 18:35:29

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

I just forked the repository and pushed my changes: https://github.com/Unia/bunsen-utilities

It mostly works, but I haven't tried this with Openbox yet. Scan the source code to see the remaining issues, they're marked by FIXMEs and TODOs. As for damo's original issues, I believe #3 is fixed now. #2 I'm not sure of, since the restore option is not properly working, but I think it is solved as well. EDIT: #2 is solved as well. Have not yet tried issue #1.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#9 2015-08-29 18:37:05

hhh
Cityspeak
Registered: 2010-08-04
Posts: 3,253

Re: Python coder needed for bl-aerosnap script!

Unia wrote:

aero style window snapping to Openbox, or any window manager now really.

So, OOTB, W-A-left or W-A-right resizes the active window to full height and 50% screen width and snaps it to the left or right edge, repeating the keybind returns it to the original position and size.


bunsenlabs     8)     forum mod squad

Offline

#10 2015-08-29 19:04:02

hhh
Cityspeak
Registered: 2010-08-04
Posts: 3,253

Re: Python coder needed for bl-aerosnap script!

Just a thought, Xfwm 4.10 allows both tiling vertically and horizontally via keyboard shortcuts and, if window wrapping is disabled, dragging to the screen edge, and IIRC 4.12 added tiling to the corners (in other words 1/4 screen). I have no idea how they implement this, but it's worth investigating.


bunsenlabs     8)     forum mod squad

Offline

#11 2015-08-29 19:17:03

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

^ Shouldn't be too hard to add in the new version. I might have a go at it once I have the current issues sorted out.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#12 2015-08-29 19:41:49

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: Python coder needed for bl-aerosnap script!

I didn't have cb-aerosnap installed, but did so to try it out, to see if it gives a problem. Aerosnap clicks to left or right, but when returning, the script has a problem. It returns to a lower position.

Otherwise, we can use a different set of keybinds to snap the window to left, right, top or down, only it won't return it to former position.

Crunchbang scripts were written for python2, and with env, they conflict with python3.

unia wrote:

I just forked the repository and pushed my changes: https://github.com/Unia/bunsen-utilities

Tried yours too. Didn't work.

/usr/bin/bl-aerosnap: linia 13: from: command not found
/usr/bin/bl-aerosnap: line 14: import: command not found
/usr/bin/bl-aerosnap: line 16: WINDOWS: command not found
/usr/bin/bl-aerosnap: line 20: class: command not found
/usr/bin/bl-aerosnap: line 21: syntax error when an unexpected tag `('
/usr/bin/bl-aerosnap: line 21: `    Left, Right = range(2)'

Last edited by ostrołęk (2015-08-30 09:47:27)

Offline

#13 2015-08-29 22:16:56

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

^ That is strange. Can you try the latest version, and tell me exactly how you got the script and ran it?

I just finished implementing python3 support also, so it does not matter anymore whether your system default is python2 or python3. Note that the python-xlib packages are different for python2 and python3, so make sure you have the correct ones installed.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#14 2015-08-29 22:45:49

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

I just pushed my latest progress. See the TODO in the top of the file and the FIXMEs/TODOs in the source code below to see what needs to be done if you want to help out and have a go. It's not much; I believe all damo's issues are resolved (including #4). The only remaining issue it that the restore is still somewhat flaky (the x and y coordinates are wrong, for some unknown reason)

One more feature that would be nice to have is also listed in the top TODO:

when using --right and then deciding you wanted --left instead, your window is restored instead of moved to the left. Perhaps we can store the direction in the dictionary too and only restore if the direction is the same...

Oh, and since I don't usually program in Python, my code might not be idiomatic. I ran pylint and fixed most of its issues, but if you are a Python programmer and spot something that can be improved, please send me a pull request or let me know! wink

I'm off for the night now smile


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#15 2015-08-30 06:39:11

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: Python coder needed for bl-aerosnap script!

Unia wrote:

^ That is strange. Can you try the latest version, and tell me exactly how you got the script and ran it?

When you updated your git repo, I just copied the script, saved it to /usr/bin as bl-aerosnap, gave executive permissions and enabled it. Before using it, I took away the cb-aerosnap file from /usr/bin. Checked your script with bl-aerosnap --help. It didn't start, so did bl-aerosnap. The result I posted.

I don't really need aerosnap, as I have keybindings to move windows half way up, down, left and right in rc.xml, but I tested it for you. smile

Edit: cb-aerosnap works OK, only it returns to a lower position.

Edit2: tried your new bl-aerosnap, the result is;

/usr/bin/bl-aerosnap: line 20: from: command not found
/usr/bin/bl-aerosnap: line 21: import: command not found
/usr/bin/bl-aerosnap: line 23: WINDOWS: command not found
/usr/bin/bl-aerosnap: line 26: syntax error when an unexpected tag `('
/usr/bin/bl-aerosnap: line 26: `class Snap(object):'

Last edited by ostrołęk (2015-08-30 09:46:52)

Offline

#16 2015-08-30 10:57:50

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

Again, how exactly do you get and run the script? I need commands used, not "I tried it, here is the result".


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#17 2015-08-30 15:56:46

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

hhh wrote:

Just a thought, Xfwm 4.10 allows both tiling vertically and horizontally via keyboard shortcuts and, if window wrapping is disabled, dragging to the screen edge, and IIRC 4.12 added tiling to the corners (in other words 1/4 screen). I have no idea how they implement this, but it's worth investigating.

I just added --top and --bottom options to bl-aerosnap. As you can see, it is really easy to add new modes: https://github.com/Unia/bunsen-utilitie … daa223539b

Do we also want to support the four screen corners?


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#18 2015-08-30 16:23:52

ostrołęk
CB Member
Registered: 2015-08-13
Posts: 110

Re: Python coder needed for bl-aerosnap script!

Unia wrote:

Again, how exactly do you get and run the script? I need commands used, not "I tried it, here is the result".

Copy bl-aerosnap from your github, paste in geany, name it bl-aerosnap, give permission to run as a program, put it in /usr/bin, add the following lines to your rc.xml

<keybind key="W-A-Left">
    <action name="Execute">
        <command>bl-aerosnap --left</command>
    </action>
</keybind>
<keybind key="W-A-Right">
    <action name="Execute">
        <command>bl-aerosnap --right</command>
    </action>
</keybind>

run the daemon, reconfigure openbox, and try the keybinds.
It didn't work, when running the daemon.
So, to find out what's not happening,

$ bl-aerosnap

and got the results, which I gave in the earlier post. This is the same as bl-aerosnap --daemon

Did the same thing with the old cb-aerosnap, and it worked, but with a small problem of returning to the same position, that is, the window returned to a position lower than it was before. W-A-Right it goes right, fills 50% window, click the same W-A-Right or W-A-Left, the window goes back to the former size, but to a lower position.

Note: bl-aerosnap in BusenLabs github repo is the same as cb-aerosnap in the old crunchbang. To use this bl-aerosnap, you have to change the first line #!/usr/bin/env python to #!/usr/bin/env python2.

Last edited by ostrołęk (2015-08-30 16:48:13)

Offline

#19 2015-08-30 17:45:43

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: Python coder needed for bl-aerosnap script!

Thanks for working on this @Unia, I'll check it out as soon as I can.

The offset error when restoring is due to (I think) the saved X/Y position not taking the window borders into account. so the window moves down a few px.

BTW I've got a bash version working, which solves all the problems, and also works with dual monitors (window snaps to edge of the screen it is on), and honours openbox margins. Terminal windows are still a bit buggy though (they restore 1 or 2px too small).


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#20 2015-08-30 17:47:50

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

damo wrote:

Terminal windows are still a bit buggy though (they restore 1 or 2px too small).

Terminals usually don't resize per pixel, but rather per column. You can disable this behaviour in URxvt, I believe. It will not work in any vte based terminal, at least. Another way around this would be to make your window manager ignore size hints, as DWM can do - but generally this is not the solution you want (not to mention it is impossible for us to hack Openbox and distribute it in BunsenLabs tongue)

I'll take a look at your bash version smile


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#21 2015-08-30 17:54:44

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: Python coder needed for bl-aerosnap script!

I was going to investigate the xprops WM_SIZE_HINTS and see if they could be used. (gnome-terminal is the only one I've found that works like a regular window BTW)


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#22 2015-08-30 18:46:45

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: Python coder needed for bl-aerosnap script!

@Unia

First feedback on your script....

1) Left/right screen margins set by obconf aren't there when snapping left/right;
2) Great idea for top/bottom snapping BTW, but it isn't consistent, and covers tint2.
   I guess "_NET_WM_STATE_MAXIMIZED_VERT" refers to the screen, not the useable area as used by openbox?
   (wmctrl uses "maximized_vert/maximized_horz", which doesn't cover the panels in openbox)


PS: I started playing with bl-aerosnap because of someone wanting to keep a side panel uncovered. I got it working with a margin passed as a command arg, but then ran into all the bugs we have been discussing, and decided to leave it to someone who is more familiar with python wink


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

#23 2015-08-30 19:35:50

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

daemo wrote:

1) Left/right screen margins set by obconf aren't there when snapping left/right;

I'm not sure what is going wrong here; the top/bottom margings do work.

damo wrote:

2) Great idea for top/bottom snapping BTW, but it isn't consistent, and covers tint2.
   I guess "_NET_WM_STATE_MAXIMIZED_VERT" refers to the screen, not the useable area as used by openbox?
   (wmctrl uses "maximized_vert/maximized_horz", which doesn't cover the panels in openbox)

How is it not consistent? I missed unsetting _NET_WM_STATE_MAXIMIZED_HORZ upon restoring the window (fixed now), but otherwise it is consistent to me.

These _NET_WM things can be seen as messages to the window manager. The window manager is also the process that decides to honor or ignore other applications' requests for space, e.g. tint2 or Openbox' margins. Therefore, it is up to the window manager to handle these things correctly. If it doesn't, it is a bug and should be reported to the respective window manager. So _NET_WM_STATE_MAXIMIZED_VERT means nothing more than to ask the window manager to maximize the window vertically in the space/work area it has left when honoring other applications' margins.

In any case, my tint2 panel is only covered when I place it vertically on the left or right edge of my screen. Not when snapping to the bottom or the top. I guess this is the same issue as Openbox' left/right margins not working properly. Will investigate...

Thank you for your feedback!


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

#24 2015-08-30 20:40:28

damo
#! gimpbanger
From: N51.5 W002.8 (mostly)
Registered: 2011-11-24
Posts: 5,434

Re: Python coder needed for bl-aerosnap script!

Using 4f57a4f
Testing on laptop (Bunsenified jessie, 1366x768):
(Error in my previous post - I meant "behind tint2". )
--top only goes to about 20% from the top of the screen (it worked the first time, but not subsequently???)
--bottom goes to the bottom screen edge ie behind tint2
left/right margins not honouring OB settings

Testing on Desktop (sid) 1920x1080 dual monitors (I have to disable one monitor to test it, obviously):
--top/--bottom going to screen edges ie behind top and bottom tint2s
left/right margins not honouring OB settings

Testing in BunsenLabs VM:

  if get_window_id(ewmh,active_win) in WINDOWS:
TypeError: argument of type 'int' is not iterable

I guess this is due to an EWMH import error (missing module?)


BunsenLabs Group on deviantArt
damo's gallery on deviantArt
Openbox themes
Forum Moderator smile

Offline

Help fund CrunchBang, donate to the project!

#25 2015-08-30 21:11:11

Unia
#! Octo-portal-pussy
From: The Netherlands
Registered: 2010-07-17
Posts: 4,634
Website

Re: Python coder needed for bl-aerosnap script!

I just figured out why it runs differently for you and I. You're using your system default python, python2 in your case. I run my system default, python3. The xlib modules for both versions are different, and in the python2 case, behave incorrectly. The script will work correctly if you install the python3 xlib module (python-xlib package, I believe).

Scratch that, it's not it. But please do test, anyway. To be sure tongue

The "--top only goes to 20% from the top of the screen" might be related to what I posted on GitHub. I'm not sure what that is, and it appears only sometimes. The coordinates printed in the terminal are correct.

The left/right margins are a confirmed bug. Multimonitor support is something I haven't worked on, but I will look into it once single monitors work correctly.

damo wrote:

Testing in BunsenLabs VM:

  if get_window_id(ewmh,active_win) in WINDOWS:
TypeError: argument of type 'int' is not iterable

I guess this is due to an EWMH import error (missing module?)

That is an interesting issue. Is python2-xlib installed? There is no EWMH import, it is a class defined in the script itself. Can I see the complete error message?


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

I am a #! forum moderator. Feel free to send me a PM with any question you have!

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.
Server: acrobat

Debian Logo