Browse Source

Add xclipshow & print screen commands

master
Fincer 7 years ago
parent
commit
73f96c56e3
5 changed files with 127 additions and 0 deletions
  1. +15
    -0
      Readme.md
  2. +12
    -0
      xclipshow/CMakeLists.txt
  3. +29
    -0
      xclipshow/PKGBUILD
  4. +25
    -0
      xclipshow/printscreen
  5. +46
    -0
      xclipshow/xclipshow.cpp

+ 15
- 0
Readme.md View File

@ -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**
--------------


+ 12
- 0
xclipshow/CMakeLists.txt View File

@ -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)

+ 29
- 0
xclipshow/PKGBUILD View File

@ -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')

+ 25
- 0
xclipshow/printscreen View File

@ -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

+ 46
- 0
xclipshow/xclipshow.cpp View File

@ -0,0 +1,46 @@
#include <QApplication>
#include <QTimer>
#include <QClipboard>
#include <QMimeData>
#include <QDebug>
#include <QStringList>
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"

Loading…
Cancel
Save