The most fun I've had in... A week

So I forgot to take my epilepsy medication this morning. When I do forget, I feel amazing… For a while… And then I begin to feel like I just ate 4 entire pizzas and I’m about to explode on the floor while being ridiculously hungry and light headed… So that’s bound to come soon. And my best friend just asked this one girl I was going to ask out, and she said yes so it has been one hell of a week. So when I am out of it I tend to get a lot of programming in… But uhh… Anyway. While I feel good let’s get to the point.

I’ve been a long time programmer and Linux enthusiast for a while and I’ve done some pretty cool stuff with projects like CarbonROM and nonprofits like the IMHS, but I was in the mood for something simple. Shell scripting. I wanted my touchpad to adjust settings when I launch Steam so I created this monstrosity…

https://github.com/CertifiedBlyndGuy/Scripts

And shockingly I actually learned a bit which I wasn’t expecting. First off, GNU parallel is actually kind of sweet and here is why.

I wanted to launch Steam and run my script that adjusts Xinput at the same time. I couldn’t do that with a typical bash script because processes are ran consecutive to one another and not concurrently. So that was a big problem. Luckily, parallel let’s you do this in either this syntax:

parallel ::: steam touchpad.sh

Or:

(echo steam; echo touchpad.sh) | parallel

So pretty easy right? WRONG. I’m much cooler than that and that’s too simple. I wanted my script to actually check for steam which is possibly if we use pgrep. In this case, I did:

if [[ -n $fast ]] || pgrep -x “steam” > /dev/null

So, I also had profiles implemented to that could be enabled by running the touchpad script with an input. In this case it would be launched with “fast” after the script name in the terminal. If ran when Steam is running without the profile selected it accomplishes the same thing.

It’s important to check for /dev/null instead of 0 because otherwise a file titled 0 will be assigned to that specific case which is incredibly unoptimal. Lot’s of developers use 0 in these cases instead and while it isn’t wrong it certainly isn’t the best way of handling comparisons

So there’s that. Also wasn’t aware that xinput could interface with libinput so that was cool to find out. I plan to expand on this in the future with more misc unrelated scripts. Manjaro doesn’t directly support my touchpad so I had to do a bit of my own work on this. Figured I’d make it worth doing instead of a pointless project.

None of this information was probably useful to you. I just wanted to get the word out because parallel is actually pretty cool. Granted, I had to add a timer to my script but whatever.

Sorry if my thoughts are way more jumbled than usual. Like I said, I’m off my medication. I probably confused someone in some way so if you have medication than just ask.

6 Likes

“if you have medication than just ask.” Oh shit I need sleep.

My source code can probably explain a lot better than I can right now

3 Likes

Im more doctors are just people too. Id let you play in the wiggle room.

I am it seems a strong human. I dont get sick. I drink a lot and Im big and scare people with boo.

We are more and more needing doctors to live. So while I dont need them I would never say dont do what the doctor says.

Darwin.

1 Like

It wasn’t intentional. I forget sometimes

1 Like

We all need :slight_smile:

1 Like