2.4 KiB
2.4 KiB
Window Management Script
A Linux utility script for managing window positions and sizes on your desktop. This script allows you to quickly position windows in predefined layouts using keyboard shortcuts or direct commands.
Features
- Position windows in various preset layouts (center, left, right)
- Support for different window widths (25%, 50%, 100%)
- Automatically accounts for taskbar/panel height
- Shows notifications when windows are repositioned
Dependencies
The script requires the following tools to be installed:
xdpyinfo- for getting screen dimensionsxdotool- for window manipulationwmctrl- for window controlnotify-send- for desktop notifications
Installing Dependencies
On Ubuntu/Debian:
sudo apt install x11-utils xdotool wmctrl libnotify-bin
On Fedora:
sudo dnf install xorg-x11-utils xdotool wmctrl libnotify
On Arch Linux:
sudo pacman -S xorg-xdpyinfo xdotool wmctrl libnotify
Usage
- Make the script executable:
chmod +x windowmanagement.sh
- Run the script with one of the following commands:
./windowmanagement.sh [command]
Available commands:
center- Full width windowcenter50- 50% width window in centerleft25- 25% width window on left sideright25- 25% width window on right sideleft50- 50% width window on left sideright50- 50% width window on right sidecenterleft25- 25% width window on left side of centercenterright25- 25% width window on right side of center
Functions
get_usable_height
Returns the available vertical screen space by calculating:
screen_height - panel_height
This ensures windows are sized correctly accounting for the taskbar/panel height.
Integration
You can integrate this script with your desktop environment's keyboard shortcuts system. For example, you could bind:
Super + Leftto./windowmanagement.sh left50Super + Rightto./windowmanagement.sh right50Super + Upto./windowmanagement.sh center
Notes
- The script automatically detects your screen dimensions and panel height
- Windows are positioned slightly below the top of the screen (0.1 pixels) to prevent issues with some desktop environments
- The script will show a notification when a window is repositioned
- If any required dependencies are missing, the script will notify you
Author
R. Branten (2022)