From Kromonos, 3 Years ago, written in Bash.
Embed
  1. #!/bin/bash
  2. export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/100000/dbus/user_bus_socket"
  3. exec > >(systemd-cat -t "profile") 2> >(systemd-cat -t "profile.warn")
  4. DBUS=`which dbus-send`
  5. DBUS_PARAM="--type=method_call --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.set_profile"
  6. VIBR_PARAM="--type=method_call --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.set_value"
  7. PROFILE=`${DBUS} --type=method_call --print-reply --dest=com.nokia.profiled /com/nokia/profiled com.nokia.profiled.get_profile | sed -n '2{p;q}' | awk -F' ' '{print $2}' | sed -e "s/^\"//" -e "s/\"$//" `
  8. PRESENCE=/home/nemo/bin/presence.py
  9.  
  10. echo Switching profile from $PROFILE
  11. case "$1" in
  12.     silent)
  13.         PROFILE="silent"
  14.         VIBR="On"
  15.         $PRESENCE away "Phone silence"
  16.         ;;
  17.     work)
  18.         PROFILE="silent"
  19.         VIBR="On"
  20.         $PRESENCE off "Currently at work"
  21.         ;;
  22.     sleep)
  23.         PROFILE="silent"
  24.         # Diable vibration alert
  25.         VIBR="Off"
  26.         $PRESENCE off "Naptime ;)"
  27.         ;;
  28.     vibron)
  29.         $DBUS $VIBR_PARAM string:"${PROFILE}" string:"vibrating.alert.enabled" string:"On"
  30.         ;;
  31.     vibroff)
  32.         $DBUS $VIBR_PARAM string:"${PROFILE}" string:"vibrating.alert.enabled" string:"Off"
  33.         ;;
  34.     *)
  35.         PROFILE="general"
  36.         # Enable vibration alert
  37.         VIBR="On"
  38.         $PRESENCE on "Online via Mobile"
  39.         ;;
  40. esac
  41.  
  42. echo Switching profile to $PROFILE with vibration $VIBR
  43.  
  44. $DBUS $DBUS_PARAM string:"${PROFILE}"
  45. $DBUS $VIBR_PARAM string:"${PROFILE}" string:"vibrating.alert.enabled" string:"${VIBR}"
  46. exit $?
  47.