Advertisement
Guest User

mymessyconfigs

a guest
Nov 16th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.06 KB | None | 0 0
  1. #----------------------------------------------------------------------
  2. #hinge-sensor (/etc/acpi/events)
  3. event=video/tabletmode
  4. action=/etc/acpi/actions/hinge-sensor.sh %e
  5.  
  6. #----------------------------------------------------------------------
  7. #hinge-sensor.sh (/etc/acpi/actions/hinge-sensor.sh)
  8. #!/bin/bash
  9. pid=$( ps ax | grep "lightdm --session-child" | grep -v grep | awk '{print $1}')
  10. pid=$(pgrep -P $pid -n)
  11.  
  12. import_environment() {
  13.         (( pid )) && for var; do
  14.                 IFS='=' read key val < <(egrep -z "$var" /proc/$pid/environ)
  15.  
  16.                 printf -v "$key" %s "$val"
  17.                 [[ ${!key} ]] && export "$key"
  18.         done
  19. }
  20.  
  21. import_environment XAUTHORITY USER DISPLAY
  22.  
  23. logger 'beginning tablet mode test'
  24.  
  25. case "$2" in
  26.     TBLT)
  27.         logger 'tablet sensor triggered'
  28.         case "$4" in
  29.             00000001)
  30.                 logger 'tablet mode 1'
  31.                 #su -c `notify-send "Tablet mode engaged"` $USER
  32.                 su -c "/home/$USER/bin/acpi/tabletmode 1" $USER
  33.                 ;;
  34.  
  35.             00000000)
  36.                 logger 'tablet mode 0'
  37.                 #su -c `notify-send "Tablet mode disengaged"` $USER    
  38.                 su -c "/home/$USER/bin/acpi/tabletmode 0" $USER
  39.                 ;;
  40.         esac
  41.         ;;
  42.     *) 
  43.         su -c "notify-send "undefined action" "tablet mode undefined action: $1 $2 $3 $4"" $USER
  44.         logger 'tablet mode action undefined: $1 $2 $3 $4'
  45.         ;;
  46. esac
  47. #======================================================================
  48.  
  49. #----------------------------------------------------------------------
  50. #ibmspecialkeys (/etc/acpi/events)
  51. event=ibm/hotkey
  52. action=/etc/acpi/actions/ibmspecialkeys.sh %e
  53.  
  54. #======================================================================
  55.  
  56. #----------------------------------------------------------------------
  57. #ibmspecialkeys.sh (/etc/acpi/actions/ibmspecialkeys.sh)
  58. #!/bin/bash
  59. pid=$( ps ax | grep "lightdm --session-child" | grep -v grep | awk '{print $1}')
  60. pid=$(pgrep -P $pid -n)
  61.  
  62. import_environment() {
  63.         (( pid )) && for var; do
  64.                 IFS='=' read key val < <(egrep -z "$var" /proc/$pid/environ)
  65.  
  66.                 printf -v "$key" %s "$val"
  67.                 [[ ${!key} ]] && export "$key"
  68.         done
  69. }
  70.  
  71. import_environment XAUTHORITY USER DISPLAY
  72.  
  73. #logger "pid:$pid"
  74. #logger "XAUTHORITY:$XAUTHORITY USER:$USER DISPLAY:$DISPLAY"
  75.  
  76. case "$4" in
  77.     00001311)
  78.         logger 'favorites button pressed'
  79.         #/home/$USER/bin/notify-send-root "favorites button pressed" "$1 $2 $3 $4"
  80.         su -c "/home/$USER/bin/acpi/ibm-keyconfig star-symbol" $USER
  81.         ;;
  82.     00001315)
  83.         logger 'keyboard symbol button pressed'
  84.         su -c "/home/$USER/bin/acpi/ibm-keyconfig keyboard-symbol" $USER
  85.         ;;
  86.  
  87.     *)
  88.         logger "ACPI action undefined: $1"
  89.         ;;
  90. esac
  91. #======================================================================
  92.  
  93. #----------------------------------------------------------------------
  94. mouse-config (/home/$USER/bin)
  95.  
  96. #!/bin/bash
  97. #mouse configuration
  98. #hint: use xinput list for a list of devices and their associated ids
  99. #hint: use xinput list-prods "${id}" to get a list of properties of device
  100. #Xorg
  101. #==================================
  102. #--------------------------------
  103. #device:Trackpoint
  104. id="ETPS/2 Elantech TrackPoint"
  105.  
  106. xinput --set-prop "${id}" 'libinput Natural Scrolling Enabled' 0
  107. xinput --set-prop "${id}" 'libinput Left Handed Enabled' 0
  108. xinput --set-prop "${id}" 'libinput Accel Speed' 1
  109. xinput --set-prop "${id}" 'libinput Accel Profiles Available' 0, 1
  110. xinput --set-prop "${id}" 'libinput Accel Profile Enabled' 0, 1
  111. xinput --set-prop "${id}" 'libinput Button Scrolling Button' 2
  112. xinput --set-prop "${id}" 'libinput Middle Emulation Enabled' 1
  113. xinput --set-prop "${id}" 'libinput Send Events Mode Enabled' 0, 0
  114. xinput --set-prop "${id}" 'libinput Horizontal Scroll Enabled' 1
  115. #xinput --set-prop "${id}" 'libinput Scroll Methods Available' 0, 0, 1
  116. #xinput --set-prop "${id}" 'libinput Send Events Modes Available' 1, 0
  117. #--------------------------------
  118.  
  119. #device:Touchpad
  120. #id=14
  121. #xinput --set-prop "${id}"
  122.  
  123. #==================================
  124.  
  125. #======================================================================
  126.  
  127. #----------------------------------------------------------------------
  128. #ibmspecialkeys.sh (/home/$USER/bin/acpi)
  129. #!/bin/bash
  130. pid=$( ps ax | grep "lightdm --session-child" | grep -v grep | awk '{print $1}')
  131. pid=$(pgrep -P $pid -n)
  132.  
  133. import_environment() {
  134.         (( pid )) && for var; do
  135.                 IFS='=' read key val < <(egrep -z "$var" /proc/$pid/environ)
  136.  
  137.                 printf -v "$key" %s "$val"
  138.                 [[ ${!key} ]] && export "$key"
  139.         done
  140. }
  141.  
  142. import_environment XAUTHORITY USER DISPLAY
  143.  
  144. #logger "pid:$pid"
  145. #logger "XAUTHORITY:$XAUTHORITY USER:$USER DISPLAY:$DISPLAY"
  146.  
  147. case "$4" in
  148.     00001311)
  149.         logger 'favorites button pressed'
  150.         #/home/$USER/bin/notify-send-root "favorites button pressed" "$1 $2 $3 $4"
  151.         su -c "/home/$USER/bin/acpi/ibm-keyconfig star-symbol" $USER
  152.         ;;
  153.     00001315)
  154.         logger 'keyboard symbol button pressed'
  155.         su -c "/home/$USER/bin/acpi/ibm-keyconfig keyboard-symbol" $USER
  156.         ;;
  157.  
  158.     *)
  159.         logger "ACPI action undefined: $1"
  160.         ;;
  161. esac
  162. #=======================================================================
  163.  
  164. #-----------------------------------------------------------------------
  165. #tabletmode (/home/$USER/bin/acpi)
  166. #!/bin/sh
  167. #acpi action script for tablet mode, handled by acpi handler in /etc/acpi/actions
  168.  
  169. case $1 in
  170.     0) 
  171.         #notify-send "Tablet mode disengaged"
  172.  
  173.         #write commands here
  174.         ;;
  175.     1)
  176.         #notify-send "Tablet mode engaged"
  177.  
  178.         #write commands here
  179.         ;;
  180.     *) 
  181.         notify-send "undefined action" "undefined action for tablet mode initiated"
  182.         ;;
  183. esac
  184. ;;
  185. #=======================================================================
  186.  
  187. #-----------------------------------------------------------------------
  188. #notify-send-root
  189. #in case you need to send notification with root privelages
  190.  
  191. #!/bin/bash
  192. #
  193. # This script shows how to send a libnotify message
  194. # to a specific user.
  195. #
  196. # It looks for a process that was started by the user and is connected to dbus.
  197.  
  198. #------------------------------------------------------------------------------------
  199. #User input
  200. #--------------------------------------------------------------------
  201. USER="$USER"
  202. USER_DBUS_PROCESS_NAME="gconfd-2" #pick any valid user process that can be associated with dbus
  203. NOTIFY_SEND_BIN="/usr/bin/notify-send"
  204. #--------------------------------------------------------------------
  205. # get pid of user dbus process
  206. DBUS_PID=`ps ax | grep $USER_DBUS_PROCESS_NAME | grep -v grep | awk '{ print $1 }'`
  207. # get DBUS_SESSION_BUS_ADDRESS variable
  208. DBUS_SESSION=`grep -z DBUS_SESSION_BUS_ADDRESS /proc/$DBUS_PID/environ | tr '\0' '\n' | sed -e s/DBUS_SESSION_BUS_ADDRESS=//`
  209.  
  210. params=()
  211. while [ "$1" != "" ]; do
  212.      params+=(\"$1\")
  213.     shift
  214. done
  215.  
  216. notify() {
  217.     arg="$@"
  218.     DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION su -c "$NOTIFY_SEND_BIN ${params[*]}" $USER
  219. }
  220. #----------------------------------------------------------------------
  221.  
  222. notify $@
  223.  
  224. #debug
  225. #notify "title 1" "body 2" "--urgency=normal" "--icon=/usr/share/icons/gnome/32x32/emblems/emblem-default.png"
  226. #=======================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement