Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ Use sudo (without dmenu) or polkit (with dmenu) while mounting/unmounting a driv
**Values**: "true", "false"
**Default**: "false"

### sudo.command

If you have `sudo` set to true this config says what program should be ran as a sudo. This config is mainly for doas users.

**Values**: Any string
**Default**: "sudo"

### dmenu.use

Use dmenu
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mounter"
version = "0.1.5"
version = "0.1.6"
edition = "2021"

[dependencies]
Expand Down
3 changes: 2 additions & 1 deletion src/preferences/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn is_valid(key: &str, value: &str) -> ValidationResult {
"true" | "false" => ValidationResult::Correct,
_ => ValidationResult::ValueError,
},
"dmenu.command" => {
"dmenu.command" | "sudo.command" => {
if value.len() > 0 {
ValidationResult::Correct
} else {
Expand All @@ -44,6 +44,7 @@ pub enum IsPresentResponse {
pub fn is_present(config: &HashMap<String, String>, key: &str) -> IsPresentResponse {
let defaults: HashMap<&str, &str> = [
("sudo", "false"),
("sudo.command", "sudo"),
("dmenu.use", "false"),
("dmenu.command", "dmenu"),
("dmenu.flags", ""),
Expand Down
16 changes: 13 additions & 3 deletions src/utils/mounting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub fn mount(mount_point: &MountPoint, preferences: &Preferences) {
"true" => true,
_ => false,
};
let sudo_command = get_value(&preferences.config, "sudo.command");
let use_dmenu = match get_value(&preferences.config, "dmenu.use").as_str() {
"true" => true,
_ => false,
Expand All @@ -31,7 +32,7 @@ pub fn mount(mount_point: &MountPoint, preferences: &Preferences) {
cmd.arg("mount");
cmd
} else {
let mut cmd = Command::new("sudo");
let mut cmd = Command::new(sudo_command);
cmd.arg("mount");
cmd
}
Expand Down Expand Up @@ -110,7 +111,7 @@ pub fn umount_addr(mount_location: &str, config: &HashMap<String, String>) {
"true" => true,
_ => false,
};

let sudo_command = get_value(config, "sudo.command");
let use_dmenu = match get_value(config, "dmenu.use").as_str() {
"true" => true,
_ => false,
Expand All @@ -122,7 +123,7 @@ pub fn umount_addr(mount_location: &str, config: &HashMap<String, String>) {
cmd.arg("umount");
cmd
} else {
let mut cmd = Command::new("sudo");
let mut cmd = Command::new(sudo_command);
cmd.arg("umount");
cmd
}
Expand All @@ -139,4 +140,13 @@ pub fn umount_addr(mount_location: &str, config: &HashMap<String, String>) {
eprintln!("Stderr: {}", String::from_utf8_lossy(&output.stderr));
exit(1);
}

console_log(
config,
format!(
"Drive that was mounted on {} was unmounted!",
mount_location
)
.as_str(),
)
}