Take and download screenshots in one click using the Compiz plugin on habreffect.ru and Dropbox

Published on November 14, 2010

Take and download screenshots in one click using the Compiz plugin on habreffect.ru and Dropbox

    imageimage

    Sitting at home on a quiet Sunday evening, I suddenly realized that I really didn’t really need to quickly take and load screenshots on Linux. There are a lot of ready-made solutions, but all of them for one reason or another did not suit me, as a rule, all ready-made solutions required too many clicks. I took the file in my hands and spent 30 minutes of my time I could make a really convenient way to upload screenshots to habreffect.ru

    To upload to habreffect.ru we need:

    - Installed compiz, compizconfig-settings-manager and compiz-plugins
    - Installed curl, xsel packages , libnotify-bin
    - Straight arms

    For lazy ubuntovodov
    sudo apt-get install compiz compizconfig-settings-manager compiz-plugins curl xsel libnotify-bin

    To upload to Dropbox we need:

    - Installed xsel and libnotify-bin, compiz compizconfigconfig-settings-manager compiz-plugins

    For lazy ubunto drivers All of the above packages are in turnips.
    sudo apt-get install xsel libnotify-bin compiz compizconfigconfig-settings-manager compiz-plugins




    As a basis, I took a script from the angel2s2 habrayuzer for which he was honored, praise and pluses in karma.
    The source script can be found here .

    1. Create a shell script with any name, and in any directory.
    For the purposes of this manual, it will be habreffect.sh and located in the directory /home/vitali/.bin

    Copy the following contents there.



    #!/bin/bash

    trap "_exit" INT KILL TERM QUIT
    _exit() {
    rm -f $SCREEN_FILE
    exit
    }

    LOG_FILE='/var/log/screenshots.log'
    SCREEN_FILE='/tmp/screenshot1.png'

    LOG_STR=$( curl -s -F "upload=yes" -F "file=@$SCREEN_FILE" -L habreffect.ru/upload.php |\
    sed -ne '/Прямая\ ссылка\|delete:/s/^.*\(http.\+\)".*$/\1/gp' | tr '\n' ' ' |\
    sed -e "s/'\ $/\ \]\n/;s/[\ \t]/\t\[del: /;s/^/$(date '+%d.%m.%Y %H:%M')\t/" |\
    tee -ai $LOG_FILE | awk '{print $3}' )
    [ $? -ne 0 ] && FINISH="[ FAIL ]"

    echo $LOG_STR | xsel -b -i

    notify-send -t 5000 -i dialog-information "Скриншот загружен"

    _exit





    For Dropbox

    #!/bin/sh

    DPDIR=~/Dropbox/Public
    ID=СВОЙID

    if [ -e "$1" ]
    then
    cp -f "$1" "$DPDIR"
    file=`basename "$1"`
    link="http://dl.getdropbox.com/u/$ID/$file"
    notify-send -i go-down "Dropbox" "Ссылка на скопирована в буфер обмена"
    echo "$link" | xsel -b -i
    else
    notify-send -i dialog-information "Dropbox" "Выберите файл!"
    fi





    We make the script executable. chmod +x /home/vitali/.bin/dropbox.sh

    If you use the script for Dropbox, go to step 3.

    Briefly, this script takes a file called /tmp/screenshot1.png (about it a bit later), downloads it using curl to habreffect.ru, copies the resulting link from using xsel and displays a notification using libnotify-bin, cleans up and leaves a date, a link to a screenshot and a link to delete it in the /var/log/screenshot.log

    2 log . Before use, you need to create the file / var / log / screenshots.log and give it write permissions.

    sudo touch /var/log/screenshots.log && sudo chmod 666 /var/log/screenshots.log

    The shell script itself must be given execution rights.

    chmod +x /home/vitali/.bin/habreffect.sh
    The way I hope you guess your substitute.

    3. We pass directly to the plug-in from Compiz. Further, I assume that you already have a Screenshot plugin since it should have come with the compiz-plugins package.

    • Launch Compiz Settings Manager either through the menu, or by pressing ALT + F2 -> ccsm.
    • We look in the Screenshot list, turn it on and open it.
    • In the Directory column, write / tmp, in the Launch application column, the path to our skip.
    After our manipulations, it should look something like this.

    image

    Done! Now all we need to do is hold down the hotkey you have set (By default, Super + Left click) and draw a stroke of the area we want to take a screenshot of.

    Unfortunately, I found one drawback with this method, when highlighting a full screen, the screenshot has a blue selection background. I did not find a solution to this issue. this is a compiz plugin problem.
    Alternatively, you can use the original script from angel2s2 , it takes a full screenshot of the desktop.

    Another drawback of the script is that it will take a screenshot only with the name screenshot1.png, this is again a limitation of the plugin and I can not do anything about it. This does not concern the end user until he has other files with the name screenshot1.png in his folder, the script cleans up each time, so you should not worry about it. The script for Dropbox does not suffer from such a flaw.

    Any comments and corrections are welcome.

    For mortals without Compiz.
    The author of the script for Dropbox is oWeRQ.

    The script was updated due to the update of the image loading process habreffect.ru