I bought this simple ass little macropad that uses real keyboard switches and for like a year I had no idea how to use it. There was no dirt simple file configed little command I can plant in my i3/config and be happy with it so I built it!

It was my first attempt at building a production-level thing out of rust and I’m really happy with it. Now I can finally use my goddamn macropad!!

  • ExLisper@lemmy.curiana.net
    link
    fedilink
    arrow-up
    4
    ·
    12 days ago
       let config = match maybe_config {
            Some(c) => c,
            None => {
                panic!("didn't find config file");
            }
        };
    

    let config = maybe_config.expect("didn't find config file");

    :)

    I like the community idea. Hope to see more posts here.

    • danhab99OPM
      link
      fedilink
      arrow-up
      2
      ·
      12 days ago

      Yeah this was written before I knew too much about rust, the syntax can definitely be reworked I just need to find the time.

  • CameronDev
    link
    fedilink
    arrow-up
    1
    ·
    12 days ago
                let c_raw = cmd.to_string();
    
                thread::spawn(move || {
                    let c = Command::new("/bin/sh")
                        .args(["-c", c_raw.as_str()])
                        .output();
    

    Did you try just splitting the c_raw into its command using shlex. Could save the intermediate sh process?

    Edit: I guess you could also be using it for $PATH, in which case fair enough.

    • danhab99OPM
      link
      fedilink
      arrow-up
      2
      ·
      12 days ago

      I have a vague memory that this is how I wrote it but now I’m noticing that I did that in similar projects and got my memory crossed… I need to do this.