forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiBbbbd35eIvan Molodetskikh1 year ago1693 commits

cli.rs101 lines, 3.1 KiBHistoryRawDownload
1use std::ffi::OsString;
2use std::path::PathBuf;
3
4use clap::{Parser, Subcommand};
5use niri_ipc::{Action, OutputAction};
6
7use crate::utils::version;
8
9#[derive(Parser)]
10#[command(author, version = version(), about, long_about = None)]
11#[command(args_conflicts_with_subcommands = true)]
12#[command(subcommand_value_name = "SUBCOMMAND")]
13#[command(subcommand_help_heading = "Subcommands")]
14pub struct Cli {
15 /// Path to config file (default: `$XDG_CONFIG_HOME/niri/config.kdl`).
16 ///
17 /// This can also be set with the `NIRI_CONFIG` environment variable. If both are set, the
18 /// command line argument takes precedence.
19 #[arg(short, long)]
20 pub config: Option<PathBuf>,
21 /// Import environment globally to systemd and D-Bus, run D-Bus services.
22 ///
23 /// Set this flag in a systemd service started by your display manager, or when running
24 /// manually as your main compositor instance. Do not set when running as a nested window, or
25 /// on a TTY as your non-main compositor instance, to avoid messing up the global environment.
26 #[arg(long)]
27 pub session: bool,
28 /// Command to run upon compositor startup.
29 #[arg(last = true)]
30 pub command: Vec<OsString>,
31
32 #[command(subcommand)]
33 pub subcommand: Option<Sub>,
34}
35
36#[derive(Subcommand)]
37pub enum Sub {
38 /// Communicate with the running niri instance.
39 Msg {
40 #[command(subcommand)]
41 msg: Msg,
42 /// Format output as JSON.
43 #[arg(short, long)]
44 json: bool,
45 },
46 /// Validate the config file.
47 Validate {
48 /// Path to config file (default: `$XDG_CONFIG_HOME/niri/config.kdl`).
49 ///
50 /// This can also be set with the `NIRI_CONFIG` environment variable. If both are set, the
51 /// command line argument takes precedence.
52 #[arg(short, long)]
53 config: Option<PathBuf>,
54 },
55 /// Cause a panic to check if the backtraces are good.
56 Panic,
57}
58
59#[derive(Subcommand)]
60pub enum Msg {
61 /// List connected outputs.
62 Outputs,
63 /// List workspaces.
64 Workspaces,
65 /// List open windows.
66 Windows,
67 /// List open layer-shell surfaces.
68 Layers,
69 /// Get the configured keyboard layouts.
70 KeyboardLayouts,
71 /// Print information about the focused output.
72 FocusedOutput,
73 /// Print information about the focused window.
74 FocusedWindow,
75 /// Perform an action.
76 Action {
77 #[command(subcommand)]
78 action: Action,
79 },
80 /// Change output configuration temporarily.
81 ///
82 /// The configuration is changed temporarily and not saved into the config file. If the output
83 /// configuration subsequently changes in the config file, these temporary changes will be
84 /// forgotten.
85 Output {
86 /// Output name.
87 ///
88 /// Run `niri msg outputs` to see the output names.
89 #[arg()]
90 output: String,
91 /// Configuration to apply.
92 #[command(subcommand)]
93 action: OutputAction,
94 },
95 /// Start continuously receiving events from the compositor.
96 EventStream,
97 /// Print the version of the running niri instance.
98 Version,
99 /// Request an error from the running niri instance.
100 RequestError,
101}