1

This may sound like a stupid idea but I like to have a transparent top-panel which can be configured in Compiz Config Settings Manager, but when I resume from a suspend it's no longer transparent and gives a graphical glitch when invoking the dash. This goes away if I restart Unity by running the command "unity". So I was wondering if it was possible to achieve this? I tried setting a script in /etc/pm/sleep.d/ as stated in how to execute a command after resume from suspend? but it didn't work, I guess it is run before I get to log in again and Unity resumes.

Is there any way to achieve what I want or should I just give up?

3 Answers 3

1

Go to System Settings > Keyboard > Shortcuts > Custom Shortcuts

and create a new one:

enter image description here

then set an easy keyboard shortcut like Alt+R to easily run a quick Unity restart after suspending.

I do not suffer your bug but I need to run this command on every new session 'cos unity doesn't remember edge bindings on new sessions.

3
  • I can unfortunately not accept this as a solution. It sounds really stupid if I show it to my friends and saying "Unity is great, but you must restart it with this shortcut command everytime you resume from a suspend". But thank you for your suggestion :)
    – Niklas
    Jun 14, 2012 at 15:40
  • Yes, graphical glitch is better, you don't have to be ashamed for a shell restart pal.
    – neonboy
    Jun 14, 2012 at 19:53
  • What? Ashamed? It has nothing to do with that, I want to be able to recommend Ubuntu to friends as a good OS, not a buggy unstable environment. If anything canonical should be ashamed of the graphical glitch.
    – Niklas
    Jun 17, 2012 at 19:35
1

Directly from the manual for systemd-suspend.service:

Immediately before entering system suspend and/or hibernation systemd-suspend.service (and the other mentioned units, respectively) will run all executables in /usr/lib/systemd/system-sleep/ and pass two arguments to them. The first argument will be "pre", the second either "suspend", "hibernate", or "hybrid-sleep" depending on the chosen action. Immediately after leaving system suspend and/or hibernation the same executables are run, but the first argument is now "post". All executables in this directory are executed in parallel, and execution of the action is not continued until all executables have finished.

I did some testing, and found that if you put a script (marked executable by all, which be achieved with chmod a+x) in /lib/systemd/system-sleep, without the /usr, it will be executed as mentioned.

However, there is one drawback which is what makes you think it isn't working: the environment is different. Graphical commands do not work. There is probably a way around this, but by default, unity --replace will fail because it can't connect to the X server (and so no commands that don't work if you press CTRL-ALT-F1 and go into an actual console without tampering will function).

Okay, I just paused my typing to do some research: after looking at the basic chroot wiki (because I've had the same problem in chroots), I found that if you manually call xhost + before suspending, graphical commands (in my case zenity --info --text "1:$1 2:$1") function properly. However, you can't call xhost + from the script. What you can do is add a program to the "startup applications" to automatically call xhost + when you log in (add it there and not to .bashrc because if added to .bashrc it will run every time you open a terminal emulator). It might be different on Unity, but on Ubuntu MATE I can go to System → Preferences → Personal → Startup Applications and click Add to do this.

Then, create a file /lib/systemd/system-sleep/restart-unity with the following contents:

#!/bin/bash
export DISPLAY=:0
if [[ "$1" == "post" && "$2" == "suspend" ]]
then
    sleep 5
    unity --replace
fi

and run sudo chmod a+x /lib/systemd/system-sleep/restart-unity (make sure the file is owned by root and only writable by root).

Note that it must use bash. This is because of the "if" statement. When I tried the statement manually in sh, I got various errors from the && part.

The sleep is there because without it, unity --replace will fail to connect to the X server (or so it seems).

Based on my own tests on Zesty, this should work.

I just spent 15 minutes trying to figure out why it wasn't working only to realize I'd forgotten the export DISPLAY=:0 line.

0

These seem useful:

Is this the glitch you're seeing?

bad_transparency_after_sleep.png

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .