summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vtcol.rs53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/vtcol.rs b/src/vtcol.rs
index a3ff57b..183da18 100644
--- a/src/vtcol.rs
+++ b/src/vtcol.rs
@@ -134,7 +134,7 @@ enum FlagJob
/** Set all keyboard flags at once. */
Set(KbLedFlags),
/** Set keyboard LED state of individual LEDs. */
- SetIndividual(Option<bool>, Option<bool>, Option<bool>),
+ SetIndividual(bool, Option<bool>, Option<bool>, Option<bool>),
}
impl FlagJob
@@ -171,6 +171,7 @@ impl FlagJob
/** Set / unset keyboard flags using the current as base. */
fn set_individual(
con: Option<String>,
+ dflt: bool,
cap: Option<bool>,
num: Option<bool>,
scr: Option<bool>,
@@ -181,9 +182,15 @@ impl FlagJob
let mut st = KbLedFlags::get(&fd)?;
- cap.map(|b| st.set_cap(b));
- num.map(|b| st.set_num(b));
- scr.map(|b| st.set_scr(b));
+ if dflt {
+ cap.map(|b| st.set_default_cap(b));
+ num.map(|b| st.set_default_num(b));
+ scr.map(|b| st.set_default_scr(b));
+ } else {
+ cap.map(|b| st.set_cap(b));
+ num.map(|b| st.set_num(b));
+ scr.map(|b| st.set_scr(b));
+ }
st.set(&fd)?;
vrb!("applied");
@@ -199,8 +206,8 @@ impl Run for FlagJob
match self {
Self::Get(raw) => Self::get(console, raw),
Self::Set(flags) => Self::set(console, flags),
- Self::SetIndividual(c, n, s) =>
- Self::set_individual(console, c, n, s),
+ Self::SetIndividual(dflt, c, n, s) =>
+ Self::set_individual(console, dflt, c, n, s),
}
}
} /* [impl Run for FlagJob] */
@@ -675,25 +682,31 @@ impl<'a> Job
)
.takes_value(true)
.required_unless_one(&[
- "revert", "caps", "num",
- "scroll",
+ "caps", "num", "scroll",
])
.conflicts_with_all(&[
- "revert", "caps", "num",
- "scroll",
+ "dflt", "caps", "num", "scroll",
])
.value_name("STATE"),
)
.arg(
+ Arg::with_name("dflt")
+ .short("d")
+ .long("default")
+ .help(
+ "operate on defaults, not the \
+ current state",
+ )
+ .takes_value(false),
+ )
+ .arg(
Arg::with_name("caps")
.short("c")
.long("caps")
.help("[de]activate Caps Lock flag")
.takes_value(true)
.possible_values(&["on", "off"])
- .conflicts_with_all(&[
- "revert", "u8",
- ])
+ .conflicts_with("u8")
.value_name("STATE"),
)
.arg(
@@ -703,9 +716,7 @@ impl<'a> Job
.help("[de]activate Num Lock flag")
.takes_value(true)
.possible_values(&["on", "off"])
- .conflicts_with_all(&[
- "revert", "u8",
- ])
+ .conflicts_with("u8")
.value_name("STATE"),
)
.arg(
@@ -717,9 +728,7 @@ impl<'a> Job
)
.takes_value(true)
.possible_values(&["on", "off"])
- .conflicts_with_all(&[
- "revert", "u8",
- ])
+ .conflicts_with("u8")
.value_name("STATE"),
),
),
@@ -922,6 +931,8 @@ impl<'a> Job
))),
));
}
+
+ let dflt = subm.is_present("dflt");
let cap =
subm.value_of("caps").map(|a| a == "on");
let num =
@@ -931,7 +942,9 @@ impl<'a> Job
Ok(Self(
con,
Subcmd::Kb(KbJob::Flags(
- FlagJob::SetIndividual(cap, num, scr),
+ FlagJob::SetIndividual(
+ dflt, cap, num, scr,
+ ),
)),
))
},