Skip to content

Tag: linux

Hook and block globally mouse in X11

I need to hook globally mouse clicks and block last click if delay between two clicks is less than was set. I wrote it for windows using WM_MOUSE_LL hook. I was unable to find any solution for me. Is it even possible to globally block mouse click in X11 ? Windows full code Answer As far as I know the

Why cat 0>file doesn’t work

In Unix, I know that 0 1 and 2 represent stdin stdout and stderr. As my understanding, the command cat meaning “concatenate” can concatenate different files. For example, cat file>&1 can concatenate the file and the stdout and the arrow means the redirection from the fileto the stdout, so w…

Executing Bash commands using C code

I’m trying to use file.cpp to execute some simple bash commands. Code works for commands like ls, gedit, echo but fails at cd command. Here is my file.cpp: I execute it after compiling using ./file and my terminal output is, Current directory didn’t change to /etc. I have tried changing cd /etc to…

Linux enable pca9685 in sysfs

I would like to enable a PCA9685 as a PWM in /sys/class/pwm/. The Platform is a Raspberry Pi 2 and the chip is connected to /dev/i2c-1. I find the chip with i2c-detect, but i don’t know how do I enable this driver: http://lxr.free-electrons.com/source/drivers/pwm/pwm-pca9685.c. I also found this but it …

gpinitsystem unknown host mdw

I am sure that there are no extra spaces before or after your hostname(S) in the host file, and using ssh mdw can connect to mdw. The /etc/hosts is like this: The error log: please. Answer How many hosts there are in your greenplum. Your /etc/hosts doesn’t contain any information about mdw and sdw. Assu…

How to use grep in shell with -e option set

In bash -e option stops executing after an error and grep commands returns a non-zero status in case it does not find for the pattern it is looking for. I want to use grep inside an if statement, something like If i use $? to get the statement of last command, then the execution stops after last command as gr…