diff options
Diffstat (limited to 'data')
| -rw-r--r-- | data/autostart.sh.in | 44 | ||||
| -rw-r--r-- | data/autostart/Makefile | 4 | ||||
| -rw-r--r-- | data/autostart/autostart | 17 | ||||
| -rwxr-xr-x | data/autostart/openbox-autostart.in | 34 | ||||
| -rwxr-xr-x | data/autostart/openbox-xdg-autostart | 198 | ||||
| -rw-r--r-- | data/environment | 10 | ||||
| -rw-r--r-- | data/xsession/openbox-session.in | 18 |
7 files changed, 270 insertions, 55 deletions
diff --git a/data/autostart.sh.in b/data/autostart.sh.in deleted file mode 100644 index eb55558a..00000000 --- a/data/autostart.sh.in +++ /dev/null @@ -1,44 +0,0 @@ -# This shell script is run before Openbox launches. -# Environment variables set here are passed to the Openbox session. - -# Set a background color -BG="" -if which hsetroot >/dev/null; then - BG=hsetroot -else - if which esetroot >/dev/null; then - BG=esetroot - else - if which xsetroot >/dev/null; then - BG=xsetroot - fi - fi -fi -test -z $BG || $BG -solid "#303030" - -# D-bus -if which dbus-launch >/dev/null && test -z "$DBUS_SESSION_BUS_ADDRESS"; then - eval `dbus-launch --sh-syntax --exit-with-session` -fi - -# Make GTK apps look and behave how they were set up in the gnome config tools -if test -x /usr/libexec/gnome-settings-daemon >/dev/null; then - /usr/libexec/gnome-settings-daemon & -elif which gnome-settings-daemon >/dev/null; then - gnome-settings-daemon & -# Make GTK apps look and behave how they were set up in the XFCE config tools -elif which xfce-mcs-manager >/dev/null; then - xfce-mcs-manager n & -fi - -# Preload stuff for KDE apps -if which start_kdeinit >/dev/null; then - LD_BIND_NOW=true start_kdeinit --new-startup +kcminit_startup & -fi - -# Run XDG autostart things. By default don't run anything desktop-specific -# See xdg-autostart --help more info -DESKTOP_ENV="OPENBOX" -if which @secretbindir@/xdg-autostart >/dev/null; then - @secretbindir@/xdg-autostart $DESKTOP_ENV -fi diff --git a/data/autostart/Makefile b/data/autostart/Makefile new file mode 100644 index 00000000..b90edacf --- /dev/null +++ b/data/autostart/Makefile @@ -0,0 +1,4 @@ +all clean install: + $(MAKE) -C .. -$(MAKEFLAGS) $@ + +.PHONY: all clean install diff --git a/data/autostart/autostart b/data/autostart/autostart new file mode 100644 index 00000000..abd92669 --- /dev/null +++ b/data/autostart/autostart @@ -0,0 +1,17 @@ +# +# These things are run when an Openbox X Session is started. +# You may place a similar script in $HOME/.config/openbox/autostart +# to run user-specific things. +# + +# If you want to use GNOME config tools... +# +#if test -x /usr/libexec/gnome-settings-daemon >/dev/null; then +# /usr/libexec/gnome-settings-daemon & +#elif which gnome-settings-daemon >/dev/null; then +# gnome-settings-daemon & +#fi + +# If you want to use XFCE config tools... +# +#xfce-mcs-manager & diff --git a/data/autostart/openbox-autostart.in b/data/autostart/openbox-autostart.in new file mode 100755 index 00000000..3b2f5ec5 --- /dev/null +++ b/data/autostart/openbox-autostart.in @@ -0,0 +1,34 @@ +#!/bin/sh + +# Set a background color +BG="" +if which hsetroot >/dev/null; then + BG=hsetroot +elif which esetroot >/dev/null; then + BG=esetroot +elif which xsetroot >/dev/null; then + BG=xsetroot +fi +test -z $BG || $BG -solid "#303030" + +GLOBALAUTOSTART="@configdir@/autostart" +AUTOSTART="${XDG_CONFIG_HOME:-"$HOME/.config"}/openbox/autostart" + +# Run the global openbox autostart script +if test -f $GLOBALAUTOSTART; then + sh $GLOBALAUTOSTART +elif test -f $GLOBALAUTOSTART.sh; then + sh $GLOBALAUTOSTART.sh +fi + +# Run the user openbox autostart script +if test -f $AUTOSTART; then + sh $AUTOSTART +elif test -f $AUTOSTART.sh; then + sh $AUTOSTART.sh +fi + +# Run the XDG autostart stuff. These are found in /etc/xdg/autostart and +# in $HOME/.config/autostart. This requires PyXDG to be installed. +# See openbox-xdg-autostart --help for more details. +@libexecdir@/openbox-xdg-autostart OPENBOX diff --git a/data/autostart/openbox-xdg-autostart b/data/autostart/openbox-xdg-autostart new file mode 100755 index 00000000..ea760281 --- /dev/null +++ b/data/autostart/openbox-xdg-autostart @@ -0,0 +1,198 @@ +#!/usr/bin/env python + +# openbox-xdg-autostart runs things based on the XDG autostart specification +# Copyright (C) 2008 Dana Jansens +# +# XDG autostart specification can be found here: +# http://standards.freedesktop.org/autostart-spec/ +# +# +# +# LICENSE: +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +ME="openbox-xdg-autostart" +VERSION="1.1" + +import os, glob, sys +try: + from xdg import BaseDirectory + from xdg.DesktopEntry import DesktopEntry + from xdg.Exceptions import ParsingError +except ImportError: + print + print "ERROR:", ME, "requires PyXDG to be installed" + print + sys.exit(1) + +def main(argv=sys.argv): + if "--help" in argv[1:]: + show_help() + return 0 + if "--version" in argv[1:]: + show_version() + return 0 + + # get the autostart directories + autodirs = BaseDirectory.load_config_paths("autostart") + + # find all the autostart files + files = [] + for dir in autodirs: + for path in glob.glob(os.path.join(dir, '*.desktop')): + try: + autofile = AutostartFile(path) + except ParsingError: + print "Invalid .desktop file: " + path + else: + if not autofile in files: + files.append(autofile) + + list = False + if "--list" in argv[1:]: + list = True + argv.remove("--list") + + # run them ! + environments = argv[1:] + for autofile in files: + if list: autofile.display(environments) + else: autofile.run(environments) + +class AutostartFile: + def __init__(self, path): + self.path = path + self.filename = os.path.basename(path) + self.dirname = os.path.dirname(path) + self.de = DesktopEntry(path) + + def __eq__(self, other): + return self.filename == other.filename + + def __str__(self): + return self.path + " : " + self.de.getName() + + def _isexecfile(self, path): + return os.access(path, os.X_OK) + + def _findFile(self, path, search, match_func): + # check empty path + if not path: return None + # check absolute path + if path[0] == '/': + if match_func(path): return path + else: return None + else: + # check relative path + for dirname in search.split(os.pathsep): + if dirname != "": + candidate = os.path.join(dirname, path) + if (match_func(candidate)): return candidate + + def _alert(self, str, info=False): + if info: + print "\t ", str + else: + print "\t*", str + + def _showInEnvironment(self, envs, verbose=False): + default = not self.de.getOnlyShowIn() + noshow = False + force = False + for i in self.de.getOnlyShowIn(): + if i in envs: force = True + for i in self.de.getNotShowIn(): + if i in envs: noshow = True + + if verbose: + if not default and not force: + s = "" + for i in self.de.getOnlyShowIn(): + if s: s += ", " + s += i + self._alert("Excluded by: OnlyShowIn (" + s + ")") + if default and noshow and not force: + s = "" + for i in self.de.getNotShowIn(): + if s: s += ", " + s += i + self._alert("Excluded by: NotShowIn (" + s + ")") + return (default and not noshow) or force + + def _shouldRun(self, envs, verbose=False): + if not self.de.getExec(): + if verbose: self._alert("Excluded by: Missing Exec field") + return False + if self.de.getHidden(): + if verbose: self._alert("Excluded by: Hidden") + return False + if self.de.getTryExec(): + if not self._findFile(self.de.getTryExec(), os.getenv("PATH"), + self._isexecfile): + if verbose: self._alert("Excluded by: TryExec (" + + self.de.getTryExec() + ")") + return False + if not self._showInEnvironment(envs, verbose): + return False + return True + + def display(self, envs): + if self._shouldRun(envs): + print "[*] " + self.de.getName() + else: + print "[ ] " + self.de.getName() + self._alert("File: " + self.path, info=True) + if self.de.getExec(): + self._alert("Executes: " + self.de.getExec(), info=True) + self._shouldRun(envs, True) + print + + def run(self, envs): + here = os.getcwd() + if self.de.getPath(): + os.chdir(self.de.getPath()) + if self._shouldRun(envs): + args = ["/bin/sh", "-c", "exec " + self.de.getExec()] + os.spawnv(os.P_NOWAIT, args[0], args); + os.chdir(here) + +def show_help(): + print "Usage:", ME, "[OPTION]... [ENVIRONMENT]..." + print + print "This tool will run xdg autostart .desktop files" + print + print "OPTIONS" + print " --list Show a list of the files which would be run" + print " Files which would be run are marked with an asterix" + print " symbol [*]. For files which would not be run," + print " information is given for why they are excluded" + print " --help Show this help and exit" + print " --version Show version and copyright information" + print + print "ENVIRONMENT specifies a list of environments for which to run autostart" + print "applications. If none are specified, only applications which do not " + print "limit themselves to certain environments will be run." + print + print "ENVIRONMENT can be one or more of:" + print " GNOME Gnome Desktop" + print " KDE KDE Desktop" + print " ROX ROX Desktop" + print " XFCE XFCE Desktop" + print " Old Legacy systems" + print + +def show_version(): + print ME, VERSION + print "Copyright (c) 2008 Dana Jansens" + print + +if __name__ == "__main__": + sys.exit(main()) diff --git a/data/environment b/data/environment new file mode 100644 index 00000000..3311bd6f --- /dev/null +++ b/data/environment @@ -0,0 +1,10 @@ +# +# Set system-wide environment variables here for Openbox +# User-specific variables should be placed in $HOME/.config/openbox/environment +# + +# To set your language for displaying messages and time/date formats, use the following: +#LANG=en_CA.UTF8 + +# To set your keyboard layout, you need to modify your X config: +# http://www.google.com/search?q=how+to+set+keyboard+layout+xorg diff --git a/data/xsession/openbox-session.in b/data/xsession/openbox-session.in index fa1bb996..3cf3571f 100644 --- a/data/xsession/openbox-session.in +++ b/data/xsession/openbox-session.in @@ -12,15 +12,11 @@ xprop -root -remove _NET_NUMBER_OF_DESKTOPS \ -remove _NET_DESKTOP_NAMES \ -remove _NET_CURRENT_DESKTOP 2> /dev/null -AUTOSTART="${XDG_CONFIG_HOME:-"$HOME/.config"}/openbox/autostart.sh" -GLOBALAUTOSTART="@configdir@/openbox/autostart.sh" +# Set up the environment +A="@configdir@/openbox/environment" +test -r $A && . $A +A="${XDG_CONFIG_HOME:-"$HOME/.config"}/openbox/environment" +test -r $A && . $A -if test -r $AUTOSTART; then - . $AUTOSTART -else - if test -r $GLOBALAUTOSTART; then - . $GLOBALAUTOSTART - fi -fi - -exec @bindir@/openbox "$@" +# Run Openbox, and have it run the autostart stuff +exec @bindir@/openbox --startup "@libexecdir@/openbox-autostart OPENBOX" "$@" |
