Friday, May 3, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 1289  / 2 Years ago, wed, march 30, 2022, 12:40:26

Distribution:



Ubuntu 14.04 64bit Desktop



Question:



I love using the shutter program to take/manage screenshots. However, remapping the print-screen behaviour to the appropriate shortcut keys on every computer is rather tedious. I would like be able to run a script to do this for me and others.



I found this similar Askubuntu question, which appears to want to do the same sort of thing (set shortcuts through the CLI), but unfortunately, it doesn't work for me (yet). I am pretty sure a few things in my script just need tweaking, or perhaps things have drastically changed between 12.10 and 14.04?



Script:



#!/bin/bash
gsettings set org.gnome.desktop.wm.keybindings shutter --select "['<Shift>Print']"
gsettings set org.gnome.desktop.wm.keybindings shutter --full "['Print']"
gsettings set org.gnome.desktop.wm.keybindings shutter --active "['<Alt>Print']"


Example Error output:




More From » 14.04

 Answers
2

It turns out that custom shortcuts are slightly different and you need to run 3 commands for each. I managed to get it "working" with the following script:



#!/bin/bash

# Add the paths for if we are adding rather than overwritting shortcuts
KEY_PATH="/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"
gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings
"['$KEY_PATH/custom0/', '$KEY_PATH/custom1/', '$KEY_PATH/custom2/']"

# Now set the shortcuts
BEGINNING="gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"

$BEGINNING/custom0/ name "Take Full Screenshot"
$BEGINNING/custom0/ command "shutter --full"
$BEGINNING/custom0/ binding "Print"

$BEGINNING/custom1/ name "Grab Active Window"
$BEGINNING/custom1/ command "shutter --active"
$BEGINNING/custom1/ binding "<Alt>Print"

$BEGINNING/custom2/ name "Screenshot Selection"
$BEGINNING/custom2/ command "shutter --select"
$BEGINNING/custom2/ binding "<Shift>Print"


Note that this will overwrite your first 3 custom shortcuts (if they exist) and you may want to rename custom0, custom1, custom2 accordingly in order to not do this.



One also needs to manually disable the printscreen shortcuts as shown below (although would be grateful if someone could just update this answers script with the appropriate command(s).



enter image description here


[#25146] Friday, April 1, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tatoethin

Total Points: 377
Total Questions: 110
Total Answers: 98

Location: Saudi Arabia
Member since Sat, Aug 20, 2022
2 Years ago
;