Updating camera settings with gphoto2

gphoto2 is a cool little command line utility to remotely control many digital cameras and their settings.  Grab it out of your repository, connect your camera by USB, turn on and enjoy.

Sometimes when you try to use gphoto2 you get an error message like this

*** Error ***              
An error occurred in the io-library ('Could not lock the device'): Camera is already in use.
*** Error (-60: 'Could not lock the device') ***

which is probably because you’ve connected you camera with an SD/CF card in it.  Fix it simply with

 gvfs-mount -s gphoto2

or however you chose to unmount a remote drive.

All I wanted to do was check my shuttercount, but you can get a full list of your camera’s capabilities with the following command (yours will probably be different)

simon@commodus:~$ gphoto2 --list-config
/main/actions/bulb                                                             
/main/actions/uilock
/main/actions/syncdatetime
/main/actions/autofocusdrive
/main/actions/manualfocusdrive
/main/actions/eoszoom
/main/actions/eoszoomposition
/main/actions/eosviewfinder
/main/settings/datetime
/main/settings/reviewtime
/main/settings/output
/main/settings/evfmode
/main/settings/ownername
/main/settings/customfuncex
/main/settings/capturetarget
/main/settings/capture
/main/status/model
/main/status/ptpversion
/main/status/dpofversion
/main/status/batterylevel
/main/status/serialnumber
/main/status/shuttercounter
/main/status/availableshots
/main/imgsettings/imageformat
/main/imgsettings/imageformatsd
/main/imgsettings/iso
/main/imgsettings/whitebalance
/main/imgsettings/whitebalanceadjusta
/main/imgsettings/whitebalanceadjustb
/main/imgsettings/whitebalancexa
/main/imgsettings/whitebalancexb
/main/imgsettings/colorspace
/main/capturesettings/exposurecompensation
/main/capturesettings/focusmode
/main/capturesettings/autoexposuremode
/main/capturesettings/drivemode
/main/capturesettings/picturestyle
/main/capturesettings/shutterspeed
/main/capturesettings/meteringmode
/main/capturesettings/bracketmode
/main/other/d402
/main/other/d407
/main/other/d406

and to get the current setting for any one key (you can use either the short or long key), just

simon@commodus:~$ gphoto2 --get-config shuttercounter
Label: Shutter Counter                                                         
Type: TEXT
Current: 66666

I thought I’d update the time on the camera whilst I was at it, so used this handy little shortcut.

gphoto2 --set-config datetime=`date +%s`

Depending on your model, you may be able to set copyright and ownername strings which the camera will automatically embed in EXIF for all photos taken: check what your camera supports as described above.