After a recent update of my LMDE, the gnome-screenshot tool started making an annoying camera shutter noise every time a screenshot is taken. This is both annoying and startling (especially if you happen to be wearing earphones when taking the screenshot).
I checked the man page of gnome-screenshot` but there were no relevant options. How can I take silent screenshots?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The other solution1 has some inconveniences:
– it requires root access
– it’s a global change so it affects all users
– upgrading sound-theme-freedesktop restores the file
For the record, the proper way to do it (and avoid all of the above) is via a custom sound theme that disables2 the default sound file used by gnome-screenshot (the name of the file is screen-capture.oga corresponding to the screen-capture event – hardcoded in gnome-settings-daemon and gnome-screenshot).
Create the custom theme directory:
mkdir -p ~/.local/share/sounds/__custom
create the .disabled file:
touch ~/.local/share/sounds/__custom/screen-capture.disabled
add the index.theme:
cat << 'EOF' > ~/.local/share/sounds/__custom/index.theme [Sound Theme] Name=__custom Inherits=freedesktop Directories=. EOF
set __custom as default theme name:
gsettings set org.gnome.desktop.sound theme-name '__custom'
Or, if you’re using Cinnamon:
gsettings set org.cinnamon.desktop.sound theme-name '__custom'
and enjoy the silence…
1: Yeah, I know it’s actually my solution but at the time of posting it on the arch forums I was just being lazy…
2: A pseudo file format “.disabled” is used for disabling sounds in a theme that inherits from another theme. If the sound lookup algorithms detects a file with the suffix “.disabled” it shall immediately terminate the lookup logic and consider the sound not available. All files with “.disabled” suffix should be of length zero.
Method 2
I found the solution here. The sound played is /usr/share/sounds/freedesktop/stereo/camera-shutter.oga. So simply renaming that file stops it from being played:
sudo mv /usr/share/sounds/freedesktop/stereo/camera-shutter.oga
/usr/share/sounds/freedesktop/stereo/damn-camera-shutter.oga
That’s it, next time you take a screenshot, it will be done in silence.
Method 3
Renaming the shutter sound file is OK, but probably won’t work if you don’t have root access to the system. Here’s an alternative approach:
#!/bin/bash
volume=$(amixer sget Master | awk -F '[],[,%]' '/%/{print $2 }')
amixer sset Master 0
gnome-screenshot
amixer sset Master "$volume"%
What this script does is remember volume percentage, set volume temporarily to 0, take screenshot, and once gnome-screenshot process exits, the volume is restored back to original percentage.
The advantage of this approach is that it is flexible and can be customized to suit your needs. This script can be bound to PrntScr button, or to custom shortcut.
Tested on Ubuntu 16.04 LTS
Method 4
Same code as above but with a slight change to work in ubuntu (adding the -D pulse to select the device, and removing the speech marks on the volume variable.
This works for me on Ubuntu 20.04 (create a file in your home dir, make it executable, create a keyboard shortcut in gnome settings to run the script)
#!/bin/bash
volume=$(amixer -D pulse sget Master | awk -F '[],[,%]' '/%/{print $2 }')
amixer -D pulse sset Master 0
gnome-screenshot
amixer -D pulse sset Master $volume%
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0