pandora-scripts: try to fix currentuser/home mess
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_power.sh
index bba0f51..9b0e1b2 100644 (file)
@@ -1,6 +1,8 @@
 #!/bin/bash
 
-. /usr/pandora/scripts/op_paths.sh
+. /usr/pandora/scripts/op_common.sh
+xfceuser=$(get_user)
+xfceuser_home=$(get_user_home)
 
 # XXX: better use lockfile (or something), but it's not in current firmware
 test -e /tmp/op_power.lock && exit 2
@@ -12,9 +14,7 @@ debug(){
        return 1 # 0 when debugging, 1 when not
 }
 
-test -e $(grep /etc/passwd -e ^$(ps u -C xfce4-session | tail -n1 | awk '{print $1}'): | cut -f 6 -d ":")/.lidconfig && lidconfig=$(cat $(grep /etc/passwd -e ^$(ps u -C xfce4-session | tail -n1 | awk '{print $1}'): | cut -f 6 -d ":")/.lidconfig) # read lid conf. file if it exists
-
-#powerbuttonconfig=$(cat $(grep /etc/passwd -e ^$(ps u -C xfce4-session | tail -n1 | awk '{print $1}'): | cut -f 6 -d ":")/.powerbuttonconfig)
+test -e $xfceuser_home/.lidconfig && lidconfig=$(cat $xfceuser_home/.lidconfig) # read lid conf. file if it exists
 
 if [ -e /tmp/powerstate ]; then 
        powerstate="$(cat /tmp/powerstate)"
@@ -138,7 +138,6 @@ display_on_with_checks() {
 
 show_message() {
        # TODO: check if desktop is visible; maybe use layer3?
-       xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}')
        cmd="DISPLAY=:0.0 zenity --info --text \"$1\" --timeout 10"
        su -c "$cmd" $xfceuser
 }
@@ -254,7 +253,6 @@ resume() {
 }
 
 shutdown(){ # warns the user and shuts the pandora down
-       xfceuser=$(ps u -C xfce4-session | tail -n1 | awk '{print $1}')
        time=5
        countdown () {
                for i in $(seq $time); do