Xfce Forum

Sub domains
 

You are not logged in.

#1 2021-08-18 11:34:19

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

I want to create a advanced window snapping app for XFCE

Update 2021-08-21

An early version is available for testing. The app is called `Xlap` pronounced `slap`. Available here: https://gitlab.com/sri-at-gitlab/projects/xlap

Next is to refine it and make it release-worthy. Feedback welcome!

------------

TL;DR version (As seen on IRC): "Good day all, If I was to programmatically manipulate (tile/resize) windows in XFCE/XFWM in Python, are there any libraries I could rely on? "

Long version (As seen on Reddit)

I absolutely detest Mac OS. It is terrible in every way.[1]



Windows is tolerable as a non-work gaming OS. Nothing more.

KDE is good. As is Gnome, as a laptop OS.

But man, XFCE is just love. XFCE is near perfect.

Back to Mac OS. There's only one App I miss from the vast Mac OS app ecosystem. It is this: https://rectangleapp.com/

This is not unique to Mac OS. Windows, KDE and Gnome also have advanced window snapping features.

XFCE has basic Window tiling. Left-half. Right-half. Bottom-half. Top-half. And I use them.

However, before I buy a massive ultra-wide display, I would like to build an app of suitable quality so that I can configure window snapping / tiling for XFWM.

In order to undertake this quest, I need your help.

Can you point this good-enough[2] developer to the library that can control all windows in XFWM?

[1] In my humble opinion

[2] As confirmed by an employer that considers me worthy of a good-enough[3] paycheck

[3] good-enough as rated by a woman who owns me and all of my material wealth

Last edited by sri19 (2021-08-21 09:17:18)


Make stuff. Build things.

Offline

#2 2021-08-18 13:07:50

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 8,040

Re: I want to create a advanced window snapping app for XFCE

There already exist a number of solutions to enable advance window snapping in Xfce:
- https://github.com/dodophoenix/xfce-tile (python)
- https://github.com/eraserhead1897/xf-tile (python)
- https://github.com/blrsn/zentile (go)
- https://github.com/jalovatt/percenttile (shell script)

I'm sure there are more, but these are the ones I could find easily. If you search these forums for tiling script you may find some more.
Maybe one of them will fit the bill, or you can base your development around one of them?

Online

#3 2021-08-19 20:04:47

Skaperen
Member
From: right by Jesus, our Saviour
Registered: 2013-06-15
Posts: 558

Re: I want to create a advanced window snapping app for XFCE

what kind of snapping do you plan to do?  top to full screen?  screen edge placement?  adjacent window placement?  window grid alignment?

Offline

#4 2021-08-21 09:10:48

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

Re: I want to create a advanced window snapping app for XFCE

An early version is available for testing. The app is called `Xlap` pronounced `slap`. Available here: https://gitlab.com/sri-at-gitlab/projects/xlap

Next is to refine it and make it release-worthy. Feedback welcome!


Make stuff. Build things.

Offline

#5 2021-08-21 09:11:49

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

Re: I want to create a advanced window snapping app for XFCE

Skaperen wrote:

what kind of snapping do you plan to do?  top to full screen?  screen edge placement?  adjacent window placement?  window grid alignment?

Xlap supports the following window layouts:

    FULL_SCREEN = 'Full Screen'
    MAXIMIZED = 'Maximized'
    ALMOST_MAXIMIZED = 'Almost Maximized'

    COL_50_LEFT = '50% Left Column'
    COL_50_RIGHT = '50% Right Column'

    COL_66_LEFT = '66% Left Column'
    COL_66_RIGHT = '66% Right Column'

    COL_33_LEFT = '33% Left Column'
    COL_33_CENTER = '33% Center Column'
    COL_33_RIGHT = '33% Right Column'

    ROW_50_TOP = '50% Top Row'
    ROW_50_BOTTOM = '50% Bottom Row'

    ROW_66_TOP = '66% Top Row'
    ROW_66_BOTTOM = '66% Bottom Row'

    ROW_33_TOP = '33% Top Row'
    ROW_33_CENTER = '33% Center Row'
    ROW_33_BOTTOM = '33% Bottom Row'

    CELL_50_LEFT_TOP = '50% Left Top Cell'
    CELL_50_LEFT_BOTTOM = '50% Left Bottom Cell'

    CELL_50_RIGHT_TOP = '50% Right Top Cell'
    CELL_50_RIGHT_BOTTOM = '50% Right Bottom Cell'

    CELL_33_LEFT_TOP = '33% Left Top Cell'
    CELL_33_LEFT_CENTER = '33% Left Center Cell'
    CELL_33_LEFT_BOTTOM = '33% Left Bottom Cell'

    CELL_33_CENTER_TOP = '33% Center Top Cell'
    CELL_33_CENTER_CENTER = '33% Center Center Cell'
    CELL_33_CENTER_BOTTOM = '33% Center Bottom Cell'

    CELL_33_RIGHT_TOP = '33% Right Top Cell'
    CELL_33_RIGHT_CENTER = '33% Right Center Cell'
    CELL_33_RIGHT_BOTTOM = '33% Right Bottom Cell'


Make stuff. Build things.

Offline

#6 2021-08-21 09:14:47

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

Re: I want to create a advanced window snapping app for XFCE

ToZ wrote:

There already exist a number of solutions to enable advance window snapping in Xfce:
- https://github.com/dodophoenix/xfce-tile (python)
- https://github.com/eraserhead1897/xf-tile (python)
- https://github.com/blrsn/zentile (go)
- https://github.com/jalovatt/percenttile (shell script)

I'm sure there are more, but these are the ones I could find easily. If you search these forums for tiling script you may find some more.
Maybe one of them will fit the bill, or you can base your development around one of them?

Thanks ToZ, this list was certainly useful, but I went a slightly different route.

It's not a tiling-script per se, but a Window snapping tool. That means it would not automatically position all open windows, but rather allow to user to apply pre-defined layouts. With an indicator menu, keyboard shortcuts, multi monitor / display support etc.

Would love your feedback, I'll spend the next week refining the user-experience and making a first release. https://gitlab.com/sri-at-gitlab/projects/xlap

Last edited by sri19 (2021-08-21 09:17:51)


Make stuff. Build things.

Offline

#7 2021-08-22 02:56:55

Misko_2083
Member
Registered: 2015-10-13
Posts: 163
Website

Re: I want to create a advanced window snapping app for XFCE

In Debian 11 repository there is only gir1.2-ayatanaappindicator3-0.1

sudo apt install gir1.2-ayatanaappindicator3-0.1 xdotool

In file "indicator" I had to change all instances of AppIndicator3 to AyatanaAppIndicator3 to make it work.
Pynput can be grabbed only with pip

sudo apt install python3-pip
pip install pynput

All the lines with

#!/usr/bin/env python

had to be changed

#!/usr/bin/env python3

Now there is a monkey face icon in the indicator.
Fullscreen and maximized doesn't work. With wmctrl it does work:

#Maximize
wmctrl -ir $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) -b add,maximized_vert,maximized_horz
#Unmaximize
wmctrl -ir $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) -b remove,maximized_vert,maximized_horz

But that's ok ,you must have a newer version of xdotool in that distro than version 3.20160805.1.
With Xlib it wouldn't depend on xdotool.
Package is python3-xlib in debian repo.

"Almost maximize" works but it's better to position it inside the workarea or it may go under the panel if the panel has multiple rows or the panel size iz big.

xprop -root _NET_WORKAREA

Which is now confirmed, windows are placed behind the bottom panel in bottom cells.

All in all it's a good idea.

Last edited by Misko_2083 (2021-08-22 03:18:05)

Offline

#8 2021-08-22 03:58:50

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

Re: I want to create a advanced window snapping app for XFCE

Misko_2083 wrote:

In Debian 11 repository there is only gir1.2-ayatanaappindicator3-0.1

sudo apt install gir1.2-ayatanaappindicator3-0.1 xdotool

In file "indicator" I had to change all instances of AppIndicator3 to AyatanaAppIndicator3 to make it work.
Pynput can be grabbed only with pip

sudo apt install python3-pip
pip install pynput

All the lines with

#!/usr/bin/env python

had to be changed

#!/usr/bin/env python3

Now there is a monkey face icon in the indicator.
Fullscreen and maximized doesn't work. With wmctrl it does work:

#Maximize
wmctrl -ir $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) -b add,maximized_vert,maximized_horz
#Unmaximize
wmctrl -ir $(xprop -root 32x '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) -b remove,maximized_vert,maximized_horz

But that's ok ,you must have a newer version of xdotool in that distro than version 3.20160805.1.
With Xlib it wouldn't depend on xdotool.
Package is python3-xlib in debian repo.

"Almost maximize" works but it's better to position it inside the workarea or it may go under the panel if the panel has multiple rows or the panel size iz big.

xprop -root _NET_WORKAREA

Which is now confirmed, windows are placed behind the bottom panel in bottom cells.

All in all it's a good idea.

Thanks for the detailed feedback Misko.

I'm on an Arch variant thus I had all the dependencies (and their latest versions) available from the default package manager.

But .. I'd love to have as broad of a support as possible

I'll look into ayatana appindicator, python-xlib, NET_WORKAREA and replacing the xdotool with wmctrl for maximize and full screen.


Make stuff. Build things.

Offline

#9 2021-08-22 09:36:22

Misko_2083
Member
Registered: 2015-10-13
Posts: 163
Website

Re: I want to create a advanced window snapping app for XFCE

sri19 wrote:

Thanks for the detailed feedback Misko.

I'm on an Arch variant thus I had all the dependencies (and their latest versions) available from the default package manager.

But .. I'd love to have as broad of a support as possible

I'll look into ayatana appindicator, python-xlib, NET_WORKAREA and replacing the xdotool with wmctrl for maximize and full screen.

Well you can try to import either AppIndicato3 or AyatanaAppIndicator3:

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

def module_exists(module_name):
    try:
        gi.require_version(module_name, '0.1')
    except:
        return False
    else:
        return True

if module_exists('AppIndicator3'):
    from gi.repository import AppIndicator3
elif module_exists('AyatanaAppIndicator3'):
    from gi.repository import AyatanaAppIndicator3 as AppIndicator3
else:
    print('Requires either AppIndicator3 or AyatanaAppIndicator3')

Relevant line is here. https://gitlab.com/sri-at-gitlab/projec … icator#L12
The difference is only in the name of the module. big_smile

Workarea is in freedesktop specifications. https://specifications.freedesktop.org/ … 3294079184
Panels create struts and window manager calculates workarea and writes it to root window property _NET_WORKAREA.

xprop -root

Last edited by Misko_2083 (2021-08-22 09:56:24)

Offline

#10 2021-08-22 14:58:40

mint4all
Member
From: out of sight
Registered: 2018-08-21
Posts: 188

Re: I want to create a advanced window snapping app for XFCE

sri19 wrote:

However, before I buy a massive ultra-wide display, I would like to build an app of suitable quality so that I can configure window snapping / tiling for XFWM.

In order to undertake this quest, I need your help.
Can you point this good-enough[2] developer to the library that can control all windows in XFWM?

[1] In my humble opinion
[2] As confirmed by an employer that considers me worthy of a good-enough[3] paycheck
[3] good-enough as rated by a woman who owns me and all of my material wealth

Greetings!

With utmost respect for the work you've already done / effort you've put into this project, you may want to look at "x-tile". It is written in python3 (99% anyway), uses gnome's "glade" tool for its setup-GUI, and was originally written by developer of the "cherrytree" note-taking app (which i've used for many yaers). The app is community maintained, handles multiple monitors & geometries, and has great flexibility for full- & partial-tiling.

It is decomented @ https://www.giuspen.com/x-tile/ and its source is located @ https://github.com/giuspen/x-tile ... If nothing else, you might get some additional ideas for your project, or use it as a good starting point for your own enhancements.

Cheers, m4a


Linux Mint 18.3, 19.3, 20.2 -- xfce 4.12 / 4.14 / 4.16 ... Apple iMAC -- Dell & HP Desktops -- Toshiba, Dell & HP Laptops -- Family & Community Support

Offline

#11 2021-08-22 16:26:13

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

Re: I want to create a advanced window snapping app for XFCE

mint4all wrote:

Greetings!

With utmost respect for the work you've already done / effort you've put into this project, you may want to look at "x-tile". It is written in python3 (99% anyway), uses gnome's "glade" tool for its setup-GUI, and was originally written by developer of the "cherrytree" note-taking app (which i've used for many yaers). The app is community maintained, handles multiple monitors & geometries, and has great flexibility for full- & partial-tiling.

It is decomented @ https://www.giuspen.com/x-tile/ and its source is located @ https://github.com/giuspen/x-tile ... If nothing else, you might get some additional ideas for your project, or use it as a good starting point for your own enhancements.

Cheers, m4a

Thanks for your comment mint4all. Shucks .. Your comment is four days too late! sad

x-tile looks pretty cool, but now Xlap is nearly ready and _perfect_ for my personal use-case.

The difference is just this:

x-tile automatically tiles all open windows based on layout
vs.
Xlap snaps the active window to a layout upon user instruction (hotkey or indicator menu)

Obviously, as shared in my original post, I've based this user-experience off the highly popular Rectangle Mac OS application.

But thank you still for sharing x-tile. I will look into that for further inspiration and clarity.

Who knows, maybe I eventually need an automatic tiling of all open windows?


Make stuff. Build things.

Offline

#12 2021-08-22 16:48:03

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

Re: I want to create a advanced window snapping app for XFCE

Misko_2083 wrote:
sri19 wrote:

Thanks for the detailed feedback Misko.

I'm on an Arch variant thus I had all the dependencies (and their latest versions) available from the default package manager.

But .. I'd love to have as broad of a support as possible

I'll look into ayatana appindicator, python-xlib, NET_WORKAREA and replacing the xdotool with wmctrl for maximize and full screen.

Well you can try to import either AppIndicato3 or AyatanaAppIndicator3:

gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

def module_exists(module_name):
    try:
        gi.require_version(module_name, '0.1')
    except:
        return False
    else:
        return True

if module_exists('AppIndicator3'):
    from gi.repository import AppIndicator3
elif module_exists('AyatanaAppIndicator3'):
    from gi.repository import AyatanaAppIndicator3 as AppIndicator3
else:
    print('Requires either AppIndicator3 or AyatanaAppIndicator3')

Relevant line is here. https://gitlab.com/sri-at-gitlab/projec … icator#L12
The difference is only in the name of the module. big_smile

Workarea is in freedesktop specifications. https://specifications.freedesktop.org/ … 3294079184
Panels create struts and window manager calculates workarea and writes it to root window property _NET_WORKAREA.

xprop -root

Thank you, I applied the AyanaAppIndicator3 related changes.

I'll read up on NET_WORKAREA .. Specifically for the case of multiple displays where one has panels and another hasn't.


Make stuff. Build things.

Offline

#13 2021-08-26 18:50:37

jaywilkas
Member
Registered: 2021-06-05
Posts: 7

Re: I want to create a advanced window snapping app for XFCE

Perhaps take a look at  xpytile

xpytile is a pure Python script which can auto-tile windows and simulateously resize side-by-side (docked) windows.

Offline

#14 2021-08-27 08:35:14

Misko_2083
Member
Registered: 2015-10-13
Posts: 163
Website

Re: I want to create a advanced window snapping app for XFCE

jaywilkas wrote:

Perhaps take a look at  xpytile

xpytile is a pure Python script which can auto-tile windows and simulateously resize side-by-side (docked) windows.

Well documented script, pure python and Xlib.
Is it blacklisting windows based on name or wm class?

Offline

#15 2021-08-27 09:02:34

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

Re: I want to create a advanced window snapping app for XFCE

jaywilkas wrote:

Perhaps take a look at  xpytile

xpytile is a pure Python script which can auto-tile windows and simulateously resize side-by-side (docked) windows.

Nice one jaywilkas!

Even tho our approaches are different (auto tiling vs. user-controlled window snapping) I think we can collaborate.

I'm now investigating the distribution element, first target being Arch and Arch based distros.

Perhaps the distributed package could contain both manual snapping and auto-tiling features.


Make stuff. Build things.

Offline

#16 2021-08-27 10:30:45

jaywilkas
Member
Registered: 2021-06-05
Posts: 7

Re: I want to create a advanced window snapping app for XFCE

Misko_2083 wrote:

Well documented script, pure python and Xlib.
Is it blacklisting windows based on name or wm class?

Thanks smile

In xpytile the blacklisting of windows is based on the name and/or window title (not on the wm class), and this is defined in the config-file with regex-patterns.
Sticky windows (presend on all workspaces) and modal windows (like dialog boxes) are generally ignored, that means they are neither tiled nor resized.

Last edited by jaywilkas (2021-08-27 10:59:43)

Offline

#17 2021-08-27 10:48:58

jaywilkas
Member
Registered: 2021-06-05
Posts: 7

Re: I want to create a advanced window snapping app for XFCE

sri19 wrote:

Nice one jaywilkas!

Even tho our approaches are different (auto tiling vs. user-controlled window snapping) I think we can collaborate.

I'm now investigating the distribution element, first target being Arch and Arch based distros.

Perhaps the distributed package could contain both manual snapping and auto-tiling features.

Hi sri19,

yes, definitely a good idea to combine the two different approaches.

I think such a combined script, which supports auto-tiling/resizing as well as manual snapping could perhaps be implemented the easiest way by working in two different modes.

Offline

#18 2021-08-27 20:50:07

sri19
Member
From: Amsterdam, NL
Registered: 2021-08-18
Posts: 10
Website

Re: I want to create a advanced window snapping app for XFCE

jaywilkas wrote:
sri19 wrote:

Nice one jaywilkas!

Even tho our approaches are different (auto tiling vs. user-controlled window snapping) I think we can collaborate.

I'm now investigating the distribution element, first target being Arch and Arch based distros.

Perhaps the distributed package could contain both manual snapping and auto-tiling features.

Hi sri19,

yes, definitely a good idea to combine the two different approaches.

I think such a combined script, which supports auto-tiling/resizing as well as manual snapping could perhaps be implemented the easiest way by working in two different modes.

Glad you agree! smile

Here's an update on my side:
- I merged all my sources into a single Py script
- This listens to hotkeys and runs the indicator menu
- Also read a fair bit into Arch packaging (PKGBUILD)
- And having a single Python file definitely helps with that

I don't think we need to "combine" our two scripts, the package can distribute and provide a service that starts both of them.

In the indicator menu, we can add top level distinction between window tiling and window snapping with submenus for relevant menuitems.

At some point, we will have to look into Debian packaging, Snap and Flatpak.


Make stuff. Build things.

Offline

Board footer

Powered by FluxBB