Skip to content

Commit

Permalink
Restore is_user of config. And change it to clash_srv_is_user.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanChane committed Apr 14, 2024
1 parent d99231b commit 5baee2a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ clash_core_path: "/usr/bin/mihomo"
clash_cfg_dir: "/srv/mihomo"
clash_cfg_path: "/srv/mihomo/config.yaml"
clash_srv_name: "mihomo" # systemctl {restart | stop} <clash_srv_name>
clash_srv_is_user: false # true: systemctl --user ...
```

If you have cargo, you can use `cargo install clashtui` to install clashtui.
Expand Down
1 change: 1 addition & 0 deletions README_ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ clash_core_path: "/usr/bin/mihomo"
clash_cfg_dir: "/srv/mihomo"
clash_cfg_path: "/srv/mihomo/config.yaml"
clash_srv_name: "mihomo" # systemctl {restart | stop} <clash_srv_name>
clash_srv_is_user: false # true: systemctl --user ...
```

如果有 cargo 则可以使用 `cargo install clashtui` 安装 clashtui。
Expand Down
1 change: 1 addition & 0 deletions clashtui/src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub struct ClashTuiConfig {
pub clash_cfg_path: String,
pub clash_core_path: String,
pub clash_srv_name: String,
pub clash_srv_is_user: bool, // true: systemctl --user ...

pub edit_cmd: Option<String>,
pub open_dir_cmd: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions clashtui/src/utils/tui/impl_clashsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ impl ClashTuiUtil {
match op {
ClashSrvOp::StartClashService => {
let mut args = vec!["restart", self.tui_cfg.clash_srv_name.as_str()];
if !toolkit::is_run_as_root() {
if self.tui_cfg.clash_srv_is_user {
args.push("--user")
}
let output1 = exec("systemctl", args)?; // Although the command execution is successful,
Expand All @@ -27,7 +27,7 @@ impl ClashTuiUtil {
}
ClashSrvOp::StopClashService => {
let mut args = vec!["stop", self.tui_cfg.clash_srv_name.as_str()];
if !toolkit::is_run_as_root() {
if self.tui_cfg.clash_srv_is_user {
args.push("--user")
}
let output1 = exec("systemctl", args)?;
Expand Down

0 comments on commit 5baee2a

Please sign in to comment.