aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexis Maiquez <games-fun-inc@hotmail.com>2019-02-19 16:06:21 +0100
committerGitHub <noreply@github.com>2019-02-19 16:06:21 +0100
commitc5403e9c5fb08319e984d939b975915dddf59791 (patch)
tree03157462eb5ac0f3ce74e340abd20b74bf88ebfe
parent9ec7c51b9c82d6898e35be764c10fd852baefe57 (diff)
parenta1ddbe5b94b21877c1a082256857d2e6feb692fe (diff)
downloadlead-c5403e9c5fb08319e984d939b975915dddf59791.tar
lead-c5403e9c5fb08319e984d939b975915dddf59791.tar.gz
lead-c5403e9c5fb08319e984d939b975915dddf59791.zip
Merge pull request #1 from MageJohn/master
Merge from MageJohn
-rw-r--r--.gitignore3
-rw-r--r--README.md56
-rwxr-xr-xdata/usr/bin/leadbin44936 -> 0 bytes
-rw-r--r--src/app.cpp30
-rw-r--r--src/sensor.cpp38
-rw-r--r--src/sensor.h10
6 files changed, 98 insertions, 39 deletions
diff --git a/.gitignore b/.gitignore
index ab24a97..90cc9cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.vscode
-build/* \ No newline at end of file
+build/*
+data
diff --git a/README.md b/README.md
index 1c0f1f7..258789d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
*lead* provides hot-corners for your desktop, notably for openbox, awesome, i3 and other window managers.
+This fork adds support for specifying an interval to wait before the action is triggered. There may be more improvements in the future.
+
![Screenshot of lead](https://github.com/mlde/lead/blob/master/screenshot.png)
> Despite the screenshot, the sensors are only 1px in size and invisible.
@@ -33,10 +35,6 @@ To build *lead* open a terminal in the root folder of the repository and:
- Qt5Gui
- Qt5Core
-### Build
-
-A build `lead` is provided in `data/usr/bin/`. It was build on my arch64 system.
-
# Install it
@@ -55,28 +53,32 @@ On the first run lead will look into these dirs for a conf-file. The first one f
If none of these exists, it will create `~/.config/lead/lead.conf` with default values for each screen, ie:
[eDP1]
- bottom=
- bottomLeft=
- bottomRight=
- left=
- right=
- top=
- topLeft=
- topRight=
+ bottom-action=
+ bottom-interval=0
+ bottomLeft-action=
+ bottomLeft-interval=0
+ bottomRight-action=
+ bottomRight-interval=0
+ left-action=
+ left-interval=0
+ right-action=
+ right-interval=0
+ top-action=
+ top-interval=0
+ topLeft-action=
+ topLeft-interval=0
+ topRight-action=
+ topRight-interval=0
To enable a action for a sensor, simply add a command to the corner or side:
- [eDP1]
- bottom=
- bottomLeft=chromium
- bottomRight=thunar
- left=
- right=
- top=
- topLeft=californium toggle
- topRight=skippy-xd
+ bottomLeft-action=chromium
+
+The intervals are set in milliseconds. For example, to set chromium to open only after the mouse has been in the corner for 1 second, do:
+
+ bottomLeft-interval=1000
-Used config-files and theme-files are monitored and changes are applied automatically.
+The configuration file is monitored and changes are applied automatically.
# Use it
@@ -96,3 +98,13 @@ To uninstall *lead* open a terminal in the root folder of the repository and:
# Drawbacks
I didnt want to poll the mouse, so i created sensors which works with events. The sensors are transparent, but need a running compositor like compton for that. Without a compositor, they are black.
+
+# TODO
+
+Improvements that need to be made:
+
+- Error checking of the conf file; e.g. check that an integer was set for the interval
+
+Possible new features:
+
+- Custom regions
diff --git a/data/usr/bin/lead b/data/usr/bin/lead
deleted file mode 100755
index 2fbb39f..0000000
--- a/data/usr/bin/lead
+++ /dev/null
Binary files differ
diff --git a/src/app.cpp b/src/app.cpp
index 0e3075a..1b63b72 100644
--- a/src/app.cpp
+++ b/src/app.cpp
@@ -30,6 +30,7 @@ SOFTWARE.
#include <QDebug>
#include <QScreen>
#include <QFileSystemWatcher>
+#include <QVariant>
#define SENSOR_WIDTH 5
#define SENSOR_HEIGHT 5
@@ -136,29 +137,40 @@ void
App::loadSensor(QScreen* screen, QString name, int x, int y, int w, int h)
{
- QString key = screen->name() + "/" + name;
+ QString action = screen->name() + "/" + name + "-" + "action";
+ QString interval = screen->name() + "/" + name + "-" + "interval";
+ if (!settings.contains(interval))
+ {
+ qDebug() << "App::loadSensor() interval for " << name << " not found; setting to 0";
+
+ // set default
+ settings.setValue(interval, QVariant(0));
+ }
- if (!settings.contains(key) )
+ if (!settings.contains(action))
{
- qDebug() << "App::loadSensor() key " << name << " not found";
+ qDebug() << "App::loadSensor() action for " << name << " not found; creating empty key";
- // restore missing key
- settings.setValue(key, QString());
+ // restore missing action
+ settings.setValue(action, QString());
return;
}
- if (settings.value(key).toString().isEmpty())
+ if (settings.value(action).toString().isEmpty())
{
- qDebug() << "App::loadSensor() key " << name << " is empty";
+ qDebug() << "App::loadSensor() action for " << name << " is empty";
return;
}
// create sensor and save in list so we can delete all sensors on delete
- sensors.append( new Sensor(x, y, w, h, settings.value(key).toString()) );
+ qDebug() << "App::loadSensor() action for " << name << " is " << settings.value(action).toString();
+ qDebug() << "App::loadSensor() interval for " << name << " is " << settings.value(interval).toInt();
+
+ sensors.append( new Sensor(x, y, w, h, settings.value(action).toString(), settings.value(interval).toInt()) );
}
-} // namespace \ No newline at end of file
+} // namespace
diff --git a/src/sensor.cpp b/src/sensor.cpp
index d84f0a2..49fd149 100644
--- a/src/sensor.cpp
+++ b/src/sensor.cpp
@@ -34,12 +34,18 @@ SOFTWARE.
namespace Lead {
-Sensor::Sensor(int x, int y, int w, int h, QString action):
- QWidget()
+Sensor::Sensor(int x, int y, int w, int h, QString action, int interval):
+ QWidget(),
+ action(action),
+ interval(interval)
{
- qDebug() << "lead::Sensor() " << x << "," << y << "," << w << "," << h << " : " << action;
+ qDebug() << "lead::Sensor() " << x << "," << y << "," << w << "," << h << " : action=" << action << " : interval=" << interval;
- this->action = action;
+ this->timer = new QTimer(this);
+ this->timer->setSingleShot(true);
+ this->timer->setInterval(interval);
+
+ connect(this->timer, SIGNAL(timeout()), this, SLOT(activate()));
//setStyleSheet("background-color:red;");
setGeometry(x, y, w, h);
@@ -51,13 +57,33 @@ Sensor::Sensor(int x, int y, int w, int h, QString action):
Sensor::~Sensor()
-{}
+{
+ delete this->timer;
+}
void
Sensor::enterEvent(QEvent * event)
{
- qDebug() << "lead::Sensor::enterEvent() " << this->x() << ":" << this->y() << " action: " << this->action;
+ qDebug() << "lead::Sensor::enterEvent() " << this->x() << ":" << this->y() << " interval: " << this->interval;
+
+ this->timer->start();
+}
+
+
+void
+Sensor::leaveEvent(QEvent * event)
+{
+ qDebug() << "lead::Sensor::leaveEvent() " << this->x() << ":" << this->y() << " interval: " << this->interval;
+
+ this->timer->stop();
+}
+
+
+void
+Sensor::activate()
+{
+ qDebug() << "lead::Sensor::activate() " << this->x() << ":" << this->y() << " action: " << this->action;
QProcess::startDetached(action);
}
diff --git a/src/sensor.h b/src/sensor.h
index 0a400b6..ed5add8 100644
--- a/src/sensor.h
+++ b/src/sensor.h
@@ -30,6 +30,7 @@ SOFTWARE.
#include <QWidget>
#include <QScreen>
+#include <QTimer>
namespace Lead {
@@ -40,14 +41,21 @@ class Sensor : public QWidget
Q_OBJECT
public:
- explicit Sensor(int x, int y, int w, int h, QString action);
+ explicit Sensor(int x, int y, int w, int h, QString action, int interval);
~Sensor();
protected:
void enterEvent(QEvent * event);
+ void leaveEvent(QEvent * event);
private:
QString action;
+ QTimer *timer;
+ int interval;
+
+public slots:
+ void activate();
+
};