mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-19 23:31:25 +02:00
refactor(clippy): apply lints
This commit is contained in:
@@ -128,7 +128,7 @@ fn stop_powershell() -> Result<()> {
|
|||||||
|
|
||||||
pub fn exec_powershell(cmd: &str) -> Result<()> {
|
pub fn exec_powershell(cmd: &str) -> Result<()> {
|
||||||
if let Some(session_stdin) = SESSION_STDIN.lock().as_mut() {
|
if let Some(session_stdin) = SESSION_STDIN.lock().as_mut() {
|
||||||
if let Err(e) = writeln!(session_stdin, "{}", cmd) {
|
if let Err(e) = writeln!(session_stdin, "{cmd}") {
|
||||||
tracing::error!(error = %e, cmd = cmd, "failed to write command to PowerShell stdin");
|
tracing::error!(error = %e, cmd = cmd, "failed to write command to PowerShell stdin");
|
||||||
return Err(e);
|
return Err(e);
|
||||||
}
|
}
|
||||||
@@ -635,8 +635,7 @@ impl Komobar {
|
|||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
home.is_dir(),
|
home.is_dir(),
|
||||||
"$Env:KOMOREBI_CONFIG_HOME is set to '{}', which is not a valid directory",
|
"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
|
||||||
home_path
|
|
||||||
);
|
);
|
||||||
|
|
||||||
home
|
home
|
||||||
|
|||||||
@@ -159,8 +159,7 @@ fn main() -> color_eyre::Result<()> {
|
|||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
home.is_dir(),
|
home.is_dir(),
|
||||||
"$Env:KOMOREBI_CONFIG_HOME is set to '{}', which is not a valid directory",
|
"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
|
||||||
home_path
|
|
||||||
);
|
);
|
||||||
|
|
||||||
home
|
home
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ impl BarWidget for Battery {
|
|||||||
.args(["/C", "start", "ms-settings:batterysaver"])
|
.args(["/C", "start", "ms-settings:batterysaver"])
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{}", error)
|
eprintln!("{error}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ impl Cpu {
|
|||||||
|
|
||||||
CpuOutput {
|
CpuOutput {
|
||||||
label: match self.label_prefix {
|
label: match self.label_prefix {
|
||||||
LabelPrefix::Text | LabelPrefix::IconAndText => format!("CPU: {}%", used),
|
LabelPrefix::Text | LabelPrefix::IconAndText => format!("CPU: {used}%"),
|
||||||
LabelPrefix::None | LabelPrefix::Icon => format!("{}%", used),
|
LabelPrefix::None | LabelPrefix::Icon => format!("{used}%"),
|
||||||
},
|
},
|
||||||
selected,
|
selected,
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ impl BarWidget for Cpu {
|
|||||||
if let Err(error) =
|
if let Err(error) =
|
||||||
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{}", error)
|
eprintln!("{error}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ impl Date {
|
|||||||
.to_string()
|
.to_string()
|
||||||
.trim()
|
.trim()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
Err(_) => format!("Invalid timezone: {}", timezone),
|
Err(_) => format!("Invalid timezone: {timezone}"),
|
||||||
},
|
},
|
||||||
None => Local::now()
|
None => Local::now()
|
||||||
.format(&self.format.fmt_string())
|
.format(&self.format.fmt_string())
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ impl<'de> Deserialize<'de> for KomorebiLayout {
|
|||||||
let s: String = String::deserialize(deserializer)?;
|
let s: String = String::deserialize(deserializer)?;
|
||||||
|
|
||||||
// Attempt to deserialize the string as a DefaultLayout
|
// Attempt to deserialize the string as a DefaultLayout
|
||||||
if let Ok(default_layout) =
|
if let Ok(default_layout) = from_str::<komorebi_client::DefaultLayout>(&format!("\"{s}\""))
|
||||||
from_str::<komorebi_client::DefaultLayout>(&format!("\"{}\"", s))
|
|
||||||
{
|
{
|
||||||
return Ok(KomorebiLayout::Default(default_layout));
|
return Ok(KomorebiLayout::Default(default_layout));
|
||||||
}
|
}
|
||||||
@@ -53,7 +52,7 @@ impl<'de> Deserialize<'de> for KomorebiLayout {
|
|||||||
"Floating" => Ok(KomorebiLayout::Floating),
|
"Floating" => Ok(KomorebiLayout::Floating),
|
||||||
"Paused" => Ok(KomorebiLayout::Paused),
|
"Paused" => Ok(KomorebiLayout::Paused),
|
||||||
"Custom" => Ok(KomorebiLayout::Custom),
|
"Custom" => Ok(KomorebiLayout::Custom),
|
||||||
_ => Err(Error::custom(format!("Invalid layout: {}", s))),
|
_ => Err(Error::custom(format!("Invalid layout: {s}"))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,9 +79,9 @@ impl Memory {
|
|||||||
MemoryOutput {
|
MemoryOutput {
|
||||||
label: match self.label_prefix {
|
label: match self.label_prefix {
|
||||||
LabelPrefix::Text | LabelPrefix::IconAndText => {
|
LabelPrefix::Text | LabelPrefix::IconAndText => {
|
||||||
format!("RAM: {}%", usage)
|
format!("RAM: {usage}%")
|
||||||
}
|
}
|
||||||
LabelPrefix::None | LabelPrefix::Icon => format!("{}%", usage),
|
LabelPrefix::None | LabelPrefix::Icon => format!("{usage}%"),
|
||||||
},
|
},
|
||||||
selected,
|
selected,
|
||||||
}
|
}
|
||||||
@@ -128,7 +128,7 @@ impl BarWidget for Memory {
|
|||||||
if let Err(error) =
|
if let Err(error) =
|
||||||
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
Command::new("cmd.exe").args(["/C", "taskmgr.exe"]).spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{}", error)
|
eprintln!("{error}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -314,7 +314,7 @@ impl Network {
|
|||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
if let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn() {
|
if let Err(error) = Command::new("cmd.exe").args(["/C", "ncpa"]).spawn() {
|
||||||
eprintln!("{}", error);
|
eprintln!("{error}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -535,6 +535,6 @@ enum DataUnit {
|
|||||||
|
|
||||||
impl fmt::Display for DataUnit {
|
impl fmt::Display for DataUnit {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{:?}", self)
|
write!(f, "{self:?}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ impl Storage {
|
|||||||
LabelPrefix::Text | LabelPrefix::IconAndText => {
|
LabelPrefix::Text | LabelPrefix::IconAndText => {
|
||||||
format!("{} {}%", mount.to_string_lossy(), percentage)
|
format!("{} {}%", mount.to_string_lossy(), percentage)
|
||||||
}
|
}
|
||||||
LabelPrefix::None | LabelPrefix::Icon => format!("{}%", percentage),
|
LabelPrefix::None | LabelPrefix::Icon => format!("{percentage}%"),
|
||||||
},
|
},
|
||||||
selected,
|
selected,
|
||||||
})
|
})
|
||||||
@@ -151,7 +151,7 @@ impl BarWidget for Storage {
|
|||||||
])
|
])
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{}", error)
|
eprintln!("{error}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -209,7 +209,7 @@ impl Time {
|
|||||||
Some(dt.time()),
|
Some(dt.time()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Err(_) => (format!("Invalid timezone: {:?}", timezone), None),
|
Err(_) => (format!("Invalid timezone: {timezone:?}"), None),
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
let dt = Local::now();
|
let dt = Local::now();
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ impl BarWidget for Update {
|
|||||||
)])
|
)])
|
||||||
.spawn()
|
.spawn()
|
||||||
{
|
{
|
||||||
eprintln!("{}", error)
|
eprintln!("{error}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -17,5 +17,5 @@ pub enum AnimationPrefix {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_animation_key(prefix: AnimationPrefix, key: String) -> String {
|
pub fn new_animation_key(prefix: AnimationPrefix, key: String) -> String {
|
||||||
format!("{}:{}", prefix, key)
|
format!("{prefix}:{key}")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -302,7 +302,7 @@ mod tests {
|
|||||||
let deserialized: Container =
|
let deserialized: Container =
|
||||||
serde_json::from_str(&serialized).expect("Should deserialize");
|
serde_json::from_str(&serialized).expect("Should deserialize");
|
||||||
|
|
||||||
assert_eq!(deserialized.locked(), true);
|
assert!(deserialized.locked());
|
||||||
assert_eq!(deserialized.id(), container.id());
|
assert_eq!(deserialized.id(), container.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -200,8 +200,7 @@ lazy_static! {
|
|||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
home.is_dir(),
|
home.is_dir(),
|
||||||
"$Env:KOMOREBI_CONFIG_HOME is set to '{}', which is not a valid directory",
|
"$Env:KOMOREBI_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
|
||||||
home_path
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -331,12 +331,12 @@ mod tests {
|
|||||||
let mut ring = test_deque(&[(0, false), (1, true), (2, false), (3, false)]);
|
let mut ring = test_deque(&[(0, false), (1, true), (2, false), (3, false)]);
|
||||||
ring.swap_respecting_locks(0, 1);
|
ring.swap_respecting_locks(0, 1);
|
||||||
assert_eq!(vals(&ring), vec![1, 0, 2, 3]);
|
assert_eq!(vals(&ring), vec![1, 0, 2, 3]);
|
||||||
assert_eq!(ring[0].locked, false);
|
assert!(!ring[0].locked);
|
||||||
assert_eq!(ring[1].locked, true);
|
assert!(ring[1].locked);
|
||||||
ring.swap_respecting_locks(0, 1);
|
ring.swap_respecting_locks(0, 1);
|
||||||
assert_eq!(vals(&ring), vec![0, 1, 2, 3]);
|
assert_eq!(vals(&ring), vec![0, 1, 2, 3]);
|
||||||
assert_eq!(ring[0].locked, false);
|
assert!(!ring[0].locked);
|
||||||
assert_eq!(ring[1].locked, true);
|
assert!(ring[1].locked);
|
||||||
|
|
||||||
// Both locked
|
// Both locked
|
||||||
let mut ring = test_deque(&[(0, true), (1, false), (2, true)]);
|
let mut ring = test_deque(&[(0, true), (1, false), (2, true)]);
|
||||||
|
|||||||
@@ -801,7 +801,7 @@ mod tests {
|
|||||||
let wm = match WindowManager::new(receiver, Some(socket_path.clone())) {
|
let wm = match WindowManager::new(receiver, Some(socket_path.clone())) {
|
||||||
Ok(manager) => manager,
|
Ok(manager) => manager,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
panic!("Failed to create WindowManager: {}", e);
|
panic!("Failed to create WindowManager: {e}");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -829,7 +829,7 @@ mod tests {
|
|||||||
Ok(notification) => {
|
Ok(notification) => {
|
||||||
assert_eq!(notification, MonitorNotification::ResolutionScalingChanged);
|
assert_eq!(notification, MonitorNotification::ResolutionScalingChanged);
|
||||||
}
|
}
|
||||||
Err(e) => panic!("Failed to receive MonitorNotification: {}", e),
|
Err(e) => panic!("Failed to receive MonitorNotification: {e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -849,7 +849,7 @@ mod tests {
|
|||||||
for _ in 0..20 {
|
for _ in 0..20 {
|
||||||
let notification = match receiver.try_recv() {
|
let notification = match receiver.try_recv() {
|
||||||
Ok(notification) => notification,
|
Ok(notification) => notification,
|
||||||
Err(e) => panic!("Failed to receive MonitorNotification: {}", e),
|
Err(e) => panic!("Failed to receive MonitorNotification: {e}"),
|
||||||
};
|
};
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
notification,
|
notification,
|
||||||
@@ -960,7 +960,7 @@ mod tests {
|
|||||||
Ok(notification) => {
|
Ok(notification) => {
|
||||||
assert_eq!(notification, MonitorNotification::DisplayConnectionChange);
|
assert_eq!(notification, MonitorNotification::DisplayConnectionChange);
|
||||||
}
|
}
|
||||||
Err(e) => panic!("Failed to receive MonitorNotification: {}", e),
|
Err(e) => panic!("Failed to receive MonitorNotification: {e}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1180,6 +1180,7 @@ impl WindowsApi {
|
|||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn enable_focus_follows_mouse() -> Result<()> {
|
pub fn enable_focus_follows_mouse() -> Result<()> {
|
||||||
|
#[allow(clippy::manual_dangling_ptr)]
|
||||||
Self::system_parameters_info_w(
|
Self::system_parameters_info_w(
|
||||||
SPI_SETACTIVEWINDOWTRACKING,
|
SPI_SETACTIVEWINDOWTRACKING,
|
||||||
0,
|
0,
|
||||||
|
|||||||
@@ -92,8 +92,7 @@ lazy_static! {
|
|||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
whkd_config_home.is_dir(),
|
whkd_config_home.is_dir(),
|
||||||
"$Env:WHKD_CONFIG_HOME is set to '{}', which is not a valid directory",
|
"$Env:WHKD_CONFIG_HOME is set to '{home_path}', which is not a valid directory"
|
||||||
home_path
|
|
||||||
);
|
);
|
||||||
|
|
||||||
whkd_config_home
|
whkd_config_home
|
||||||
|
|||||||
Reference in New Issue
Block a user