Skip to main content

A simple tool to automate window management

Project description

Janela

Window handling for humans

PyPI version License Python Version Platform

A simple Python package for managing and manipulating application windows on GUI environments. janela provides an easy-to-use interface for moving, resizing, maximizing, minimizing, and arranging windows across multiple monitors.

Note: Currently, Janela supports Linux platforms. Support for Windows and macOS is in progress and will be available in future releases.

Features

  • Move windows between monitors: Easily transfer windows from one monitor to another.
  • Resize windows: Adjust the size of windows programmatically.
  • Maximize and minimize windows: Control window states effortlessly.
  • Focus on windows: Bring specific windows to the foreground.
  • Close windows: Programmatically close application windows.
  • Arrange windows in mosaic patterns: Organize your windows in a mosaic layout across your monitors.

Table of Contents

Installation

Linux

First, ensure that you have the required system dependencies installed.

Install xdotool and wmctrl

On Debian/Ubuntu-based systems:

sudo apt-get update
sudo apt-get install xdotool wmctrl

Install Janela

You can install Janela from PyPI:

pip install janela

Windows (Coming Soon)

Support for Windows platforms is currently under development. Stay tuned for upcoming releases that will include Windows support.

macOS

Install from PyPI (this pulls the necessary PyObjC/Quartz bindings automatically):

pip install janela

On first run, macOS will prompt you for Accessibility permission for the Python interpreter or terminal you are using. Approve that prompt (or pre-authorize via System Settings → Privacy & Security → Accessibility). Janela will request this permission automatically when needed.

Requirements

Usage

Note: The following usage examples are applicable to Linux platforms. Support for Windows and macOS is coming soon.

Basic Example

Arrange all windows in a mosaic pattern across all monitors:

from janela import Janela, effects

# Initialize the window manager
ja = Janela()

# Arrange windows in a mosaic pattern
effects.mosaic(ja)

Moving a Window to Another Monitor

from janela import Janela

# Initialize the window manager
ja = Janela()

# Get a window by name
window = ja.get_window_by_name("Mozilla Firefox")

# Get the target monitor (e.g., monitor with ID 1)
target_monitor = ja.get_monitor_by_id(1)

# Move the window to the target monitor
if window and target_monitor:
  window.move_to_monitor(target_monitor)

Resizing and Moving Windows

from janela import Janela

ja = Janela()

# Get the active window
window = ja.get_active_window()

if window:
  # Move the window to position (100, 100)
  window.set_position(100, 100)

  # Resize the window to width 800 and height 600
  window.resize(800, 600)

Maximizing and Minimizing Windows

from janela import Janela

ja = Janela()

# Get a window by name
window = ja.get_window_by_name("Terminal")

if window:
  # Maximize the window
  window.maximize()

  # Check if the window is maximized
  if window.is_maximized():
    print(f"Window '{window.name}' is maximized.")

  # Minimize the window
  window.minimize()

Focusing and Closing Windows

from janela import Janela

ja = Janela()

# Get a window by name
window = ja.get_window_by_name("Text Editor")

if window:
  # Focus the window
  window.focus()

  # Close the window
  window.close()

API Reference

WindowManager

The WindowManager class is the main interface to manage windows and monitors.

Methods:

  • list_windows(): List all open windows.
  • list_monitors(): List all available monitors.
  • get_active_window(): Get the currently active window.
  • get_window_by_name(name): Get a window by its name.
  • get_monitor_by_id(monitor_id): Get a monitor by its ID.

Window

Represents a window in the system.

Attributes:

  • id: The window ID.
  • name: The window name.
  • x, y: The position of the window.
  • width, height: The dimensions of the window.
  • is_active: Whether the window is currently active.

Methods:

  • set_position(x, y): Move the window to the specified position.
  • move(x, y): Move the window by the specified offset.
  • resize(width, height): Resize the window.
  • minimize(): Minimize the window.
  • maximize(): Maximize the window.
  • move_to_monitor(monitor): Move the window to the specified monitor.
  • is_maximized(): Check if the window is maximized.
  • unmaximize(): Unmaximize the window.
  • focus(): Bring the window to the foreground.
  • close(): Close the window.

Monitor

Represents a monitor connected to the system.

Attributes:

  • id: The monitor ID.
  • name: The monitor name.
  • x, y: The position of the monitor.
  • width, height: The dimensions of the monitor.

Methods:

  • list_windows(): List all windows on this monitor.
  • contains(x, y): Check if a point is within this monitor.
  • is_vertical(): Check if the monitor is vertically oriented.
  • is_horizontal(): Check if the monitor is horizontally oriented.
  • aspect_ratio(): Get the aspect ratio of the monitor.

Tested Platforms

The following table lists the operating systems and distributions where Janela has been tested. This helps track where the library works and where it might encounter issues.

Operating System Distribution Version(s) Status
Linux Ubuntu (KDE) 20.04 LTS, 22.04 LTS ✅ Works
Windows - - 🚧 In Progress
macOS - - 🚧 In Progress

Note: As the library is designed specifically for Linux systems at the moment, Windows and macOS support is currently under development. We are actively working on bringing Janela's capabilities to these platforms in future releases.

Contributing

Contributions are welcome! Please submit a pull request or open an issue on GitHub.

If you're interested in helping us bring support for Windows and macOS platforms, feel free to contribute to the project.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

  • xdotool - Simulate keyboard input and mouse activity.
  • wmctrl - Interact with an X Window Manager.
  • python-xlib - Python interface to the X11 protocol client library.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

janela-0.0.10.tar.gz (20.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

janela-0.0.10-py3-none-any.whl (21.9 kB view details)

Uploaded Python 3

File details

Details for the file janela-0.0.10.tar.gz.

File metadata

  • Download URL: janela-0.0.10.tar.gz
  • Upload date:
  • Size: 20.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for janela-0.0.10.tar.gz
Algorithm Hash digest
SHA256 4ba30184afafed609aa5d23819804df4a021ba95d8072e5545a6bb7e2d455fc6
MD5 e448078c028425daa6a2e4ef62b6b2cc
BLAKE2b-256 7a8f310c23e6d2a1cd329381140b966e44d6afeb4b6ec5c3c971b0dc8e52fd44

See more details on using hashes here.

File details

Details for the file janela-0.0.10-py3-none-any.whl.

File metadata

  • Download URL: janela-0.0.10-py3-none-any.whl
  • Upload date:
  • Size: 21.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for janela-0.0.10-py3-none-any.whl
Algorithm Hash digest
SHA256 4b43eae735b1f18692c2f9b89c685fa9e4bb5bb02292c176a622e78cb9c2e5ac
MD5 9162ac9bc1287b9f67ab20d5655fdf2d
BLAKE2b-256 326393dcff475ac562869a17270b67190fee5f7c95cd23c331a3eb4ec7979ed2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page