Index: libs/libmythtv/jobqueue.cpp
===================================================================
--- libs/libmythtv/jobqueue.cpp	(revision 13351)
+++ libs/libmythtv/jobqueue.cpp	(working copy)
@@ -168,14 +168,7 @@
 
     QMap<QString, int> jobStatus;
     int maxJobs;
-    QString queueStartTimeStr;
-    QString queueEndTimeStr;
-    int queueStartTime;
-    int queueEndTime;
-    QTime curQTime;
-    int curTime;
     QString message;
-    QString tmpStr;
     QMap<int, JobQueueEntry> jobs;
     bool atMax = false;
     bool inTimeWindow = true;
@@ -187,16 +180,10 @@
 
         startedJobAlready = false;
         sleepTime = gContext->GetNumSetting("JobQueueCheckFrequency", 30);
-        queueStartTimeStr =
-            gContext->GetSetting("JobQueueWindowStart", "00:00");
-        queueEndTimeStr =
-            gContext->GetSetting("JobQueueWindowEnd", "23:59");
-
         maxJobs = gContext->GetNumSetting("JobQueueMaxSimultaneousJobs", 3);
         VERBOSE(VB_JOBQUEUE, LOC +
-                QString("Currently set at %1 job(s) max and to run new jobs "
-                        "from %2 to %3").arg(maxJobs).arg(queueStartTimeStr)
-                                        .arg(queueEndTimeStr));
+                QString("Currently set to run up to %1 job(s) max.")
+                        .arg(maxJobs));
 
         jobStatus.clear();
 
@@ -204,24 +191,7 @@
         
         if (jobs.size())
         {
-            tmpStr = queueStartTimeStr;
-            queueStartTime = tmpStr.replace(QRegExp(":"), "").toInt();
-            tmpStr = queueEndTimeStr;
-            queueEndTime = tmpStr.replace(QRegExp(":"), "").toInt();
-            curQTime = QTime::currentTime();
-            curTime = curQTime.hour() * 100 + curQTime.minute();
-            inTimeWindow = false;
-
-            if ((queueStartTime <= curTime) && (curTime < queueEndTime))
-            {
-                inTimeWindow = true;
-            }
-            else if ((queueStartTime > queueEndTime) &&
-                     ((curTime < queueEndTime) || (queueStartTime <= curTime)))
-            {
-                inTimeWindow = true;
-            }
-
+            inTimeWindow = InJobRunWindow();
             jobsRunning = 0;
             for (unsigned int x = 0; x < jobs.size(); x++)
             {
@@ -241,8 +211,7 @@
             {
                 message += QString("  Jobs in Queue, but we are outside of the "
                                    "Job Queue time window, no new jobs can be "
-                                   "started, next window starts at %1.")
-                                   .arg(queueStartTimeStr);
+                                   "started.");
                 VERBOSE(VB_JOBQUEUE, LOC + message);
             }
             else if (jobsRunning >= maxJobs)
@@ -1121,6 +1090,132 @@
     return JobQueue::GetJobQueueKey(pginfo->chanid, pginfo->recstartts);
 }
 
+bool JobQueue::InJobRunWindow(int orStartsWithinMins)
+{
+    QString queueStartTimeStr;
+    QString queueEndTimeStr;
+    QTime queueStartTime;
+    QTime queueEndTime;
+    QTime curTime = QTime::currentTime();
+    bool inTimeWindow = false;
+    orStartsWithinMins = orStartsWithinMins < 0 ? 0 : orStartsWithinMins;
+
+    queueStartTimeStr = gContext->GetSetting("JobQueueWindowStart", "00:00");
+    queueEndTimeStr = gContext->GetSetting("JobQueueWindowEnd", "23:59");
+
+    VERBOSE(VB_JOBQUEUE, LOC +
+            QString("Currently set to run new jobs from %1 to %2")
+                    .arg(queueStartTimeStr).arg(queueEndTimeStr));
+
+    queueStartTime = QTime::fromString(queueStartTimeStr);
+    if (!queueStartTime.isValid())
+    {
+        VERBOSE(VB_IMPORTANT, "Invalid JobQueueWindowStart time, using 00:00");
+        queueStartTime = QTime::QTime(0, 0);
+    }
+
+    queueEndTime = QTime::fromString(queueEndTimeStr);
+    if (!queueEndTime.isValid())
+    {
+        VERBOSE(VB_IMPORTANT, "Invalid JobQueueWindowEnd time, using 23:59");
+        queueEndTime = QTime::QTime(23, 59);
+    }
+    
+    if ((queueStartTime <= curTime) && (curTime < queueEndTime))
+    {
+        inTimeWindow = true;
+    }
+    else if ((queueStartTime > queueEndTime) &&
+             ((curTime < queueEndTime) || (queueStartTime <= curTime)))
+    {
+        inTimeWindow = true;
+    }
+    else if (orStartsWithinMins > 0)
+    {
+        // Check if the window starts soon
+        if (curTime <= queueStartTime)
+        {
+            // Start time hasn't passed yet today
+            if (queueStartTime.secsTo(curTime) <= (orStartsWithinMins * 60))
+            {
+                VERBOSE(VB_JOBQUEUE, LOC +
+                    QString("Job run window will start within %1 minutes")
+                            .arg(orStartsWithinMins));
+                inTimeWindow = true;
+            }
+        }
+        else
+        {
+            // We passed the start time for today, try tomorrow
+            QDateTime curDateTime = QDateTime::currentDateTime();
+            QDateTime startDateTime = QDateTime(QDate::currentDate(), queueStartTime).addDays(1);
+
+            if (curDateTime.secsTo(startDateTime) <= (orStartsWithinMins * 60))
+            {
+                VERBOSE(VB_JOBQUEUE, LOC +
+                    QString("Job run window will start within %1 minutes (tomorrow)")
+                            .arg(orStartsWithinMins));
+                inTimeWindow = true;
+            }
+        }
+    }
+
+    return inTimeWindow;
+}
+
+bool JobQueue::HasRunningOrPendingJobs(int startingWithinMins)
+{
+    /* startingWithinMins <= 0 - look for any pending jobs
+           > 0 -  only consider pending starting within this time */
+    QMap<int, JobQueueEntry> jobs;
+    QMap<int, JobQueueEntry>::Iterator it;
+    QDateTime maxSchedRunTime = QDateTime::currentDateTime();
+    int tmpStatus = 0;
+    bool checkForQueuedJobs = (startingWithinMins <= 0 
+                                || InJobRunWindow(startingWithinMins));
+
+    if (checkForQueuedJobs && startingWithinMins > 0) {
+        maxSchedRunTime = maxSchedRunTime.addSecs(startingWithinMins * 60);
+        VERBOSE(VB_JOBQUEUE, LOC +
+            QString("HasRunningOrPendingJobs: checking for jobs "
+                    "starting before: %1").arg(maxSchedRunTime.toString()));
+    }
+
+    JobQueue::GetJobsInQueue(jobs, JOB_LIST_NOT_DONE);
+
+    if (jobs.size()) {
+        for (it = jobs.begin(); it != jobs.end(); ++it)
+        {
+            tmpStatus = it.data().status;
+            if (tmpStatus == JOB_RUNNING) {
+                VERBOSE(VB_JOBQUEUE, LOC +
+                        QString("HasRunningOrPendingJobs: found running job"));
+                return true;
+            }
+            
+            if (checkForQueuedJobs) {
+                if ((tmpStatus != JOB_UNKNOWN) && (!(tmpStatus & JOB_DONE))) {
+                    if (startingWithinMins <= 0) {
+                        VERBOSE(VB_JOBQUEUE, LOC +
+                            QString("HasRunningOrPendingJobs: " 
+                                    "found pending job"));
+                        return true;
+                    }
+                    else if (it.data().schedruntime <= maxSchedRunTime) {
+                        VERBOSE(VB_JOBQUEUE, LOC +
+                            QString("HasRunningOrPendingJobs: found pending " 
+                                    "job scheduled to start at: %1")
+                                    .arg(it.data().schedruntime.toString()));
+                        return true;
+                    }
+                }
+            }
+        }
+    }
+    return false;
+}
+
+
 int JobQueue::GetJobsInQueue(QMap<int, JobQueueEntry> &jobs, int findJobs)
 {
     JobQueueEntry thisJob;
Index: libs/libmythtv/jobqueue.h
===================================================================
--- libs/libmythtv/jobqueue.h	(revision 13351)
+++ libs/libmythtv/jobqueue.h	(working copy)
@@ -161,6 +161,8 @@
     static QString JobText(int jobType);
     static QString StatusText(int status);
 
+    static bool HasRunningOrPendingJobs(int startingWithinMins = 0);
+
     static int GetJobsInQueue(QMap<int, JobQueueEntry> &jobs,
                               int findJobs = JOB_LIST_NOT_DONE);
 
@@ -178,6 +180,8 @@
 
     bool AllowedToRun(JobQueueEntry job);
 
+    static bool InJobRunWindow(int orStartingWithinMins = 0);
+
     void StartChildJob(void *(*start_routine)(void *), ProgramInfo *tmpInfo);
 
     static QString GetJobQueueKey(QString chanid, QString startts);
Index: programs/mythwelcome/welcomedialog.cpp
===================================================================
--- programs/mythwelcome/welcomedialog.cpp	(revision 13351)
+++ programs/mythwelcome/welcomedialog.cpp	(working copy)
@@ -633,6 +633,8 @@
         m_statusList.append(tr("MythTV is busy grabbing EPG data."));
     if (statusCode & 16)
         m_statusList.append(tr("MythTV is locked by a user."));
+    if (statusCode & 32)
+        m_statusList.append(tr("MythTV is has running or pending jobs."));
     if (statusCode & 64)
         m_statusList.append(tr("MythTV is in a daily wakeup/shutdown period."));
     if (statusCode & 128)
Index: programs/mythshutdown/main.cpp
===================================================================
--- programs/mythshutdown/main.cpp	(revision 13351)
+++ programs/mythshutdown/main.cpp	(working copy)
@@ -12,6 +12,7 @@
 #include <mythcontext.h>
 #include <mythdbcon.h>
 #include "libmythtv/programinfo.h"
+#include "libmythtv/jobqueue.h"
 #include "tv.h"
 
 void setGlobalSetting(const QString &key, const QString &value)
@@ -201,6 +202,12 @@
         res += 16;
     }
 
+    if (JobQueue::HasRunningOrPendingJobs(15))
+    {
+        VERBOSE(VB_IMPORTANT, "Has queued or pending jobs");
+        res += 32;
+    }
+
     QDateTime dtPeriod1Start = getDailyWakeupTime("DailyWakeupStartPeriod1");
     QDateTime dtPeriod1End = getDailyWakeupTime("DailyWakeupEndPeriod1");
     QDateTime dtPeriod2Start = getDailyWakeupTime("DailyWakeupStartPeriod2");
@@ -715,7 +722,7 @@
   cout << "                          4 - Grabbing EPG data\n";
   cout << "                          8 - Recording - only valid if flag is 1\n";
   cout << "                         16 - Locked\n";
-  cout << "                         32 - Not used\n";
+  cout << "                         32 - Jobs running or pending\n";
   cout << "                         64 - In a daily wakeup/shutdown period\n";
   cout << "                        128 - Less than 15 minutes to next wakeup period\n";
   cout << "-v/--verbose debug-level (Use '-v help' for level info\n";
