Logitech and Solaar

I’m making progress…

#!/bin/bash

if solaar config 1 | grep -q 'True' 
then solaar config 1 fn-swap 'false'
else solaar config 1 fn-swap 'true'
fi

I’m running this in terminal using the script:
#!/bin/bash
commands () {
~/Admin/fn-swap.sh
$SHELL # keep the terminal open after the previous commands are executed
}
export -f commands
konsole -e “bash -c ‘commands’”

I bound the sw.sh to the pause/break key - switches every time… so then I bound the fn-swap.sh and it switches without popping up terminal, it just takes a few seconds to take effect maybe due to the errors.

However, it works without opening solaar. Great.

No time wasted - once I figured the commands, I already bound ‘ON’ (ALT+[) ‘OFF’ (ALT+]) so I could easily use those. I just prefer the one key toggle :wink:

This is something I need to learn more about… so it’s all good practice.

I would have tried to store the state of fn-swap into a variable “myvariable”
myvariable=$(command to get the state of fn-swap)
But I don’t understand where that fn-swap state is coming from. Is solaar config 1 a file you’re reading from?

then compare it
if ["$myvariable" == "True"]

solaar config 1 is not a file to read; is a command of the executable solaar which in this case tell you the configuration of the device 1 (hint: is also possible to use the device’s name given by such command, instead of “1”.)

My example:

solaar config 1
Wireless Mobile Mouse MX Anywhere 2S (MX Anywhere 2S) [406A:EAE66939]

solaar config "MX Anywhere 2S"
Wireless Mobile Mouse MX Anywhere 2S (MX Anywhere 2S) [406A:EAE66939]

About the toggle script, assuming that “1” is your keyboard (in my case is 2)

#!/bin/bash

checkstatus=$(solaar config 1 | tail -1 | awk '{ print $3 }')

if [[ "$checkstatus" == "True" ]] ; then

        solaar config 1 fn-swap 'false'
   else
        solaar config 1 fn-swap 'true'
fi

Edit: I forget the dollar sign on the checkstatus variable :smiley:

3 Likes
checkstatus=$(solaar config 1 | tail -1 | awk '{ print $3 }')

if [[ "$checkstatus" == "True" ]] ; then

So much geekier than if solaar config 1 | grep -q 'True'

I love it.

As it takes a good 5-6 seconds to finish the job, I added a notification:

#!/bin/bash
checkstatus=$(solaar config 1 | tail -1 | awk '{ print $3 }')
echo "$checkstatus"
if [[ "$checkstatus" == "True" ]] ; then
        solaar config 1 fn-swap 'false' && notify-send 'Fn OFF'
   else
        solaar config 1 fn-swap 'true' && notify-send 'Fn ON'
fi
2 Likes

Wow, my new Samsung 860 EVO failed - had to reinstall to my old SanDisk for now, nice to have this to copy.

Lots of fun with hooks… you can solve a lot by totally deleting your fstab content. So now with no swap, had to edit /etc/default/grub (remove the wrong UUID resume) and regenerate grub, remove ‘resume’ from mkinitcpio.conf and ‘sudo mkinitcpio -P’, and also nano /etc/default/grub and basically just delete everything except my T3/T4 storage entries.

Annoyingly lost quite a bit of work there… only backed up hidden home files this week… after answering a thread I though I had done it right.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.