Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

enter image description here

share|improve this question

2 Answers 2

Alternatively you can use Compiz to set keyboard commands:

gconftool -t string /apps/compiz/plugins/commands/allscreens/options/command0 -s "shutter --full"

gconftool -t string /apps/compiz/plugins/commands/allscreens/options/run_command0_key -s "< Control>k"

Note: Compiz must be using dconf as the backend.

share|improve this answer
1  
Thanks, thats quite helpful. Originally I was using the compiz plugins tool, but every now and then it would get "cleared" for some reason. I wanted to move away from compiz just in case it one day becomes "unsupported". –  Programster May 18 at 13:58
    
It gets cleared almost every time there is an update labeled ubuntu base, which I believe updates compiz unity or both. This can be worked around by script either every boot or after update of ubuntu base if you know how. –  dginsd May 19 at 12:17
up vote 1 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.