Toggle Touchpad Enable & Disable

Here is my simple script to help me toggle touchpad enable & disable in NixOS running on Thinkpad R61.


# Try disabling the libinput device.

d=`xinput list | grep -i touchpad | awk '{for(i=1;i<=NF;i++){ tmp=match($i, /id=[0-9]/); if(tmp){print $i} } }' | awk --field-separator== '{ print $2 }'`
echo 'xinput list'
echo " SynPS/2 Synaptics TouchPad device ID: $d"

# Find the touchpad, in my case it's called "SynPS/2 Synaptics TouchPad", with ID 11.
echo "xinput list-props $d"
de=`xinput list-props $d | grep 'Device Enabled' | awk '{ print $3}' | awk --field-separator=\( '{print $2}' | awk --field-separator=\) '{print $1}'`
ds=`xinput list-props $d | grep 'Device Enabled' | awk '{ print $4}'`
echo " Device Enabled setting ID: $de, Device Enabled status: $ds"

if [ $ds == 0 ]; then
 #echo "Set new status to: $newStatus"
elif [ $ds == 1 ]; then
 #echo "Set new status to: $newStatus"

# There should be one called 'Device Enabled'; at least mine has.
echo "xinput set-prop $d $de $newStatus"
xinput set-prop $d $de $newStatus

ds2=`xinput list-props $d | grep 'Device Enabled' | awk '{ print $4}'`
echo " Device Enabled setting ID: $de, Device Enabled status: $ds2"



Git for web development

Here we will discus on how to manage web development code and deploy to web server.

/web server dev & \ ---->  [git repo] ------->[web server staging]
\local git workdir/              |
                                 +----------->[web server prod]

Base on above diagram, there is 4 server involve:

  • dev – web server for development & local git work directory. Each programmer have their own development server, maybe running in virtual machine on their laptop.
  • stag – web server for staging before being push to production web server. This server will be tested by our test team and then also by client. Client will approve the changes to be push to production server. We have full control of our dev and stag server, so we can ssh to the servers.
  • prod – production web server. This server may not have connection ssh, usually only ftp transfer allow.
  • gitrepo – bare git repository. This git repo server will act as centralize git repo, where each developer/programmer will push their commit to the server.

Work flow

  1. Programmer will do coding on their own development server with local git workdir (dev). Do commit, etc.
  2. Then do pull and push their staging branch to staging branch at staging server.
  3. ….staging branch centralize git repo (gitrepo) via ssh connection.
  4. … prod branch to prod branch in gitrepo via ssh.
  5. gitrepo will do ftp to  prod server.

Configuration file