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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
use clap::{Args, Parser, Subcommand};
use std::fmt::Debug;
use std::path::PathBuf;
#[derive(Parser, Debug, Clone)]
#[command(
author,
version,
about,
long_about = "A modern GTK4-based window switcher and application launcher for Hyprland"
)]
pub struct App {
#[clap(flatten)]
pub global_opts: GlobalOpts,
#[clap(subcommand)]
pub command: Command,
}
#[derive(Args, Debug, Clone)]
pub struct GlobalOpts {
/// Increase the verbosity level (-v: debug, -vv: trace)
#[arg(short = 'v', global = true, action = clap::ArgAction::Count)]
pub verbose: u8,
/// Turn off all output
#[arg(short = 'q', long, global = true)]
pub quiet: bool,
/// Path to config [default: `$XDG_CONFIG_HOME/hyprshell/config.ron`],
/// allowed file types: ron, toml, json5
#[arg(short = 'c', long, global = true)]
pub config_file: Option<PathBuf>,
/// Path to css [default: `$XDG_CONFIG_HOME/hyprshell/styles.css`]
#[arg(long, short = 's', global = true)]
pub css_file: Option<PathBuf>,
/// Path to data directory [default: `$XDG_DATA_HOME/hyprshell`]
#[arg(long, global = true)]
pub data_dir: Option<PathBuf>,
/// Path to cache directory [default: `$XDG_CACHE_HOME/hyprshell`]
#[arg(long, global = true)]
pub cache_dir: Option<PathBuf>,
/// Path to system data directory [default: `/usr/share/hyprshell`]
#[arg(long, global = true)]
pub system_data_dir: Option<PathBuf>,
}
#[derive(Subcommand, Debug, Clone)]
pub enum Command {
/// Run the hyprshell daemon
Run {},
/// Generate or check the config file
Config {
#[clap(subcommand)]
command: ConfigCommand,
},
#[cfg(feature = "debug_command")]
/// Debug command to debug finding icons for the GUI, desktop files, etc.
Debug {
#[clap(subcommand)]
command: DebugCommand,
},
/// Show data, like launch history, etc.
Data {
#[clap(subcommand)]
command: DataCommand,
},
/// Send json to the hyprshell socket
#[clap(hide = true)]
Socat {
/// JSON to send to the socket
json: String,
},
/// Generate completions for shells
Completions {
/// Shell to generate completion for (if not set completions for all shells will be generated)
shell: Option<String>,
/// BASE Path for completion without filename
/// Bash Default: `/usr/share/bash-completion/completions`
/// Fish Default: `/usr/share/fish/vendor_completions.d`
/// Zsh Default: `/usr/share/zsh/site-functions`
#[arg(long, short = 'p')]
base_path: Option<PathBuf>,
/// Delete the generated completion files
#[arg(short = 'd', long, default_value_t = false)]
delete: bool,
},
}
#[derive(Subcommand, Debug, Clone)]
pub enum ConfigCommand {
/// Generate a default config file (just opens GUI editor)
Generate {},
/// Edit the config file with a GUI
Edit {},
/// Check the config file for errors
Check {},
/// Explain how to use the program based on the config
Explain {},
#[cfg(feature = "ci_config_check")]
/// Check if the provided config is equal to the default config
CheckIfDefault {},
#[cfg(feature = "ci_config_check")]
/// Check if the provided config is equal to the fully enabled config
CheckIfFull {},
}
#[derive(Subcommand, Debug, Clone)]
pub enum DataCommand {
/// Show the history of launched applications
LaunchHistory {
/// weeks to include in the history, defaults to set config value
run_cache_weeks: Option<u8>,
},
}
#[derive(Subcommand, Debug, Clone)]
pub enum DebugCommand {
/// List all icons in the theme
ListIcons,
/// List all desktop files
ListDesktopFiles,
/// Search for an icon with a window class
CheckClass {
/// The class (from `hyprctl clients -j | jq -e ".[] | {title, class}"`) of a window to find an icon for
///
/// If not provided, all open windows will be searched
class: Option<String>,
},
/// simulate search in launcher and display search insights
Search {
/// text entered into the search box
text: String,
/// Show all matches, not just x ones like configured in config
#[arg(short = 'a', long)]
all: bool,
},
/// get or set default applications for different mime types
DefaultApplications {
#[clap(subcommand)]
command: DefaultApplicationsCommand,
},
/// print debug info
Info {},
}
#[derive(Subcommand, Debug, Clone)]
pub enum DefaultApplicationsCommand {
/// Get default app for mimetype
Get {
/// for example `image/png` of `x-scheme-handler/https`
mime: String,
},
/// Sets a default app for a mimetype (if one already exists, it is replaced)
Set {
/// for example `image/png` of `x-scheme-handler/https`
mime: String,
/// Name of a desktop file (with .desktop extension)
value: String,
},
/// Add an association app for mimetype (if one already exists, this one is placed before)
Add {
/// for example `image/png` of `x-scheme-handler/https`
mime: String,
/// Name of a desktop file (with .desktop extension)
value: String,
},
/// List default apps for all mimetypes
List {
/// Show all mimes instead of ony the ones used by hyprshell
#[arg(short = 'a', long)]
all: bool,
},
/// Check if all entries in all mimetype files point to valid desktop files
Check {},
}