Intention
I intend to replace my own Bash script executing the following commands indefinitely in favor of this C++ compiled code, the reason being that the Bash script seemed very CPU ineffective.
It's not that I would think this solution is effective, nor perfect, but better than the one written in Bash for there is a great overhead over time.
The two commands are very simple:
/usr/bin/numlockx on
sleep 1
Environment
Linux Mint 18 with Cinnamon desktop environment.
Purpose
As I don't have a Num Lock indicator on my laptop, I want to ensure the Num Lock is always turned on.
xmodmap
I have tried using this utility, but it literally, excuse my wording, crippled my key mappings, which I have set up from inside Cinnamon DE.
Current C++ code
#include <cstdlib> // in order to use system function
#include <unistd.h> // in order to use sleep function
int main()
{
do {
system("/usr/bin/numlockx on");
sleep(1);
} while (true);
return 0;
}
This is compiled with g++ 5.x as follows:
g++ numlock-always-on.c -o "numlock-always-on"