summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moreau <oreaus@gmail.com>2009-11-06 20:05:03 -0700
committerScott Moreau <oreaus@gmail.com>2009-11-06 20:05:03 -0700
commit6275ca63f462c8b846282cce77d82624f5d12932 (patch)
tree8967a1189be5c8e9099f477f8f4c9c546bc2a210
parentfadb5a76a1dd8f2ab11d50bb136e66a4b2f2e2f5 (diff)
downloadstartup-6275ca63f462c8b846282cce77d82624f5d12932.tar.gz
startup-6275ca63f462c8b846282cce77d82624f5d12932.tar.bz2
Some restructuring
-rw-r--r--src/startup.cpp43
-rw-r--r--src/startup.h4
2 files changed, 24 insertions, 23 deletions
diff --git a/src/startup.cpp b/src/startup.cpp
index 2f6c952..2884355 100644
--- a/src/startup.cpp
+++ b/src/startup.cpp
@@ -31,7 +31,7 @@ StartupScreen::RunCommands()
for (int i = 0; i < numCommands; i++)
{
- // We're running the commands. FIXME: There may be a neater way to set this bool
+ // FIXME: There may be a neater way to set this bool
if ( i == 0)
ranCommands = true;
@@ -41,6 +41,7 @@ StartupScreen::RunCommands()
return;
}
// else
+ // Run the commands.
// If first time in this session, run all commands except with option 2
if ( firstSession && commands[i].interval != 2 )
{
@@ -65,20 +66,6 @@ void
StartupScreen::UpdateStatus()
{
-#define GET_ENV_VAR(ourvar, envvar, error) \
- char* ourvar = getenv(#envvar); \
- if ( ourvar == NULL ) \
- { \
- compLogMessage ("startup", CompLogLevelError, "Environment variable " #envvar " is not set");\
- error = true; \
- return; \
- }
-
- GET_ENV_VAR (dbus_env_var, DBUS_SESSION_BUS_ADDRESS, error)
- GET_ENV_VAR (dsp, DISPLAY, error)
- GET_ENV_VAR (home, HOME, error)
-#undef GET_ENV_VAR
-
// We're only interested in the dbus ID
CompString s(dbus_env_var);
size_t idx = s.find("guid=");
@@ -88,8 +75,6 @@ StartupScreen::UpdateStatus()
std::fstream lock;
int nCompLock = 0;
int nCompPid = getpid();
- CompString lockdir = "/.compiz/locks/startup/";
- lockdir.insert (0,home);
CompString compLockFile = lockdir + "complock" + dsp;
CompString xLockFile = lockdir + "xlock" + dsp;
@@ -129,9 +114,7 @@ StartupScreen::UpdateStatus()
{
lock.open(compLockFile.c_str (), std::ios::out);
if (!lock)
- {
compLogMessage ("startup", CompLogLevelWarn, "Couldn't open %s for writing: %s", compLockFile.c_str (), strerror(errno));
- }
else
{
// Compiz has just been started. Save it's PID
@@ -148,9 +131,7 @@ StartupScreen::UpdateStatus()
mkdir_p(lockdir);
lock.open (xLockFile.c_str (), std::ios::out);
if (!lock)
- {
compLogMessage ("startup", CompLogLevelWarn, "Could not open %s for writing: %s", xLockFile.c_str (), strerror(errno));
- }
else
{
// First time compiz has been run in this X session
@@ -203,7 +184,7 @@ StartupScreen::updateOptions ()
compLogMessage ("startup", CompLogLevelWarn, "Malformed option");
return;
}
-
+compLogMessage ("startup", CompLogLevelWarn, "Non-malformed option");
commands.clear ();
numCommands = 0;
@@ -235,7 +216,23 @@ StartupScreen::StartupScreen (CompScreen *screen) :
optionChanged, this, _1, _2));
ranCommands = firstRun = firstSession = alreadyRunning = error = false;
- updateOptions ();
+
+#define GET_ENV_VAR(ourvar, envvar, error) \
+ ourvar = getenv(#envvar); \
+ if ( ourvar == NULL ) \
+ { \
+ compLogMessage ("startup", CompLogLevelError, "Environment variable " #envvar " is not set"); \
+ error = true; \
+ return; \
+ }
+
+ GET_ENV_VAR (dbus_env_var, DBUS_SESSION_BUS_ADDRESS, error)
+ GET_ENV_VAR (dsp, DISPLAY, error)
+ GET_ENV_VAR (home, HOME, error)
+#undef GET_ENV_VAR
+
+ lockdir = "/.compiz/locks/startup/";
+ lockdir.insert (0,home);
}
StartupWindow::StartupWindow (CompWindow *window) :
diff --git a/src/startup.h b/src/startup.h
index 9582387..487d28f 100644
--- a/src/startup.h
+++ b/src/startup.h
@@ -30,6 +30,10 @@ class StartupScreen :
bool ranCommands, firstRun, firstSession, alreadyRunning, error;
+ char *dbus_env_var, *dsp, *home;
+
+ CompString lockdir;
+
StartupCommands commands;
int numCommands;