Skip to content

Commit

Permalink
chore: clippy fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Enrico Stemmer <[email protected]>
  • Loading branch information
H3rmt committed Jan 18, 2025
1 parent 548db29 commit 1cd1633
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
with:
prefix-key: rust-build
- name: Build
run: cargo build
run: cargo build --release --all-features
- name: Test
run: cargo test --all-features

Expand Down
4 changes: 4 additions & 0 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ pub enum Command {
/// Specify a path to custom hyprswitch executable, uses current executable if not set
#[arg(long)]
exe: Option<PathBuf>,

/// Use systemd for starting the daemon
#[arg(long, default_value_t = true)]
systemd: bool,
},
/// Initialize and start the Daemon
Init {
Expand Down
36 changes: 25 additions & 11 deletions src/daemon/gui/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,23 @@ pub fn debug_gui(class: String, list: bool, desktop_files: bool) -> anyhow::Resu
gtk4::init().context("Failed to init gtk")?;
let theme = gtk4::IconTheme::new();
for icon in theme.icon_names() {
println!("Icon: {icon}");
#[allow(clippy::print_stdout)]
{
println!("Icon: {icon}");
}
}
}
(false, true) => {
let map = get_desktop_files_debug()?;

for (name, file) in map {
println!(
"Desktop file: {} [{:?}] -> {:?} from {:?}",
name.0, name.1, file.0, file.1,
);
#[allow(clippy::print_stdout)]
{
println!(
"Desktop file: {} [{:?}] -> {:?} from {:?}",
name.0, name.1, file.0, file.1,
);
}
}
}
_ => {
Expand All @@ -26,18 +32,26 @@ pub fn debug_gui(class: String, list: bool, desktop_files: bool) -> anyhow::Resu
return Ok(());
}

println!("Icon for class {class}");
#[allow(clippy::print_stdout)]
{
println!("Icon for class {class}");
}
gtk4::init().context("Failed to init gtk")?;
let theme = gtk4::IconTheme::new();

let name = get_icon_name_debug(&class)
.with_context(|| format!("Failed to get icon name for class {class}"))?;
println!(
"Icon: {:?} from desktop file cache: {:?} found by {:?}",
name.0, name.2, name.1
);
#[allow(clippy::print_stdout)]
{
println!(
"Icon: {:?} from desktop file cache: {:?} found by {:?}",
name.0, name.2, name.1
);
}
if theme.has_icon(&class) {
println!("Theme contains icon for class {class}");
#[allow(clippy::print_stdout)] {
println!("Theme contains icon for class {class}");
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/daemon/gui/maps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ pub(in crate::daemon::gui) fn get_icon_name_debug(
find_icon_path_by_name(map, icon)
}

#[allow(clippy::type_complexity)]
pub(in crate::daemon::gui) fn get_desktop_files_debug(
) -> anyhow::Result<HashMap<(Box<str>, Source), (Box<Path>, Box<Path>)>> {
let mut map = HashMap::new();
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() -> anyhow::Result<()> {

envvar_dump();

let _ = check_version().warn("Unable to check Hyprland version, continuing anyway");
check_version().warn("Unable to check Hyprland version, continuing anyway");

global::DRY
.set(cli.global_opts.dry_run)
Expand All @@ -56,7 +56,7 @@ fn main() -> anyhow::Result<()> {

match cli.command {
#[cfg(feature = "config")]
cli::Command::Generate { exe } => {
cli::Command::Generate { exe, .. } => {
info!("Loading config");
let config = hyprswitch::config::load().context("Failed to load config")?;
hyprswitch::config::validate(&config).context("Failed to validate config")?;
Expand Down

0 comments on commit 1cd1633

Please sign in to comment.