This Perl script allows easy export and import of GNOME keybindings. It's particularly useful when switching between systems or after fresh installations to quickly restore your personal keyboard shortcuts.
				
			
		| gnome-keybindings.pl | ||
| README.md | ||
GNOME Keybindings Export/Import Tool
Description
This Perl script allows easy export and import of GNOME keybindings. It's particularly useful when switching between systems or after fresh installations to quickly restore your personal keyboard shortcuts.
Features
- Export GNOME keybindings to a text file
 - Import keybindings from a file
 - Support for standard GNOME keybindings
 - Support for custom keybindings
 - Automatic detection of import/export based on file existence
 
Requirements
- Linux system with GNOME desktop environment
 - Perl (usually pre-installed)
 gsettingstool (part of GNOME)
Installation
- Download the script and make it executable:
 
chmod +x gnome-keybindings.pl
- Optional: Move to a directory in your PATH:
 
sudo mv gnome-keybindings.pl /usr/local/bin/
Usage
Display help
./gnome-keybindings.pl -h
./gnome-keybindings.pl --help
Export keybindings
# To stdout (terminal)
./gnome-keybindings.pl -e
# To a file
./gnome-keybindings.pl -e my-keybindings.txt
./gnome-keybindings.pl --export my-keybindings.txt
Import keybindings
./gnome-keybindings.pl -i my-keybindings.txt
./gnome-keybindings.pl --import my-keybindings.txt
Automatic detection
# Exports if file doesn't exist
./gnome-keybindings.pl new-file.txt
# Imports if file already exists
./gnome-keybindings.pl existing-file.txt
Exported Settings
The script exports keybindings from the following areas:
- Window Management (
org.gnome.desktop.wm.keybindings)- Close, maximize, move windows, etc.
 
 - Power Buttons (
org.gnome.settings-daemon.plugins.power)- Power button actions
 
 - Media Keys (
org.gnome.settings-daemon.plugins.media-keys)- Volume, brightness, media player controls
 
 - Custom Keybindings
- User-created shortcuts with custom commands
 
 
File Format
The exported file is a simple tab-separated text file:
# Standard keybindings
org.gnome.desktop.wm.keybindings	close	['<Super>q']
org.gnome.settings-daemon.plugins.media-keys	volume-up	['<Super>plus']
# Custom keybindings
custom	'Open Terminal'	'gnome-terminal'	'<Super>t'
Example Workflow
# System 1: Export keybindings
./gnome-keybindings.pl --export backup-$(date +%Y%m%d).txt
# Copy file to System 2 (e.g., via USB drive, cloud, etc.)
# System 2: Import keybindings
./gnome-keybindings.pl --import backup-20250922.txt
Notes
- Importing will overwrite existing keybindings
 - It's recommended to export current settings before importing
 - After import, a logout/login may be required for all changes to take effect
 - The script doesn't require root privileges as it only modifies user settings
 
Troubleshooting
Error: "Can't open file"
- Check read/write permissions for the specified file
 
Import fails
- Ensure you're using GNOME
 - Check if 
gsettingsis available:which gsettings 
Keybindings don't work after import
- Log out and log back in
 - Check GNOME settings for conflicts
 
License
Free to use for personal and commercial purposes.
Author
wiht fixes from Zenny to work on Ubuntu 24.04.3 LTS and later