Skip to content

Commit 36775e0

Browse files
committed
Add some options to cinnamon-screenshot
This adds two option to cinnamon-screenshot: - autosave-to-file - autosave-to-clipboard These options do what they're called, without opening the interactive window. Both options can be used at the same time.
1 parent 085d07c commit 36775e0

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

data/org.cinnamon.gschema.xml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,18 @@
10661066
<description>When enabled, opens the file manager with the saved screenshot pre-selected after a successful save.</description>
10671067
</key>
10681068

1069+
<key name="autosave-to-file" type="b">
1070+
<default>false</default>
1071+
<summary>Autosave screenshot to file</summary>
1072+
<description>When enabled, saves the screenshot to file without showing the application's interactive window</description>
1073+
</key>
1074+
1075+
<key name="autosave-to-clipboard" type="b">
1076+
<default>false</default>
1077+
<summary>Autosave screenshot to file</summary>
1078+
<description>When enabled, saves the screenshot to the clipboard without showing the application's interactive window</description>
1079+
</key>
1080+
10691081
</schema>
10701082

10711083
</schemalist>

files/usr/share/cinnamon/cinnamon-screenshot/application.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ def do_activate(self):
2929
self._run_clipboard()
3030
elif args.file and not args.interactive:
3131
self._run_save_to_file(args.file)
32+
elif (prefs.get_autosave_to_file() or prefs.get_autosave_to_clipboard()) and not args.interactive:
33+
if prefs.get_autosave_to_file():
34+
filename = util.build_filename(
35+
prefs.get_save_directory(),
36+
file_type=prefs.get_default_file_type(),
37+
)
38+
self._run_save_to_file(filename)
39+
if prefs.get_autosave_to_clipboard():
40+
self._run_clipboard()
3241
else:
3342
self._run_window()
3443

files/usr/share/cinnamon/cinnamon-screenshot/prefs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
SAVE_DIRECTORY_KEY = 'save-directory'
1313
DEFAULT_FILE_TYPE_KEY = 'default-file-type'
1414
LAUNCH_FILE_MANAGER_KEY = 'launch-file-manager-after-save'
15+
AUTOSAVE_TO_FILE_KEY = 'autosave-to-file'
16+
AUTOSAVE_TO_CLIPBOARD_KEY = 'autosave-to-clipboard'
1517

1618
settings = Gio.Settings.new(SCHEMA_ID)
1719
if not settings.get_string(SAVE_DIRECTORY_KEY):
@@ -59,6 +61,12 @@ def set_default_file_type(value):
5961
def get_launch_file_manager():
6062
return settings.get_boolean(LAUNCH_FILE_MANAGER_KEY)
6163

64+
def get_autosave_to_file():
65+
return settings.get_boolean(AUTOSAVE_TO_FILE_KEY)
66+
67+
def get_autosave_to_clipboard():
68+
return settings.get_boolean(AUTOSAVE_TO_CLIPBOARD_KEY)
69+
6270
_current_window = None
6371

6472

@@ -109,6 +117,16 @@ def __init__(self, parent):
109117
SCHEMA_ID, LAUNCH_FILE_MANAGER_KEY,
110118
))
111119

120+
section_behavior = page.add_section(_('Behavior'))
121+
section_behavior.add_row(GSettingsSwitch(
122+
_('Autosave to file'),
123+
SCHEMA_ID, AUTOSAVE_TO_FILE_KEY,
124+
))
125+
section_behavior.add_row(GSettingsSwitch(
126+
_('Autosave to clipboard'),
127+
SCHEMA_ID, AUTOSAVE_TO_CLIPBOARD_KEY,
128+
))
129+
112130
self.window.show_all()
113131

114132
def _on_destroy(self, _w):

0 commit comments

Comments
 (0)