Linux Desktop Control
by @ouyangabel
Linux desktop automation and control. Use when: (1) taking screenshots of the screen or windows, (2) controlling mouse and keyboard, (3) managing windows, (4...
clawhub install linux-desktopπ About This Skill
name: linux-desktop description: "Linux desktop automation and control. Use when: (1) taking screenshots of the screen or windows, (2) controlling mouse and keyboard, (3) managing windows, (4) automating desktop tasks, or (5) any Linux desktop interaction needs. Supports screenshot capture, mouse movement, typing, and window management."
Linux Desktop Control
Automate and control your Linux desktop using command-line tools. Capture screenshots, control mouse/keyboard, and manage windows.
When to Use
Prerequisites
Install required tools:
sudo apt-get install scrot xdotool xclip x11-utils x11-apps
Quick Start
Take Screenshot
python3 scripts/linux-desktop.py screenshot
Output: ~/screenshot_20240224_203901.png
List Windows
python3 scripts/linux-desktop.py list
Move Mouse and Click
python3 scripts/linux-desktop.py move 500 300
python3 scripts/linux-desktop.py click
Type Text
python3 scripts/linux-desktop.py type "Hello World"
Commands
screenshot [path]
Capture a screenshot of the entire screen.Examples:
# Save to default location (/tmp/screenshot_YYYYMMDD_HHMMSS.png)
python3 scripts/linux-desktop.py screenshotSave to custom path
python3 scripts/linux-desktop.py screenshot ~/desktop.png
window [window_id] [path]
Capture a screenshot of a specific window.Examples:
# Screenshot active window
python3 scripts/linux-desktop.py windowScreenshot specific window
python3 scripts/linux-desktop.py window 0x12345678 ~/window.png
active
Get information about the currently active window.python3 scripts/linux-desktop.py active
Output: π₯οΈ Active Window
ID: 0x12345678
Title: Terminal
list
List all visible windows.python3 scripts/linux-desktop.py list
Output: πͺ Found 5 windows:
1. 0x12345678 - Terminal
2. 0x87654321 - Chrome
move
Move mouse cursor to specified coordinates.Examples:
python3 scripts/linux-desktop.py move 100 200
Moves mouse to (100, 200)
python3 scripts/linux-desktop.py move 500 300
Moves mouse to center of 1000x600 area
click [button]
Click mouse button at current cursor position.Button values:
1 - Left button (default)2 - Middle button3 - Right buttonExamples:
python3 scripts/linux-desktop.py click
Left click
python3 scripts/linux-desktop.py click 3
Right click
type
Type text at current cursor position (must be in focused window).Examples:
python3 scripts/linux-desktop.py type "Hello World"python3 scripts/linux-desktop.py type "ls -la"
python3 scripts/linux-desktop.py type "sudo apt update"
key
Press keyboard keys.Common keys:
Return - Enter keyEscape - Escape keyTab - Tab keyBackSpace - BackspaceDelete - DeleteUp, Down, Left, Right - Arrow keysHome, End, Page_Up, Page_DownF1 through F12Ctrl+c, Ctrl+v, Ctrl+a, Ctrl+z - Key combinationsExamples:
python3 scripts/linux-desktop.py key Returnpython3 scripts/linux-desktop.py key Escape
python3 scripts/linux-desktop.py key Ctrl+a
python3 scripts/linux-desktop.py key F5
screen
Get screen information.python3 scripts/linux-desktop.py screen
Output: π₯οΈ Screen Info
Resolution: 1920x1080
Automation Examples
Basic Automation
# Move mouse, click, type, and press enter
python3 scripts/linux-desktop.py move 100 100
python3 scripts/linux-desktop.py click
python3 scripts/linux-desktop.py type "ls -la"
python3 scripts/linux-desktop.py key Return
Web Search Automation
# Open browser, navigate to Google, search
python3 scripts/linux-desktop.py move 100 50
python3 scripts/linux-desktop.py click
python3 scripts/linux-desktop.py type "https://www.google.com"
python3 scripts/linux-desktop.py key Return
sleep 2
python3 scripts/linux-desktop.py type "how to make money online"
python3 scripts/linux-desktop.py key Return
Screenshot Workflow
# Take screenshot before and after action
python3 scripts/linux-desktop.py screenshot /tmp/before.png
python3 scripts/linux-desktop.py key F5 # Refresh
sleep 1
python3 scripts/linux-desktop.py screenshot /tmp/after.png
Tips
sleep commands between actions for reliabilityTroubleshooting
"Command not found" errors:
sudo apt-get install scrot xdotool xclip x11-utils x11-apps
Permission denied:
Mouse doesn't move:
Security Notes
β‘ When to Use
π‘ Examples
Take Screenshot
python3 scripts/linux-desktop.py screenshot
Output: ~/screenshot_20240224_203901.png
List Windows
python3 scripts/linux-desktop.py list
Move Mouse and Click
python3 scripts/linux-desktop.py move 500 300
python3 scripts/linux-desktop.py click
Type Text
python3 scripts/linux-desktop.py type "Hello World"
βοΈ Configuration
Install required tools:
sudo apt-get install scrot xdotool xclip x11-utils x11-apps
π Tips & Best Practices
sleep commands between actions for reliability