diff --git a/Readme.md b/Readme.md index 29ab1dd..5e05d09 100644 --- a/Readme.md +++ b/Readme.md @@ -303,6 +303,21 @@ A Python-based GUI for creating Wine application launchers/Desktop shortcuts. FORMAT: Arch Linux PKGBUILD script + source archive. +**xclipshow** +-------------- + +QT5 based program which shows information about the current clipboard content. + +Original program code & instructions here: + +[Application that allows to show clipboard contents and its MIME type?](https://unix.stackexchange.com/questions/163081/application-that-allows-to-show-clipboard-contents-and-its-mime-type) + +FORMAT: Arch Linux PKGBUILD script + source files. + +NOTE: This program is useful if used with a combination of commands. I tend to use the program to automate 'take a screenshot and paste it to Kolourpaint' process. To achieve my goal, I need Plasma 5 desktop environment + two additional command-line programs: loliclip & imagemagick. + +For additional info and exact commands (and where to put them), please take a look into /xclipshow/printscreen file. + **xephem** -------------- diff --git a/xclipshow/CMakeLists.txt b/xclipshow/CMakeLists.txt new file mode 100644 index 0000000..4808b34 --- /dev/null +++ b/xclipshow/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.0.0) +project(xclipshow) +find_package(Qt5Widgets) +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SRC + xclipshow.cpp) + +add_definitions(-std=c++11) +add_executable(xclipshow ${SRC}) +qt5_use_modules(xclipshow Widgets Core) \ No newline at end of file diff --git a/xclipshow/PKGBUILD b/xclipshow/PKGBUILD new file mode 100644 index 0000000..f0e9a3c --- /dev/null +++ b/xclipshow/PKGBUILD @@ -0,0 +1,29 @@ +pkgname=xclipshow +pkgver=1 +pkgrel=1 +pkgdesc="Show information of current clipboard contents" +url=() +arch=('any') +license=('BSD') +install='' +source=(xclipshow.cpp CMakeLists.txt) +depends=('cmake' 'qt5-base') +optdepends=() +conflicts=() +#provides='' +makedepends=() + +build() { + cd $srcdir + mkdir build + cd ./build + cmake $srcdir + make +} + +package() { + mkdir -p $pkgdir/usr/bin/ + install -Dm 755 $srcdir/build/xclipshow $pkgdir/usr/bin/ +} +md5sums=('e445f888db036c7a1dfc7d33294c84f9' + '947756f823b5c82ad3626f46e38c549e') diff --git a/xclipshow/printscreen b/xclipshow/printscreen new file mode 100644 index 0000000..b25e973 --- /dev/null +++ b/xclipshow/printscreen @@ -0,0 +1,25 @@ +####################################################################### +## SHORTCUT COMMAND 1 - TAKE A SCREENSHOT +## USE AS A GLOBAL SHORTCUT COMMAND FOR 'PRINT SCREEN' KEY IN PLASMA 5 + +##Take a screenshot: Save an image to clipboard, DO NOT save in a file (can't be used with Kolourpaint, clipboard use only) + +import -window root -screen png:- | loliclip -bi image/png + +##Take a screenshot: Save an image to clipboard and as a temporary file (can be used with Kolourpaint) + +import -window root -screen /tmp/screen.png | loliclip -bi image/png < /tmp/screen.png && notify-send Screenshot -i image-x-krita 'Screenshot saved to clipboard' + +####################################################################### +## SHORTCUT COMMAND 2 - PASTE THE SCREENSHOT +## USE AS A GLOBAL SHORTCUT COMMAND FOR ALT+V KEY COMBINATION IN PLASMA 5 + +##Paste the screenshot into a new Kolourpaint session. Put this as a custom global shortcut Alt+V + +bash -c "if [[ $(xclipshow |grep -c image/png) -eq 1 ]]; then kolourpaint /tmp/screen.png; fi" + + +####################################################################### + +## You can find Plasma 5 shortcut settings in System Settings -> Shortcuts -> Custom Shortcuts +## Add the above commands as New Global Shortcuts, Command/URL diff --git a/xclipshow/xclipshow.cpp b/xclipshow/xclipshow.cpp new file mode 100644 index 0000000..4471b5b --- /dev/null +++ b/xclipshow/xclipshow.cpp @@ -0,0 +1,46 @@ +#include +#include +#include +#include +#include +#include + +class App: public QObject { + Q_OBJECT +private: + void main(); +public: + App(): QObject() { } +public slots: + void qtmain() { main(); emit finished(); } +signals: + void finished(); +}; + +void App::main() { + QClipboard *clip = QApplication::clipboard(); + + for(QString& formatName: clip->mimeData()->formats()) { + std::string s; + s = formatName.toStdString(); + + QByteArray arr = clip->mimeData()->data(formatName); + printf("name=%s, size=%d: ", s.c_str(), arr.size()); + + for(int i = 0; i < arr.size(); i++) { + printf("%02x ", (unsigned char) arr.at(i)); + } + + printf("\n"); + } +} + +int main(int argc, char **argv) { + QApplication app(argc, argv); + App *task = new App(); + QObject::connect(task, SIGNAL(finished()), & app, SLOT(quit())); + QTimer::singleShot(0, task, SLOT(qtmain())); + return app.exec(); +} + +#include "xclipshow.moc" \ No newline at end of file