Python script to run startup - insserv: command not found

Forum rules
Before you post please read how to get help
Level 1
Level 1
Posts: 1
Joined: Sat Aug 04, 2012 12:57 pm

Python script to run startup - insserv: command not found

Postby garethfoote » Sat Aug 04, 2012 1:20 pm

Hi there,

I am trying get a python script to run on startup using insserv or executing the script using /etc/rc.local. The python script enables keyboard shortcuts for snapping windows to the edges of the screen (

When I use rc.local I found that I get errors related to the display presumably because the screen isn't ready at the point that rc.local is executed. Here is the error log:

Code: Select all

/usr/lib/python2.7/dist-packages/gtk-2.0/gtk/ GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
Traceback (most recent call last):
  File "/home/gareth/bin/gnome-shell-grid/", line 192, in <module>
  File "/home/gareth/bin/gnome-shell-grid/", line 147, in main
    display = Xlib.display.Display()
  File "/usr/lib/pymodules/python2.7/Xlib/", line 83, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/pymodules/python2.7/Xlib/", line 65, in __init__
    apply(protocol.display.Display.__init__, (self, ) + args, keys)
  File "/usr/lib/pymodules/python2.7/Xlib/protocol/", line 44, in __init__
    name, host, displayno, screenno = connect.get_display(display)
  File "/usr/lib/pymodules/python2.7/Xlib/support/", line 65, in get_display
    return mod.get_display(display)
  File "/usr/lib/pymodules/python2.7/Xlib/support/", line 59, in get_display
    raise error.DisplayNameError(display)
Xlib.error.DisplayNameError: Bad display name ""

Alternatively I was going to try using insserv but whenever I try to run insserv I get 'command not found'. To ensure it was installed I ran 'apt-get install insserv' and I am apparently at the latest version already.

I would like to remove and reinstall but when I try to remove insserv I get a warning that I am about to do something dangerous and potentially harmful.

So I have 2 questions really:

1) Can I use insserv to get this script to run at startup after the display is ready?
and if so:
2) why can I not run insserv if it is apparently installed?

Thanks in advance,

User avatar
Level 24
Level 24
Posts: 21644
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Python script to run startup - insserv: command not foun

Postby xenopeek » Sun Aug 05, 2012 2:53 am

As this is about scripting, moving it here.

Why not just add an entry in Startup Applications for your script?

Return to “Scripts & Bash”