Skip to content

Instantly share code, notes, and snippets.

@pnlinh
Forked from populov/jing.sh
Created November 22, 2024 11:29
Show Gist options
  • Select an option

  • Save pnlinh/8eb1105da2416e8cac36faaf1ee4d30c to your computer and use it in GitHub Desktop.

Select an option

Save pnlinh/8eb1105da2416e8cac36faaf1ee4d30c to your computer and use it in GitHub Desktop.

Revisions

  1. @populov populov revised this gist Sep 28, 2022. 1 changed file with 11 additions and 13 deletions.
    24 changes: 11 additions & 13 deletions jing.sh
    Original file line number Diff line number Diff line change
    @@ -9,37 +9,35 @@
    ## Install prerequisites (Ubuntu):
    # sudo apt-get install flameshot openssh-client notify-send xclip
    #
    # Upload your ssh key to SSH/SFTP server (should ask for password):
    # ssh-copy-id -i ~/.ssh/id_rsa.pub -p $PORT [email protected]
    #
    # Uncomment last line to delete screenshot file after upload

    PORT=2221
    USER="UserName"
    SFTPSERVER="sftp.server.com"
    USER="SergeyPopulov"
    SFTPSERVER="jing.saritasa.com"
    STORAGE=~/Pictures/Screenshots
    PASSWORD=oh-noooooooo
    #STORAGE=/tmp

    RND=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-8} | head -n 1)
    DATE=$(date +%Y-%m-%d_%H-%M)
    FILE=$DATE"_"$RND".png"

    flameshot gui -r > $STORAGE/$FILE
    if [ $? -ne 0 ]; then
    cat $STORAGE/$FILE
    flameshot gui --raw > $STORAGE/$FILE
    if [[ ! -s $STORAGE/$FILE ]]; then
    rm $STORAGE/$FILE
    exit 0
    fi

    echo "$FILE created!"
    scp -i ~/.ssh/id_rsa -o PasswordAuthentication=no -P $PORT $STORAGE/$FILE ${USER}@${SFTPSERVER}:/
    scp -i ~/.ssh/interesnee -P $PORT -o PasswordAuthentication=no -o PubkeyAcceptedKeyTypes=+ssh-rsa $STORAGE/$FILE ${USER}@${SFTPSERVER}:/
    #sshpass -p $PASSWORD scp -vvv -P $PORT -o PasswordAuthentication=yes $STORAGE/$FILE ${USER}@${SFTPSERVER}:/

    if [ $? -ne 0 ]; then
    notify-send --icon terminal --category 'transfer.error' "Screenshot upload error" "Could not upload $FILE to $SFTPSERVER"
    else
    URL="https://${SFTPSERVER}/${USER}/${FILE}"
    echo $URL | xclip -selection clipboard
    notify-send --icon flameshot --category 'transfer.complete' --expire-time 10 "Screenshot uploaded" "$URL copied to clipboard"
    fi

    URL="https://${SFTPSERVER}/${USER}/${FILE}"
    echo $URL | xclip -selection clipboard
    notify-send --icon flameshot --category 'transfer.complete' --expire-time 10 "Screenshot uploaded" "$URL copied to clipboard"

    # rm $STORAGE/$FILE
  2. @populov populov revised this gist Apr 16, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jing.sh
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    # sudo apt-get install flameshot openssh-client notify-send xclip
    #
    # Upload your ssh key to SSH/SFTP server (should ask for password):
    # ssh-copy-id -i ~/.ssh/id_rsa -p $PORT [email protected]
    # ssh-copy-id -i ~/.ssh/id_rsa.pub -p $PORT [email protected]
    #
    # Uncomment last line to delete screenshot file after upload

  3. @populov populov revised this gist Apr 16, 2021. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions jing.sh
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,9 @@
    ## Install prerequisites (Ubuntu):
    # sudo apt-get install flameshot openssh-client notify-send xclip
    #
    # Upload your ssh key to SSH/SFTP server (should ask for password):
    # ssh-copy-id -i ~/.ssh/id_rsa -p $PORT [email protected]
    #
    # Uncomment last line to delete screenshot file after upload

    PORT=2221
  4. @populov populov revised this gist Apr 16, 2021. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion jing.sh
    Original file line number Diff line number Diff line change
    @@ -29,7 +29,11 @@ if [ $? -ne 0 ]; then
    fi

    echo "$FILE created!"
    scp -i ~/.ssh/id_rsa -o IdentitiesOnly=yes -P $PORT $STORAGE/$FILE ${USER}@${SFTPSERVER}:/
    scp -i ~/.ssh/id_rsa -o PasswordAuthentication=no -P $PORT $STORAGE/$FILE ${USER}@${SFTPSERVER}:/

    if [ $? -ne 0 ]; then
    notify-send --icon terminal --category 'transfer.error' "Screenshot upload error" "Could not upload $FILE to $SFTPSERVER"
    fi

    URL="https://${SFTPSERVER}/${USER}/${FILE}"
    echo $URL | xclip -selection clipboard
  5. @populov populov revised this gist Apr 16, 2021. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions jing.sh
    Original file line number Diff line number Diff line change
    @@ -12,9 +12,9 @@
    # Uncomment last line to delete screenshot file after upload

    PORT=2221
    JINGUSER="SergeyPopulov"
    JINGDOMAIN="jing.saritasa.com"
    STORAGE=/home/populov/Pictures/Screenshots
    USER="UserName"
    SFTPSERVER="sftp.server.com"
    STORAGE=~/Pictures/Screenshots
    #STORAGE=/tmp

    RND=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-8} | head -n 1)
    @@ -29,9 +29,9 @@ if [ $? -ne 0 ]; then
    fi

    echo "$FILE created!"
    scp -i ~/.ssh/id_rsa -o IdentitiesOnly=yes -P $PORT $STORAGE/$FILE $JINGUSER@$JINGDOMAIN:/
    scp -i ~/.ssh/id_rsa -o IdentitiesOnly=yes -P $PORT $STORAGE/$FILE ${USER}@${SFTPSERVER}:/

    URL="https://${JINGDOMAIN}/${JINGUSER}/${FILE}"
    URL="https://${SFTPSERVER}/${USER}/${FILE}"
    echo $URL | xclip -selection clipboard
    notify-send --icon flameshot --category 'transfer.complete' --expire-time 10 "Screenshot uploaded" "$URL copied to clipboard"

  6. @populov populov revised this gist Apr 14, 2021. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions jing.sh
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,13 @@
    #!/bin/bash

    # Prerequisites:
    # * flameshost: https://flameshot.org
    # * scp (OpenSSH file copy client)
    # * flameshost (Take screenshot + basic edit): https://flameshot.org
    # * scp (OpenSSH/SFTP file copy client) https://www.mankier.com/1/scp
    # * notify-send (Desktop notifications) https://ss64.com/bash/notify-send.html
    # * xclip (copy to clipboard) https://opensource.com/article/19/7/xclip
    #
    ## Install prerequisites:
    # sudo apt-get install flameshot scp notify-send xclip
    ## Install prerequisites (Ubuntu):
    # sudo apt-get install flameshot openssh-client notify-send xclip
    #
    # Uncomment last line to delete screenshot file after upload

  7. @populov populov created this gist Apr 14, 2021.
    38 changes: 38 additions & 0 deletions jing.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #!/bin/bash

    # Prerequisites:
    # * flameshost: https://flameshot.org
    # * scp (OpenSSH file copy client)
    # * notify-send (Desktop notifications) https://ss64.com/bash/notify-send.html
    # * xclip (copy to clipboard) https://opensource.com/article/19/7/xclip
    #
    ## Install prerequisites:
    # sudo apt-get install flameshot scp notify-send xclip
    #
    # Uncomment last line to delete screenshot file after upload

    PORT=2221
    JINGUSER="SergeyPopulov"
    JINGDOMAIN="jing.saritasa.com"
    STORAGE=/home/populov/Pictures/Screenshots
    #STORAGE=/tmp

    RND=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-8} | head -n 1)
    DATE=$(date +%Y-%m-%d_%H-%M)
    FILE=$DATE"_"$RND".png"

    flameshot gui -r > $STORAGE/$FILE
    if [ $? -ne 0 ]; then
    cat $STORAGE/$FILE
    rm $STORAGE/$FILE
    exit 0
    fi

    echo "$FILE created!"
    scp -i ~/.ssh/id_rsa -o IdentitiesOnly=yes -P $PORT $STORAGE/$FILE $JINGUSER@$JINGDOMAIN:/

    URL="https://${JINGDOMAIN}/${JINGUSER}/${FILE}"
    echo $URL | xclip -selection clipboard
    notify-send --icon flameshot --category 'transfer.complete' --expire-time 10 "Screenshot uploaded" "$URL copied to clipboard"

    # rm $STORAGE/$FILE