Python script to run startup - insserv: command not found

Forum rules
Before you post please read this

Python script to run startup - insserv: command not found

Postby garethfoote on 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 (https://github.com/paulswartz/gnome-shell-grid).

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/__init__.py:57: GtkWarning: could not open display
  warnings.warn(str(e), _gtk.Warning)
Traceback (most recent call last):
  File "/home/gareth/bin/gnome-shell-grid/gnome-shell-grid.py", line 192, in <module>
    main()
  File "/home/gareth/bin/gnome-shell-grid/gnome-shell-grid.py", line 147, in main
    display = Xlib.display.Display()
  File "/usr/lib/pymodules/python2.7/Xlib/display.py", line 83, in __init__
    self.display = _BaseDisplay(display)
  File "/usr/lib/pymodules/python2.7/Xlib/display.py", line 65, in __init__
    apply(protocol.display.Display.__init__, (self, ) + args, keys)
  File "/usr/lib/pymodules/python2.7/Xlib/protocol/display.py", line 44, in __init__
    name, host, displayno, screenno = connect.get_display(display)
  File "/usr/lib/pymodules/python2.7/Xlib/support/connect.py", line 65, in get_display
    return mod.get_display(display)
  File "/usr/lib/pymodules/python2.7/Xlib/support/unix_connect.py", 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,
Gareth
garethfoote
Level 1
Level 1
 
Posts: 1
Joined: Sat Aug 04, 2012 12:57 pm

Linux Mint is funded by ads and donations.
 

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

Postby xenopeek on 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?
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14969
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 1 guest