4

Every time I plug/unplug the power cable docky is closing. This thing is happening since I have updated to 14.04, also, my battery life seems to be shorter. I am using a toshiba satellite c55-A-1PX.

4 Answers4

4

You should write a pm script as described in this page:

http://www.linux-compatible.com/tutorial/docky-closes-after-waking-suspend-ubuntu

coolman
  • 168
2

Original credit goes to linux-compatible.com

This is just an attempt to enhance the script a bit. I my case Docky was also crashing when laptop lid was opened/closed.

replace gedit with pluma if you're running Mint

gksudo gedit /etc/pm/sleep.d/20_docky

#!/bin/sh
case $1 in
    resume)
    if grep -q open /proc/acpi/button/lid/*/state
    then
        USER=`who | grep ":0" | head -1 | cut -d" " -f1`
        USERHOME=/home/$USER
        export XAUTHORITY="$USERHOME/.Xauthority"
        export DISPLAY=":0"
        su $USER - -c "dbus-launch /usr/bin/docky >/dev/null" &
        exit 0;
        ;;
    fi
esac

$ sudo chmod ugo+x /etc/pm/sleep.d/20_docky

next...

gksudo gedit /etc/pm/power.d/20_docky

#!/bin/sh
if grep -q open /proc/acpi/button/lid/*/state
then
    USER=`who | grep ":0" | head -1 | cut -d" " -f1`
    USERHOME=/home/$USER
    export XAUTHORITY="$USERHOME/.Xauthority"
    export DISPLAY=":0"
    su $USER - -c "dbus-launch /usr/bin/docky >/dev/null" &
    exit 0;
fi

$ sudo chmod ugo+x /etc/pm/power.d/20_docky

also...

gksudo gedit /etc/acpi/events/lid

event=button[ /]lid
action=/etc/acpi/lid.sh

finally...

gksudo gedit /etc/acpi/lid.sh

#!/bin/sh
if grep -q open /proc/acpi/button/lid/*/state
then
    if [ -z "$(pgrep docky)" ]
    then
        USER=`who | grep ":0" | head -1 | cut -d" " -f1`
        USERHOME=/home/$USER
        export XAUTHORITY="$USERHOME/.Xauthority"
        export DISPLAY=":0"
        su $USER - -c "dbus-launch /usr/bin/docky >/dev/null" &
        exit 0;
    fi
fi

sudo chmod ugo+x /etc/acpi/lid.sh

That's it. You may also want to remove Docky from startup programs, else it might attempt to start twice.

Good luck.

HEXYEBO
  • 21
2

There is an alternative to the methods mentioned here. Since a few days, that is. see: https://launchpad.net/~docky-core/+archive/ubuntu/stable

There have been a few bug-fixes and improvements to the release you normally get when installing via software sources bundled with your distro.

To install the latest stable build add this ppa to your repositories: ppa:docky-core/stable

Full copy-pasta would be: (sudo not included)

add-apt-repository ppa:docky-core/stable && apt-get update
apt-get purge docky
apt-get install docky
cytodev
  • 51
0

a modified script to avoid multiple docks on resume/lid open. simply it checks if docky is already executed

/etc/pm/sleep.d/20_docky:

#!/bin/sh
case $1 in
    resume)
    if grep -q open /proc/acpi/button/lid/*/state
    then
        USER=`who | grep ":0" | head -1 | cut -d" " -f1`
        USERHOME=/home/$USER
        export XAUTHORITY="$USERHOME/.Xauthority"
        export DISPLAY=":0"
        check=$(pidof mono /usr/bin/docky.exe | grep -c "")
        if [ $check -lt 1 ]; then
            su $USER - -c "dbus-launch /usr/bin/docky >/dev/null" &
        else
            exit 0;
        fi
       ;;
    fi
esac

and

/etc/pm/power.d/20_docky:

#!/bin/sh
USER=`who | grep ":0" | head -1 | cut -d" " -f1`
USERHOME=/home/$USER
export XAUTHORITY="$USERHOME/.Xauthority"
export DISPLAY=":0"
check=$(pidof mono /usr/bin/docky.exe | grep -c "")

if [ $check -lt 1 ]; then
    su $USER - -c "dbus-launch /usr/bin/docky >/dev/null" &
else
    exit 0;
fi

this slighlty modified script works perfectly for me on Linux Mint 17.3 Rosa

muru
  • 207,228