forge
Explore
Log in

Don't you dare go Hollow

niri

Clone
★ 0

0 watching0 forksRustGPL-3.012.1 MiB289ae36Ivan Molodetskikh2 years ago1428 commits

cli.rs99 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 /// Get the configured keyboard layouts.
68 KeyboardLayouts,
69 /// Print information about the focused output.
70 FocusedOutput,
71 /// Print information about the focused window.
72 FocusedWindow,
73 /// Perform an action.
74 Action {
75 #[command(subcommand)]
76 action: Action,
77 },
78 /// Change output configuration temporarily.
79 ///
80 /// The configuration is changed temporarily and not saved into the config file. If the output
81 /// configuration subsequently changes in the config file, these temporary changes will be
82 /// forgotten.
83 Output {
84 /// Output name.
85 ///
86 /// Run `niri msg outputs` to see the output names.
87 #[arg()]
88 output: String,
89 /// Configuration to apply.
90 #[command(subcommand)]
91 action: OutputAction,
92 },
93 /// Start continuously receiving events from the compositor.
94 EventStream,
95 /// Print the version of the running niri instance.
96 Version,
97 /// Request an error from the running niri instance.
98 RequestError,
99}