1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
use clap::{Parser, ValueEnum};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct CommandLine {
/// Path to the config file. Otherwise will be read from XDG_CONFIG_DIR/satty/config.toml
#[arg(short, long)]
pub config: Option<String>,
/// Path to input image or '-' to read from stdin
#[arg(short, long)]
pub filename: String,
/// Start Satty in fullscreen mode
#[arg(long)]
pub fullscreen: bool,
/// Filename to use for saving action or '-' to print to stdout. Omit to disable saving to file. Might contain format
/// specifiers: <https://docs.rs/chrono/latest/chrono/format/strftime/index.html>.
#[arg(short, long)]
pub output_filename: Option<String>,
/// Exit directly after copy/save action
#[arg(long)]
pub early_exit: bool,
/// Draw corners of rectangles round if the value is greater than 0
/// (Defaults to 12) (0 disables rounded corners)
#[arg(long)]
pub corner_roundness: Option<f32>,
/// Select the tool on startup
#[arg(long, value_name = "TOOL", visible_alias = "init-tool")]
pub initial_tool: Option<Tools>,
/// Configure the command to be called on copy, for example `wl-copy`
#[arg(long)]
pub copy_command: Option<String>,
/// Increase or decrease the size of the annotations
#[arg(long)]
pub annotation_size_factor: Option<f32>,
/// After copying the screenshot, save it to a file as well
/// Preferably use the `action_on_copy` option instead.
#[arg(long)]
pub save_after_copy: bool,
/// Actions to perform when pressing Enter
#[arg(long, value_delimiter = ',')]
pub actions_on_enter: Option<Vec<Action>>,
/// Actions to perform when pressing Escape
#[arg(long, value_delimiter = ',')]
pub actions_on_escape: Option<Vec<Action>>,
/// Actions to perform when hitting the copy Button.
#[arg(long, value_delimiter = ',')]
pub actions_on_right_click: Option<Vec<Action>>,
/// Hide toolbars by default
#[arg(short, long)]
pub default_hide_toolbars: bool,
/// Experimental: Whether to toggle toolbars based on focus. Doesn't affect initial state.
#[arg(long)]
pub focus_toggles_toolbars: bool,
/// Experimental feature: Fill shapes by default
#[arg(long)]
pub default_fill_shapes: bool,
/// Font family to use for text annotations
#[arg(long)]
pub font_family: Option<String>,
/// Font style to use for text annotations
#[arg(long)]
pub font_style: Option<String>,
/// The primary highlighter to use, secondary is accessible with CTRL
#[arg(long)]
pub primary_highlighter: Option<Highlighters>,
/// Disable notifications
#[arg(long)]
pub disable_notifications: bool,
/// Print profiling
#[arg(long)]
pub profile_startup: bool,
/// Disable the window decoration (title bar, borders, etc.)
/// Please note that the compositor has the final say in this.
/// Requires xdg-decoration-unstable-v1
#[arg(long)]
pub no_window_decoration: bool,
/// Experimental feature: How many points to use for the brush smoothing
/// algorithm.
/// 0 disables smoothing.
/// The default value is 0 (disabled).
#[arg(long)]
pub brush_smooth_history_size: Option<usize>,
// --- deprecated options ---
/// Right click to copy.
/// Preferably use the `action_on_right_click` option instead.
#[arg(long)]
pub right_click_copy: bool,
/// Action to perform when pressing Enter.
/// Preferably use the `actions_on_enter` option instead.
#[arg(long, value_delimiter = ',')]
pub action_on_enter: Option<Action>,
// ---
}
#[derive(Debug, Clone, Copy, Default, ValueEnum)]
pub enum Tools {
#[default]
Pointer,
Crop,
Line,
Arrow,
Rectangle,
Ellipse,
Text,
Marker,
Blur,
Highlight,
Brush,
}
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum Action {
SaveToClipboard,
SaveToFile,
Exit,
}
#[derive(Debug, Clone, Copy, Default, ValueEnum)]
pub enum Highlighters {
#[default]
Block,
Freehand,
}
impl std::fmt::Display for Tools {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
use Tools::*;
let s = match self {
Pointer => "pointer",
Crop => "crop",
Line => "line",
Arrow => "arrow",
Rectangle => "rectangle",
Ellipse => "ellipse",
Text => "text",
Marker => "marker",
Blur => "blur",
Highlight => "highlight",
Brush => "brush",
};
f.write_str(s)
}
}