Small scripts to learn about GNOME internals

Overview

gnome-hacks

This is a collection of APIs that allow programmatic manipulation of the GNOME shell. If you use GNOME (the default graphical shell in Ubuntu), then this allows you to create scripts that move your mouse, simulate key presses, manipulate windows, and more.

Disclaimer: Since these hacks hook directly into the internals of the shell, they depend heavily on the particular shell version. I have only tested this on Ubuntu 21.04 with GNOME version 3.38.5.

Exposed APIs

Evaluator - an object that evaluates JavaScript code inside the GNOME shell.

  • __call__: run some JavaScript code inside the shell and get the result as a Python object (it is serialized via JSON). Optionally pass extra kwargs to create variables in the JavaScript code's context. For example, evaluator("hi+3", hi=4).
  • call_async: similar to __call__, but supports JavaScript code that has to wait for callbacks or asynchronous events. In particular, the JavaScript code can use the await keyword to yield control to the event loop. Ideal for blocks of code that need to handle callbacks.

Window manipulation

  • list_windows: get all open windows, including their title, owning PID, and ID.
  • get_window_frame: get the bounding box of a window.
  • get_window_monitor_frame: get the bounding box of the monitor containing a window.
  • move_window: set the position of a window.

Screenshots

  • capture_screenshot: get a screenshot of the display as PNG bytes. On newer versions of GNOME, this happens entirely in memory without ever writing a temporary file.

Keyboard

  • simulate_key_events: trigger a series of key events, allowing a script to type text, trigger keystrokes, etc.

Pointer

  • simulate_pointer_events: trigger a series of mouse events, allowing a script to move, click, and drag the cursor using absolute coordinates on the screen.

Sound

  • play_bell_sound: play the bell sound that apps use to signal errors or get a user's attention.
  • bell_notify: similar to play_bell_sound, but may also flash the screen or use other feedback if the user has configured the shell to do so.

How it works

The GNOME shell provides a DBus interface, allowing other processes to connect to it and make IPC calls. Through this interface, it exposes an Eval method for evaluating JavaScript inside an embedded interpreter. This JavaScript code has access to most of the types and functions used by the shell, exposed through GJS bindings.

The shell exposes a global object which has methods to access various shell state, such as the list of open windows or the global MetaDisplay object.

You might also like...
Small Arrow Vortex clipboard processing library

Description Small Arrow Vortex clipboard processing library. Install You can install this library from PyPI with pip install av-clipboard-lib or compi

Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Advent Of Code 2021 - Python English Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels th

Repository, with small useful and functional applications
Repository, with small useful and functional applications

Repositorio,com pequenos aplicativos uteis e funcionais A ideia e ir deselvolvendo pequenos aplicativos funcionais e adicionar a este repositorio List

🍕 A small app with capabilities ordering food and listing them with pub/sub pattern

food-ordering A small app with capabilities ordering food and listing them. Prerequisites Docker Run Tests docker-compose run --rm web ./manage.py tes

An Advent calendar of small programming puzzles for a variety of skill sets and skill levels.

Advent of Code 2021 The Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be sol

A very small (15 lines of code) and beautiful fetch script (exclusively for Arch Linux).

minifetch A very small (15 lines of code) and beautiful fetch script (exclusively for Arch Linux). There are many fetch scripts out there but I wanted

Small tool to use hero .json files created with Optolith for The Dark Eye/ Das Schwarze Auge 5 to perform talent probes.
Small tool to use hero .json files created with Optolith for The Dark Eye/ Das Schwarze Auge 5 to perform talent probes.

DSA5-ProbeMaker A little tool for The Dark Eye 5th Edition (Das Schwarze Auge 5) to load .json from Optolith character generation and easily perform t

An easy FASTA object handler, reader, writer and translator for small to medium size projects without dependencies.

miniFASTA An easy FASTA object handler, reader, writer and translator for small to medium size projects without dependencies. Installation Using pip /

Project Faros is a reference implimentation of Red Hat OpenShift 4 on small footprint, bare-metal clusters.
Project Faros is a reference implimentation of Red Hat OpenShift 4 on small footprint, bare-metal clusters.

Project Faros Project Faros is a reference implimentation of Red Hat OpenShift 4 on small footprint, bare-metal clusters. The project includes referen

Owner
Alex Nichol
Web developer, math geek, and AI enthusiast.
Alex Nichol
python scripts - mostly automation scripts

python python scripts - mostly automation scripts You can set your environment in various ways bash #!/bin/bash python - locally on remote host #!/bi

Enyi 1 Jan 5, 2022
DownTime-Score is a Small project aimed to Monitor the performance and the availabillity of a variety of the Vital and Critical Moroccan Web Portals

DownTime-Score DownTime-Score is a Small project aimed to Monitor the performance and the availabillity of a variety of the Vital and Critical Morocca

adnane-tebbaa 5 Apr 30, 2022
A small Blender addon for changing an object's local orientation while in edit mode

A small Blender addon for changing an object's local orientation while in edit mode.

Jonathan Lampel 50 Jan 6, 2023
OnTime is a small python that you set a time and on that time, app will send you notification and also play an alarm.

OnTime Always be OnTime! What is OnTime? OnTime is a small python that you set a time and on that time, app will send you notification and also play a

AmirHossein Mohammadi 11 Jan 16, 2022
Small projects for python beginners.

Python Mini Projects For Beginners I recently started doing the #100DaysOfCode Challenge in Python. I've used Python before, but I had switched to JS

Sreekesh Iyer 10 Dec 12, 2022
Small exercises to get you used to reading and writing Python code!

Pythonlings Welcome to Pythonlings, an automated Python tutorial program (inspired by Rustlings and Haskellings). WIP This program is still working in

鹤翔万里 5 Sep 23, 2022
Goddard A collection of small, simple strategies for Freqtrade

Goddard A collection of small, simple strategies for Freqtrade. Simply add the strategy you choose in your strategies folder and run. ⚠️ General Crypt

Shane Jones 118 Dec 14, 2022
A small C compiler written in Python for learning purposes

A small C compiler written in Python. Generates x64 Intel-format assembly, which is then assembled and linked by nasm and ld.

Scattered Thoughts 3 Oct 22, 2021
This is a small compiler to demonstrate how compilers work.

This is a small compiler to demonstrate how compilers work. It compiles our own dialect to C, while being written in Python.

Md. Tonoy Akando 2 Jul 19, 2022
This repo will have a small amount of Chrome tools that can be used for DFIR, Hacking, Deception, whatever your heart desires.

Chrome-Tools Overview Welcome to the repo. This repo will have a small amount of Chrome tools that can be used for DFIR, Hacking, Deception, whatever

null 5 Jun 8, 2022