From c085cc7e5f792c02175e01d6798aa5489b17df43 Mon Sep 17 00:00:00 2001 From: na Date: Fri, 20 Jan 2017 16:13:08 +0100 Subject: init --- .gitignore | 4 + CHANGELOG.md | 4 + LICENSE | 21 +++++ README.md | 94 ++++++++++++++++++++++ TODO.md | 2 + build.ninja | 26 +++++++ build/kernladung.lead | Bin 0 -> 45352 bytes build/lead.moc.o.d | 68 ++++++++++++++++ build/lead.o.d | 71 +++++++++++++++++ build/main.o.d | 68 ++++++++++++++++ build/sensor.moc.o.d | 57 ++++++++++++++ build/sensor.o.d | 64 +++++++++++++++ data/etc/xdg/kernladung/lead.conf | 3 + screenshot.png | Bin 0 -> 1382699 bytes src/lead.cpp | 160 ++++++++++++++++++++++++++++++++++++++ src/lead.h | 67 ++++++++++++++++ src/main.cpp | 37 +++++++++ src/sensor.cpp | 65 ++++++++++++++++ src/sensor.h | 54 +++++++++++++ 19 files changed, 865 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 TODO.md create mode 100644 build.ninja create mode 100755 build/kernladung.lead create mode 100644 build/lead.moc.o.d create mode 100644 build/lead.o.d create mode 100644 build/main.o.d create mode 100644 build/sensor.moc.o.d create mode 100644 build/sensor.o.d create mode 100644 data/etc/xdg/kernladung/lead.conf create mode 100644 screenshot.png create mode 100644 src/lead.cpp create mode 100644 src/lead.h create mode 100644 src/main.cpp create mode 100644 src/sensor.cpp create mode 100644 src/sensor.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..738b015 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.vscode +build/*.o +build/*.cpp +.ninja* \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1cd63a3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,4 @@ +# 01/20/2017 + +- Changed build-system from qmake/make to ninja +- Changed licence from GPLv3 to MIT \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d440aea --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Noah Andreas + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..223756f --- /dev/null +++ b/README.md @@ -0,0 +1,94 @@ +# ATTENTION +Recent versions of the makefile may try to delete system files on `sudo make uninstall`! Dont use existing cmake-files and delete generated makefiles! + +# . + +*lead* provides hot-corners for your desktop, notably for openbox, awesome, i3 and other window managers. + +![Screenshot of lead](https://github.com/nukura/lead/blob/master/screenshot.png) +> Despite the screenshot, the sensors are only 1px in size and invisible. + + +### Features +- hot corners: sensors in the corners of the screen +- hot sides: sensors on center/middle edge of the screen +- freely configurable action for each sensor +- each screen is individually configurable + + +# Get it + +- clone the repository with `$ git clone https://github.com/kernladung/lead` + +**or** + +- download as zip and extract it + + +# Build it + +*lead* uses [ninja](https://github.com/ninja-build/ninja) as build-tool. Open terminal in the root folder of the repository and: + + $ ninja + +### Dependencies +- Qt5Widgets +- Qt5Gui +- Qt5Core + +### Build + +A build `kernladung.lead` is provided in the build dir. It was build on my arch64 system. + + +# Install it + + $ sudo ninja install + + +# Configure it + +On the first run lead will look into these dirs for a conf-file. The first one found will be used. + + ~/.config/kernladung/lead.conf + /etc/xdg/kernladung/lead.conf + +If none of these exists, it will create `~/.config/kernladung/lead.conf` with default values for each screen, ie: + + [eDP1] + bottom= + bottomLeft= + bottomRight= + left= + right= + top= + topLeft= + topRight= + +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=kernladung.californium toggle + topRight=skippy-xd + +Used config-files and theme-files are monitored and changes are applied automatically. + + +# Use it + +*lead* provides the binary `kernladung.lead` which creates sensors for each configured corner or side. + +Start *lead* as background process: + + $ kernladung.lead & + + +# 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. diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..5760adb --- /dev/null +++ b/TODO.md @@ -0,0 +1,2 @@ +- show screennames to identify screen +- add commands to run if mouse leaves sensor diff --git a/build.ninja b/build.ninja new file mode 100644 index 0000000..2029300 --- /dev/null +++ b/build.ninja @@ -0,0 +1,26 @@ + +includes = -Isrc -I/usr/include -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore + + +rule cpp + depfile = $out.d + command = clang -std=c++11 -Wall -O3 -fPIC -MMD -MF $out.d $includes -c $in -o $out + +rule link + command = g++ -o $out $in -lQt5Xdg -lQt5Widgets -lQt5Gui -lQt5Core + +rule moc + command = moc $includes -o $out $in + + +build build/lead.moc.cpp: moc src/lead.h +build build/sensor.moc.cpp: moc src/sensor.h + +build build/main.o: cpp src/main.cpp +build build/lead.o: cpp src/lead.cpp +build build/sensor.o: cpp src/sensor.cpp + +build build/lead.moc.o: cpp build/lead.moc.cpp +build build/sensor.moc.o: cpp build/sensor.moc.cpp + +build build/kernladung.lead: link build/main.o build/lead.o build/sensor.o build/lead.moc.o build/sensor.moc.o diff --git a/build/kernladung.lead b/build/kernladung.lead new file mode 100755 index 0000000..e96c772 Binary files /dev/null and b/build/kernladung.lead differ diff --git a/build/lead.moc.o.d b/build/lead.moc.o.d new file mode 100644 index 0000000..ea486cd --- /dev/null +++ b/build/lead.moc.o.d @@ -0,0 +1,68 @@ +build/lead.moc.o: build/lead.moc.cpp build/../src/lead.h src/sensor.h \ + /usr/include/qt/QtWidgets/QWidget /usr/include/qt/QtWidgets/qwidget.h \ + /usr/include/qt/QtGui/qwindowdefs.h /usr/include/qt/QtCore/qglobal.h \ + /usr/include/qt/QtCore/qconfig.h /usr/include/qt/QtCore/qfeatures.h \ + /usr/include/qt/QtCore/qsystemdetection.h \ + /usr/include/qt/QtCore/qprocessordetection.h \ + /usr/include/qt/QtCore/qcompilerdetection.h \ + /usr/include/qt/QtCore/qtypeinfo.h \ + /usr/include/qt/QtCore/qtypetraits.h /usr/include/qt/QtCore/qisenum.h \ + /usr/include/qt/QtCore/qsysinfo.h /usr/include/qt/QtCore/qlogging.h \ + /usr/include/qt/QtCore/qflags.h /usr/include/qt/QtCore/qatomic.h \ + /usr/include/qt/QtCore/qbasicatomic.h \ + /usr/include/qt/QtCore/qatomic_cxx11.h \ + /usr/include/qt/QtCore/qgenericatomic.h \ + /usr/include/qt/QtCore/qglobalstatic.h \ + /usr/include/qt/QtCore/qnumeric.h \ + /usr/include/qt/QtCore/qversiontagging.h \ + /usr/include/qt/QtCore/qobjectdefs.h \ + /usr/include/qt/QtCore/qnamespace.h \ + /usr/include/qt/QtCore/qobjectdefs_impl.h \ + /usr/include/qt/QtCore/qobject.h /usr/include/qt/QtCore/qstring.h \ + /usr/include/qt/QtCore/qchar.h /usr/include/qt/QtCore/qbytearray.h \ + /usr/include/qt/QtCore/qrefcount.h /usr/include/qt/QtCore/qarraydata.h \ + /usr/include/qt/QtCore/qlist.h /usr/include/qt/QtCore/qalgorithms.h \ + /usr/include/qt/QtCore/qiterator.h \ + /usr/include/qt/QtCore/qhashfunctions.h /usr/include/qt/QtCore/qpair.h \ + /usr/include/qt/QtCore/qbytearraylist.h \ + /usr/include/qt/QtCore/qstringlist.h /usr/include/qt/QtCore/qregexp.h \ + /usr/include/qt/QtCore/qstringmatcher.h \ + /usr/include/qt/QtCore/qscopedpointer.h \ + /usr/include/qt/QtCore/qmetatype.h \ + /usr/include/qt/QtCore/qvarlengtharray.h \ + /usr/include/qt/QtCore/qcontainerfwd.h \ + /usr/include/qt/QtCore/qobject_impl.h \ + /usr/include/qt/QtCore/qmargins.h /usr/include/qt/QtGui/qpaintdevice.h \ + /usr/include/qt/QtCore/qrect.h /usr/include/qt/QtCore/qsize.h \ + /usr/include/qt/QtCore/qpoint.h /usr/include/qt/QtGui/qpalette.h \ + /usr/include/qt/QtGui/qcolor.h /usr/include/qt/QtGui/qrgb.h \ + /usr/include/qt/QtGui/qrgba64.h /usr/include/qt/QtGui/qbrush.h \ + /usr/include/qt/QtCore/qvector.h /usr/include/qt/QtGui/qmatrix.h \ + /usr/include/qt/QtGui/qpolygon.h /usr/include/qt/QtGui/qregion.h \ + /usr/include/qt/QtCore/qdatastream.h \ + /usr/include/qt/QtCore/qiodevice.h /usr/include/qt/QtCore/qline.h \ + /usr/include/qt/QtGui/qtransform.h \ + /usr/include/qt/QtGui/qpainterpath.h /usr/include/qt/QtGui/qimage.h \ + /usr/include/qt/QtGui/qpixelformat.h /usr/include/qt/QtGui/qpixmap.h \ + /usr/include/qt/QtCore/qsharedpointer.h \ + /usr/include/qt/QtCore/qshareddata.h /usr/include/qt/QtCore/qhash.h \ + /usr/include/qt/QtCore/qsharedpointer_impl.h \ + /usr/include/qt/QtGui/qfont.h /usr/include/qt/QtGui/qfontmetrics.h \ + /usr/include/qt/QtGui/qfontinfo.h \ + /usr/include/qt/QtWidgets/qsizepolicy.h \ + /usr/include/qt/QtGui/qcursor.h /usr/include/qt/QtGui/qkeysequence.h \ + /usr/include/qt/QtGui/QScreen /usr/include/qt/QtGui/qscreen.h \ + /usr/include/qt/QtCore/QList /usr/include/qt/QtCore/QObject \ + /usr/include/qt/QtCore/QRect /usr/include/qt/QtCore/QSize \ + /usr/include/qt/QtCore/QSizeF /usr/include/qt/QtGui/QTransform \ + /usr/include/qt/QtWidgets/QApplication \ + /usr/include/qt/QtWidgets/qapplication.h \ + /usr/include/qt/QtCore/qcoreapplication.h \ + /usr/include/qt/QtCore/qcoreevent.h \ + /usr/include/qt/QtCore/qeventloop.h \ + /usr/include/qt/QtGui/qguiapplication.h \ + /usr/include/qt/QtGui/qinputmethod.h /usr/include/qt/QtCore/qlocale.h \ + /usr/include/qt/QtCore/qvariant.h /usr/include/qt/QtCore/qmap.h \ + /usr/include/qt/QtCore/QSettings /usr/include/qt/QtCore/qsettings.h \ + /usr/include/qt/QtCore/QFileSystemWatcher \ + /usr/include/qt/QtCore/qfilesystemwatcher.h diff --git a/build/lead.o.d b/build/lead.o.d new file mode 100644 index 0000000..6046ed1 --- /dev/null +++ b/build/lead.o.d @@ -0,0 +1,71 @@ +build/lead.o: src/lead.cpp src/lead.h src/sensor.h \ + /usr/include/qt/QtWidgets/QWidget /usr/include/qt/QtWidgets/qwidget.h \ + /usr/include/qt/QtGui/qwindowdefs.h /usr/include/qt/QtCore/qglobal.h \ + /usr/include/qt/QtCore/qconfig.h /usr/include/qt/QtCore/qfeatures.h \ + /usr/include/qt/QtCore/qsystemdetection.h \ + /usr/include/qt/QtCore/qprocessordetection.h \ + /usr/include/qt/QtCore/qcompilerdetection.h \ + /usr/include/qt/QtCore/qtypeinfo.h \ + /usr/include/qt/QtCore/qtypetraits.h /usr/include/qt/QtCore/qisenum.h \ + /usr/include/qt/QtCore/qsysinfo.h /usr/include/qt/QtCore/qlogging.h \ + /usr/include/qt/QtCore/qflags.h /usr/include/qt/QtCore/qatomic.h \ + /usr/include/qt/QtCore/qbasicatomic.h \ + /usr/include/qt/QtCore/qatomic_cxx11.h \ + /usr/include/qt/QtCore/qgenericatomic.h \ + /usr/include/qt/QtCore/qglobalstatic.h \ + /usr/include/qt/QtCore/qnumeric.h \ + /usr/include/qt/QtCore/qversiontagging.h \ + /usr/include/qt/QtCore/qobjectdefs.h \ + /usr/include/qt/QtCore/qnamespace.h \ + /usr/include/qt/QtCore/qobjectdefs_impl.h \ + /usr/include/qt/QtCore/qobject.h /usr/include/qt/QtCore/qstring.h \ + /usr/include/qt/QtCore/qchar.h /usr/include/qt/QtCore/qbytearray.h \ + /usr/include/qt/QtCore/qrefcount.h /usr/include/qt/QtCore/qarraydata.h \ + /usr/include/qt/QtCore/qlist.h /usr/include/qt/QtCore/qalgorithms.h \ + /usr/include/qt/QtCore/qiterator.h \ + /usr/include/qt/QtCore/qhashfunctions.h /usr/include/qt/QtCore/qpair.h \ + /usr/include/qt/QtCore/qbytearraylist.h \ + /usr/include/qt/QtCore/qstringlist.h /usr/include/qt/QtCore/qregexp.h \ + /usr/include/qt/QtCore/qstringmatcher.h \ + /usr/include/qt/QtCore/qscopedpointer.h \ + /usr/include/qt/QtCore/qmetatype.h \ + /usr/include/qt/QtCore/qvarlengtharray.h \ + /usr/include/qt/QtCore/qcontainerfwd.h \ + /usr/include/qt/QtCore/qobject_impl.h \ + /usr/include/qt/QtCore/qmargins.h /usr/include/qt/QtGui/qpaintdevice.h \ + /usr/include/qt/QtCore/qrect.h /usr/include/qt/QtCore/qsize.h \ + /usr/include/qt/QtCore/qpoint.h /usr/include/qt/QtGui/qpalette.h \ + /usr/include/qt/QtGui/qcolor.h /usr/include/qt/QtGui/qrgb.h \ + /usr/include/qt/QtGui/qrgba64.h /usr/include/qt/QtGui/qbrush.h \ + /usr/include/qt/QtCore/qvector.h /usr/include/qt/QtGui/qmatrix.h \ + /usr/include/qt/QtGui/qpolygon.h /usr/include/qt/QtGui/qregion.h \ + /usr/include/qt/QtCore/qdatastream.h \ + /usr/include/qt/QtCore/qiodevice.h /usr/include/qt/QtCore/qline.h \ + /usr/include/qt/QtGui/qtransform.h \ + /usr/include/qt/QtGui/qpainterpath.h /usr/include/qt/QtGui/qimage.h \ + /usr/include/qt/QtGui/qpixelformat.h /usr/include/qt/QtGui/qpixmap.h \ + /usr/include/qt/QtCore/qsharedpointer.h \ + /usr/include/qt/QtCore/qshareddata.h /usr/include/qt/QtCore/qhash.h \ + /usr/include/qt/QtCore/qsharedpointer_impl.h \ + /usr/include/qt/QtGui/qfont.h /usr/include/qt/QtGui/qfontmetrics.h \ + /usr/include/qt/QtGui/qfontinfo.h \ + /usr/include/qt/QtWidgets/qsizepolicy.h \ + /usr/include/qt/QtGui/qcursor.h /usr/include/qt/QtGui/qkeysequence.h \ + /usr/include/qt/QtGui/QScreen /usr/include/qt/QtGui/qscreen.h \ + /usr/include/qt/QtCore/QList /usr/include/qt/QtCore/QObject \ + /usr/include/qt/QtCore/QRect /usr/include/qt/QtCore/QSize \ + /usr/include/qt/QtCore/QSizeF /usr/include/qt/QtGui/QTransform \ + /usr/include/qt/QtWidgets/QApplication \ + /usr/include/qt/QtWidgets/qapplication.h \ + /usr/include/qt/QtCore/qcoreapplication.h \ + /usr/include/qt/QtCore/qcoreevent.h \ + /usr/include/qt/QtCore/qeventloop.h \ + /usr/include/qt/QtGui/qguiapplication.h \ + /usr/include/qt/QtGui/qinputmethod.h /usr/include/qt/QtCore/qlocale.h \ + /usr/include/qt/QtCore/qvariant.h /usr/include/qt/QtCore/qmap.h \ + /usr/include/qt/QtCore/QSettings /usr/include/qt/QtCore/qsettings.h \ + /usr/include/qt/QtCore/QFileSystemWatcher \ + /usr/include/qt/QtCore/qfilesystemwatcher.h \ + /usr/include/qt/QtCore/QDebug /usr/include/qt/QtCore/qdebug.h \ + /usr/include/qt/QtCore/qtextstream.h /usr/include/qt/QtCore/qset.h \ + /usr/include/qt/QtCore/qcontiguouscache.h diff --git a/build/main.o.d b/build/main.o.d new file mode 100644 index 0000000..afdc5c0 --- /dev/null +++ b/build/main.o.d @@ -0,0 +1,68 @@ +build/main.o: src/main.cpp src/lead.h src/sensor.h \ + /usr/include/qt/QtWidgets/QWidget /usr/include/qt/QtWidgets/qwidget.h \ + /usr/include/qt/QtGui/qwindowdefs.h /usr/include/qt/QtCore/qglobal.h \ + /usr/include/qt/QtCore/qconfig.h /usr/include/qt/QtCore/qfeatures.h \ + /usr/include/qt/QtCore/qsystemdetection.h \ + /usr/include/qt/QtCore/qprocessordetection.h \ + /usr/include/qt/QtCore/qcompilerdetection.h \ + /usr/include/qt/QtCore/qtypeinfo.h \ + /usr/include/qt/QtCore/qtypetraits.h /usr/include/qt/QtCore/qisenum.h \ + /usr/include/qt/QtCore/qsysinfo.h /usr/include/qt/QtCore/qlogging.h \ + /usr/include/qt/QtCore/qflags.h /usr/include/qt/QtCore/qatomic.h \ + /usr/include/qt/QtCore/qbasicatomic.h \ + /usr/include/qt/QtCore/qatomic_cxx11.h \ + /usr/include/qt/QtCore/qgenericatomic.h \ + /usr/include/qt/QtCore/qglobalstatic.h \ + /usr/include/qt/QtCore/qnumeric.h \ + /usr/include/qt/QtCore/qversiontagging.h \ + /usr/include/qt/QtCore/qobjectdefs.h \ + /usr/include/qt/QtCore/qnamespace.h \ + /usr/include/qt/QtCore/qobjectdefs_impl.h \ + /usr/include/qt/QtCore/qobject.h /usr/include/qt/QtCore/qstring.h \ + /usr/include/qt/QtCore/qchar.h /usr/include/qt/QtCore/qbytearray.h \ + /usr/include/qt/QtCore/qrefcount.h /usr/include/qt/QtCore/qarraydata.h \ + /usr/include/qt/QtCore/qlist.h /usr/include/qt/QtCore/qalgorithms.h \ + /usr/include/qt/QtCore/qiterator.h \ + /usr/include/qt/QtCore/qhashfunctions.h /usr/include/qt/QtCore/qpair.h \ + /usr/include/qt/QtCore/qbytearraylist.h \ + /usr/include/qt/QtCore/qstringlist.h /usr/include/qt/QtCore/qregexp.h \ + /usr/include/qt/QtCore/qstringmatcher.h \ + /usr/include/qt/QtCore/qscopedpointer.h \ + /usr/include/qt/QtCore/qmetatype.h \ + /usr/include/qt/QtCore/qvarlengtharray.h \ + /usr/include/qt/QtCore/qcontainerfwd.h \ + /usr/include/qt/QtCore/qobject_impl.h \ + /usr/include/qt/QtCore/qmargins.h /usr/include/qt/QtGui/qpaintdevice.h \ + /usr/include/qt/QtCore/qrect.h /usr/include/qt/QtCore/qsize.h \ + /usr/include/qt/QtCore/qpoint.h /usr/include/qt/QtGui/qpalette.h \ + /usr/include/qt/QtGui/qcolor.h /usr/include/qt/QtGui/qrgb.h \ + /usr/include/qt/QtGui/qrgba64.h /usr/include/qt/QtGui/qbrush.h \ + /usr/include/qt/QtCore/qvector.h /usr/include/qt/QtGui/qmatrix.h \ + /usr/include/qt/QtGui/qpolygon.h /usr/include/qt/QtGui/qregion.h \ + /usr/include/qt/QtCore/qdatastream.h \ + /usr/include/qt/QtCore/qiodevice.h /usr/include/qt/QtCore/qline.h \ + /usr/include/qt/QtGui/qtransform.h \ + /usr/include/qt/QtGui/qpainterpath.h /usr/include/qt/QtGui/qimage.h \ + /usr/include/qt/QtGui/qpixelformat.h /usr/include/qt/QtGui/qpixmap.h \ + /usr/include/qt/QtCore/qsharedpointer.h \ + /usr/include/qt/QtCore/qshareddata.h /usr/include/qt/QtCore/qhash.h \ + /usr/include/qt/QtCore/qsharedpointer_impl.h \ + /usr/include/qt/QtGui/qfont.h /usr/include/qt/QtGui/qfontmetrics.h \ + /usr/include/qt/QtGui/qfontinfo.h \ + /usr/include/qt/QtWidgets/qsizepolicy.h \ + /usr/include/qt/QtGui/qcursor.h /usr/include/qt/QtGui/qkeysequence.h \ + /usr/include/qt/QtGui/QScreen /usr/include/qt/QtGui/qscreen.h \ + /usr/include/qt/QtCore/QList /usr/include/qt/QtCore/QObject \ + /usr/include/qt/QtCore/QRect /usr/include/qt/QtCore/QSize \ + /usr/include/qt/QtCore/QSizeF /usr/include/qt/QtGui/QTransform \ + /usr/include/qt/QtWidgets/QApplication \ + /usr/include/qt/QtWidgets/qapplication.h \ + /usr/include/qt/QtCore/qcoreapplication.h \ + /usr/include/qt/QtCore/qcoreevent.h \ + /usr/include/qt/QtCore/qeventloop.h \ + /usr/include/qt/QtGui/qguiapplication.h \ + /usr/include/qt/QtGui/qinputmethod.h /usr/include/qt/QtCore/qlocale.h \ + /usr/include/qt/QtCore/qvariant.h /usr/include/qt/QtCore/qmap.h \ + /usr/include/qt/QtCore/QSettings /usr/include/qt/QtCore/qsettings.h \ + /usr/include/qt/QtCore/QFileSystemWatcher \ + /usr/include/qt/QtCore/qfilesystemwatcher.h diff --git a/build/sensor.moc.o.d b/build/sensor.moc.o.d new file mode 100644 index 0000000..8a9d927 --- /dev/null +++ b/build/sensor.moc.o.d @@ -0,0 +1,57 @@ +build/sensor.moc.o: build/sensor.moc.cpp build/../src/sensor.h \ + /usr/include/qt/QtWidgets/QWidget /usr/include/qt/QtWidgets/qwidget.h \ + /usr/include/qt/QtGui/qwindowdefs.h /usr/include/qt/QtCore/qglobal.h \ + /usr/include/qt/QtCore/qconfig.h /usr/include/qt/QtCore/qfeatures.h \ + /usr/include/qt/QtCore/qsystemdetection.h \ + /usr/include/qt/QtCore/qprocessordetection.h \ + /usr/include/qt/QtCore/qcompilerdetection.h \ + /usr/include/qt/QtCore/qtypeinfo.h \ + /usr/include/qt/QtCore/qtypetraits.h /usr/include/qt/QtCore/qisenum.h \ + /usr/include/qt/QtCore/qsysinfo.h /usr/include/qt/QtCore/qlogging.h \ + /usr/include/qt/QtCore/qflags.h /usr/include/qt/QtCore/qatomic.h \ + /usr/include/qt/QtCore/qbasicatomic.h \ + /usr/include/qt/QtCore/qatomic_cxx11.h \ + /usr/include/qt/QtCore/qgenericatomic.h \ + /usr/include/qt/QtCore/qglobalstatic.h \ + /usr/include/qt/QtCore/qnumeric.h \ + /usr/include/qt/QtCore/qversiontagging.h \ + /usr/include/qt/QtCore/qobjectdefs.h \ + /usr/include/qt/QtCore/qnamespace.h \ + /usr/include/qt/QtCore/qobjectdefs_impl.h \ + /usr/include/qt/QtCore/qobject.h /usr/include/qt/QtCore/qstring.h \ + /usr/include/qt/QtCore/qchar.h /usr/include/qt/QtCore/qbytearray.h \ + /usr/include/qt/QtCore/qrefcount.h /usr/include/qt/QtCore/qarraydata.h \ + /usr/include/qt/QtCore/qlist.h /usr/include/qt/QtCore/qalgorithms.h \ + /usr/include/qt/QtCore/qiterator.h \ + /usr/include/qt/QtCore/qhashfunctions.h /usr/include/qt/QtCore/qpair.h \ + /usr/include/qt/QtCore/qbytearraylist.h \ + /usr/include/qt/QtCore/qstringlist.h /usr/include/qt/QtCore/qregexp.h \ + /usr/include/qt/QtCore/qstringmatcher.h \ + /usr/include/qt/QtCore/qscopedpointer.h \ + /usr/include/qt/QtCore/qmetatype.h \ + /usr/include/qt/QtCore/qvarlengtharray.h \ + /usr/include/qt/QtCore/qcontainerfwd.h \ + /usr/include/qt/QtCore/qobject_impl.h \ + /usr/include/qt/QtCore/qmargins.h /usr/include/qt/QtGui/qpaintdevice.h \ + /usr/include/qt/QtCore/qrect.h /usr/include/qt/QtCore/qsize.h \ + /usr/include/qt/QtCore/qpoint.h /usr/include/qt/QtGui/qpalette.h \ + /usr/include/qt/QtGui/qcolor.h /usr/include/qt/QtGui/qrgb.h \ + /usr/include/qt/QtGui/qrgba64.h /usr/include/qt/QtGui/qbrush.h \ + /usr/include/qt/QtCore/qvector.h /usr/include/qt/QtGui/qmatrix.h \ + /usr/include/qt/QtGui/qpolygon.h /usr/include/qt/QtGui/qregion.h \ + /usr/include/qt/QtCore/qdatastream.h \ + /usr/include/qt/QtCore/qiodevice.h /usr/include/qt/QtCore/qline.h \ + /usr/include/qt/QtGui/qtransform.h \ + /usr/include/qt/QtGui/qpainterpath.h /usr/include/qt/QtGui/qimage.h \ + /usr/include/qt/QtGui/qpixelformat.h /usr/include/qt/QtGui/qpixmap.h \ + /usr/include/qt/QtCore/qsharedpointer.h \ + /usr/include/qt/QtCore/qshareddata.h /usr/include/qt/QtCore/qhash.h \ + /usr/include/qt/QtCore/qsharedpointer_impl.h \ + /usr/include/qt/QtGui/qfont.h /usr/include/qt/QtGui/qfontmetrics.h \ + /usr/include/qt/QtGui/qfontinfo.h \ + /usr/include/qt/QtWidgets/qsizepolicy.h \ + /usr/include/qt/QtGui/qcursor.h /usr/include/qt/QtGui/qkeysequence.h \ + /usr/include/qt/QtGui/QScreen /usr/include/qt/QtGui/qscreen.h \ + /usr/include/qt/QtCore/QList /usr/include/qt/QtCore/QObject \ + /usr/include/qt/QtCore/QRect /usr/include/qt/QtCore/QSize \ + /usr/include/qt/QtCore/QSizeF /usr/include/qt/QtGui/QTransform diff --git a/build/sensor.o.d b/build/sensor.o.d new file mode 100644 index 0000000..6ad54bb --- /dev/null +++ b/build/sensor.o.d @@ -0,0 +1,64 @@ +build/sensor.o: src/sensor.cpp src/sensor.h \ + /usr/include/qt/QtWidgets/QWidget /usr/include/qt/QtWidgets/qwidget.h \ + /usr/include/qt/QtGui/qwindowdefs.h /usr/include/qt/QtCore/qglobal.h \ + /usr/include/qt/QtCore/qconfig.h /usr/include/qt/QtCore/qfeatures.h \ + /usr/include/qt/QtCore/qsystemdetection.h \ + /usr/include/qt/QtCore/qprocessordetection.h \ + /usr/include/qt/QtCore/qcompilerdetection.h \ + /usr/include/qt/QtCore/qtypeinfo.h \ + /usr/include/qt/QtCore/qtypetraits.h /usr/include/qt/QtCore/qisenum.h \ + /usr/include/qt/QtCore/qsysinfo.h /usr/include/qt/QtCore/qlogging.h \ + /usr/include/qt/QtCore/qflags.h /usr/include/qt/QtCore/qatomic.h \ + /usr/include/qt/QtCore/qbasicatomic.h \ + /usr/include/qt/QtCore/qatomic_cxx11.h \ + /usr/include/qt/QtCore/qgenericatomic.h \ + /usr/include/qt/QtCore/qglobalstatic.h \ + /usr/include/qt/QtCore/qnumeric.h \ + /usr/include/qt/QtCore/qversiontagging.h \ + /usr/include/qt/QtCore/qobjectdefs.h \ + /usr/include/qt/QtCore/qnamespace.h \ + /usr/include/qt/QtCore/qobjectdefs_impl.h \ + /usr/include/qt/QtCore/qobject.h /usr/include/qt/QtCore/qstring.h \ + /usr/include/qt/QtCore/qchar.h /usr/include/qt/QtCore/qbytearray.h \ + /usr/include/qt/QtCore/qrefcount.h /usr/include/qt/QtCore/qarraydata.h \ + /usr/include/qt/QtCore/qlist.h /usr/include/qt/QtCore/qalgorithms.h \ + /usr/include/qt/QtCore/qiterator.h \ + /usr/include/qt/QtCore/qhashfunctions.h /usr/include/qt/QtCore/qpair.h \ + /usr/include/qt/QtCore/qbytearraylist.h \ + /usr/include/qt/QtCore/qstringlist.h /usr/include/qt/QtCore/qregexp.h \ + /usr/include/qt/QtCore/qstringmatcher.h \ + /usr/include/qt/QtCore/qscopedpointer.h \ + /usr/include/qt/QtCore/qmetatype.h \ + /usr/include/qt/QtCore/qvarlengtharray.h \ + /usr/include/qt/QtCore/qcontainerfwd.h \ + /usr/include/qt/QtCore/qobject_impl.h \ + /usr/include/qt/QtCore/qmargins.h /usr/include/qt/QtGui/qpaintdevice.h \ + /usr/include/qt/QtCore/qrect.h /usr/include/qt/QtCore/qsize.h \ + /usr/include/qt/QtCore/qpoint.h /usr/include/qt/QtGui/qpalette.h \ + /usr/include/qt/QtGui/qcolor.h /usr/include/qt/QtGui/qrgb.h \ + /usr/include/qt/QtGui/qrgba64.h /usr/include/qt/QtGui/qbrush.h \ + /usr/include/qt/QtCore/qvector.h /usr/include/qt/QtGui/qmatrix.h \ + /usr/include/qt/QtGui/qpolygon.h /usr/include/qt/QtGui/qregion.h \ + /usr/include/qt/QtCore/qdatastream.h \ + /usr/include/qt/QtCore/qiodevice.h /usr/include/qt/QtCore/qline.h \ + /usr/include/qt/QtGui/qtransform.h \ + /usr/include/qt/QtGui/qpainterpath.h /usr/include/qt/QtGui/qimage.h \ + /usr/include/qt/QtGui/qpixelformat.h /usr/include/qt/QtGui/qpixmap.h \ + /usr/include/qt/QtCore/qsharedpointer.h \ + /usr/include/qt/QtCore/qshareddata.h /usr/include/qt/QtCore/qhash.h \ + /usr/include/qt/QtCore/qsharedpointer_impl.h \ + /usr/include/qt/QtGui/qfont.h /usr/include/qt/QtGui/qfontmetrics.h \ + /usr/include/qt/QtGui/qfontinfo.h \ + /usr/include/qt/QtWidgets/qsizepolicy.h \ + /usr/include/qt/QtGui/qcursor.h /usr/include/qt/QtGui/qkeysequence.h \ + /usr/include/qt/QtGui/QScreen /usr/include/qt/QtGui/qscreen.h \ + /usr/include/qt/QtCore/QList /usr/include/qt/QtCore/QObject \ + /usr/include/qt/QtCore/QRect /usr/include/qt/QtCore/QSize \ + /usr/include/qt/QtCore/QSizeF /usr/include/qt/QtGui/QTransform \ + /usr/include/qt/QtCore/QEvent /usr/include/qt/QtCore/qcoreevent.h \ + /usr/include/qt/QtCore/QDebug /usr/include/qt/QtCore/qdebug.h \ + /usr/include/qt/QtCore/qmap.h /usr/include/qt/QtCore/qtextstream.h \ + /usr/include/qt/QtCore/qlocale.h /usr/include/qt/QtCore/qvariant.h \ + /usr/include/qt/QtCore/qset.h \ + /usr/include/qt/QtCore/qcontiguouscache.h \ + /usr/include/qt/QtCore/QProcess /usr/include/qt/QtCore/qprocess.h diff --git a/data/etc/xdg/kernladung/lead.conf b/data/etc/xdg/kernladung/lead.conf new file mode 100644 index 0000000..0ab0c9b --- /dev/null +++ b/data/etc/xdg/kernladung/lead.conf @@ -0,0 +1,3 @@ +[General] +menu=/etc/xdg/menus/sulfur-applications.menu +theme=/usr/share/kernladung/californium/themes/default/default.qss diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..a9047ad Binary files /dev/null and b/screenshot.png differ diff --git a/src/lead.cpp b/src/lead.cpp new file mode 100644 index 0000000..cd47b19 --- /dev/null +++ b/src/lead.cpp @@ -0,0 +1,160 @@ +/* +MIT License + +Copyright (c) 2017 Noah Andreas + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + + +#include "lead.h" +#include "sensor.h" +#include +#include +#include + + +namespace kernladung { + + +Lead::Lead(int &argc, char** argv) : + QApplication(argc, argv), + settings("kernladung", "lead"), + watcher() +{ + loadScreens(); + watchSettings(); +} + + +Lead::~Lead() +{ + qDeleteAll(sensors); +} + + +void +Lead::watchSettings() +{ + watcher.addPath(settings.fileName()); + + connect(&watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString))); +} + + +void +Lead::fileChanged(QString fileName) +{ + qDebug() << "kernladung::Lead::fileChanged() fileName: " << fileName; + + // this reloads the settings from the file + settings.sync(); + + // some editors dont update but delete/create the config file, in this + // case our watcher loses the file so we have to add it again + watcher.addPath( fileName ); + + // simply reload everything + reloadScreens(); +} + + +void +Lead::screenAdded(QScreen* screen) +{ + loadScreen(screen); +} + + +void +Lead::screenRemoved(QScreen* screen) +{ + // thats the easiest way + reloadScreens(); +} + + +void +Lead::reloadScreens() +{ + qDeleteAll(sensors); + sensors.clear(); + + loadScreens(); +} + + +void +Lead::loadScreens() +{ + foreach (QScreen* screen, screens()) + { + loadScreen(screen); + } +} + + +void +Lead::loadScreen(QScreen* screen) +{ + qDebug() << "kernladung::Lead::loadScreen() " << screen->name(); + + QRect rec = screen->geometry(); + + loadSensor(screen, "top", rec.width() / 3, 0, rec.width() / 3, 10); + loadSensor(screen, "right", rec.width() - 1, rec.height() / 3, 1, rec.height() / 3); + loadSensor(screen, "bottom", rec.width() / 3, rec.height() - 1, rec.width() / 3, 1); + loadSensor(screen, "left", 0, rec.height() / 3, 1, rec.height() / 3); + loadSensor(screen, "topLeft", 0, 0, 1, 1); + loadSensor(screen, "topRight", rec.width() - 1, 0, 1, 1); + loadSensor(screen, "bottomRight", rec.width() - 1, rec.height() - 1, 1, 1); + loadSensor(screen, "bottomLeft", 0, rec.height() - 1, 1, 1); +} + + +void +Lead::loadSensor(QScreen* screen, QString name, int x, int y, int w, int h) +{ + + QString key = screen->name() + "/" + name; + + + if (!settings.contains(key) ) + { + qDebug() << "kernladung::Lead::loadSensor() key " << name << " not found"; + + // restore missing key + settings.setValue(key, QString()); + return; + } + + if (settings.value(key).toString().isEmpty()) + { + qDebug() << "kernladung::Lead::loadSensor() key " << name << " is empty"; + return; + } + + + // create sensor and save in list so we can delete all sensors on delete + + sensors.append( new lead::Sensor(x, y, w, h, settings.value(key).toString()) ); +} + + +} // namespace diff --git a/src/lead.h b/src/lead.h new file mode 100644 index 0000000..035e0f2 --- /dev/null +++ b/src/lead.h @@ -0,0 +1,67 @@ +/* +MIT License + +Copyright (c) 2017 Noah Andreas + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + + +#pragma once + + +#include "sensor.h" +#include +#include +#include +#include +#include + + +namespace kernladung { + + +class Lead : public QApplication +{ + Q_OBJECT + +public: + explicit Lead(int &argc, char** argv); + ~Lead(); + +private: + QSettings settings; + QFileSystemWatcher watcher; + QList sensors; + + void screenAdded(QScreen* screen); + void screenRemoved(QScreen* screen); + void watchSettings(); + void loadScreens(); + void loadScreen(QScreen* screen); + void loadSensor(QScreen* screen, QString name, int x, int y, int w, int h); + void reloadScreens(); + +public slots: + void fileChanged(QString fileName); + +}; + + +} // namespace diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..601c065 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,37 @@ +/* +MIT License + +Copyright (c) 2017 Noah Andreas + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + + +#include "lead.h" +#include + + +int +main(int argc, char *argv[]) +{ + kernladung::Lead lead(argc, argv); + + return lead.exec(); +} + diff --git a/src/sensor.cpp b/src/sensor.cpp new file mode 100644 index 0000000..41c4326 --- /dev/null +++ b/src/sensor.cpp @@ -0,0 +1,65 @@ +/* +MIT License + +Copyright (c) 2017 Noah Andreas + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + + +#include "sensor.h" +#include +#include +#include + + +namespace kernladung { +namespace lead { + + +Sensor::Sensor(int x, int y, int w, int h, QString action): + QWidget() +{ + qDebug() << "kernladung::lead::Sensor() " << x << "," << y << "," << w << "," << h << " : " << action; + + this->action = action; + + //setStyleSheet("background-color:red;"); + setGeometry(x, y, w, h); + setAttribute(Qt::WA_TranslucentBackground, true); + setWindowFlags(windowFlags() | Qt::X11BypassWindowManagerHint | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint ); + + show(); +} + + +Sensor::~Sensor() +{} + + +void +Sensor::enterEvent(QEvent * event) +{ + qDebug() << "kernladung::lead::Sensor::enterEvent() " << this->x() << ":" << this->y() << " action: " << this->action; + + QProcess::startDetached(action); +} + + +}} // namespace diff --git a/src/sensor.h b/src/sensor.h new file mode 100644 index 0000000..0404583 --- /dev/null +++ b/src/sensor.h @@ -0,0 +1,54 @@ +/* +MIT License + +Copyright (c) 2017 Noah Andreas + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + + +#pragma once + + +#include +#include + + +namespace kernladung { +namespace lead { + + +class Sensor : public QWidget +{ + Q_OBJECT + +public: + explicit Sensor(int x, int y, int w, int h, QString action); + ~Sensor(); + +protected: + void enterEvent(QEvent * event); + +private: + QString action; + +}; + + +}} // namespace -- cgit v1.2.3