From f826eab25b8058b8168cd52cdbfeed9d7a223d9c Mon Sep 17 00:00:00 2001 From: simoniz0r Date: Sat, 21 Apr 2018 13:47:23 -0500 Subject: [PATCH] Change tray icon to use same icon as rest of app --- yadshot.sh | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/yadshot.sh b/yadshot.sh index 134cd68..49ecfd2 100755 --- a/yadshot.sh +++ b/yadshot.sh @@ -8,6 +8,11 @@ # export running directory variables for use later export YADSHOT_PATH="$(readlink -f $0)" export RUNNING_DIR="$(dirname $(readlink -f $0))" +if [ -f "/usr/share/icons/hicolor/64x64/apps/yadshot.png" ]; then + export ICON_PATH="/usr/share/icons/hicolor/64x64/apps/yadshot.png" +else + export ICON_PATH="gtk-fullscreen" +fi # check for dependencies if ! type curl >/dev/null 2>&1; then MISSING_DEPS="TRUE" @@ -82,7 +87,7 @@ function yadshot_capture() { export -f yadshot_capture # function for launching color picker from tray function yadshotcolor() { - COLOR_SELECTION="$(yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --title="yadshot" --color)" + COLOR_SELECTION="$(yad --window-icon="$ICON_PATH" --center --title="yadshot" --color)" case $? in 0) echo -n "$COLOR_SELECTION" | xclip -i -selection clipboard @@ -96,19 +101,19 @@ function yadshotcolor() { export -f yadshotcolor # function to view upload list from tray function upload_list() { - LIST_ITEM="$(yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --list --height 600 --width 800 --title="yadshot" --separator="" --column="Uploads" --button=gtk-close:2 --button="Delete list"\!gtk-delete:1 --button=gtk-copy:0 --rest="$HOME/.teknik")" + LIST_ITEM="$(yad --window-icon="$ICON_PATH" --center --list --height 600 --width 800 --title="yadshot" --separator="" --column="Uploads" --button=gtk-close:2 --button="Delete list"\!gtk-delete:1 --button=gtk-copy:0 --rest="$HOME/.teknik")" case $? in 2) sleep 0 ;; 1) - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --info --title="yadshot" --button=gtk-ok --text="~/.teknik has been removed!" + yad --window-icon="$ICON_PATH" --center --info --title="yadshot" --button=gtk-ok --text="~/.teknik has been removed!" rm -f ~/.teknik ;; 0) echo -n "$LIST_ITEM" | xclip -selection primary echo -n "$LIST_ITEM" | xclip -selection clipboard - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --info --title="yadshot" --button=gtk-ok --text="$LIST_ITEM has been copied to clipboard." + yad --window-icon="$ICON_PATH" --center --info --title="yadshot" --button=gtk-ok --text="$LIST_ITEM has been copied to clipboard." ;; esac } @@ -122,7 +127,7 @@ function yadshottray() { mkfifo $PIPE # attach a file descriptor to the file exec 3<> $PIPE - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --notification --listen --image="gtk-fullscreen" --text="yadshot" --command="bash -c on_click" --item-separator="," \ + yad --window-icon="$ICON_PATH" --notification --listen --image="$ICON_PATH" --text="yadshot" --command="bash -c on_click" --item-separator="," \ --menu="New Screenshot,bash -c yadshot_capture,gtk-new|Upload File,bash -c teknik_file,gtk-go-up|Upload Paste,bash -c teknik_paste,gtk-copy|Color Picker,bash -c yadshotcolor,gtk-color-picker|View Upload List,bash -c upload_list,gtk-edit" <&3 } export -f yadshottray @@ -136,7 +141,7 @@ export -f yadshotsavesettings # change yadshot's settings function yadshotsettings() { . ~/.config/yadshot/yadshot.conf - OUTPUT="$(yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --title="yadshot" --height=200 --columns=1 --form --no-escape --separator="," --borders="10" \ + OUTPUT="$(yad --window-icon="$ICON_PATH" --center --title="yadshot" --height=200 --columns=1 --form --no-escape --separator="," --borders="10" \ --field="Capture selection":CHK "$SELECTION" --field="Capture decorations":CHK "$DECORATIONS" \ --field="Delay before capture":NUM "$SS_DELAY!0..120" --button="gtk-ok")" SELECTION="$(echo $OUTPUT | cut -f1 -d",")" @@ -160,20 +165,20 @@ function yadshotupload() { echo -n "$FILE_URL" | xclip -selection primary echo -n "$FILE_URL" | xclip -selection clipboard echo "$FILE_URL" >> ~/.teknik - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --height=150 --borders=10 --info --selectable-labels --title="yadshot" --button=gtk-ok --text="$FILE_URL" + yad --window-icon="$ICON_PATH" --center --height=150 --borders=10 --info --selectable-labels --title="yadshot" --button=gtk-ok --text="$FILE_URL" fi else FILE_URL=$(curl -s -F file="@$1" "https://api.teknik.io/v1/Upload") echo "$FILE_URL" if [[ ! "$FILE_URL" =~ "http" ]]; then echo 'error uploading file!\n' - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --error --title="yadshot" --text="Failed to upload $1" + yad --window-icon="$ICON_PATH" --center --error --title="yadshot" --text="Failed to upload $1" else FILE_URL="$(echo $FILE_URL | cut -f6 -d'"')" echo -n "$FILE_URL" | xclip -selection primary echo -n "$FILE_URL" | xclip -selection clipboard echo "$FILE_URL" >> ~/.teknik - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --height=150 --borders=10 --info --selectable-labels --title="yadshot" --button=gtk-ok --text="$FILE_URL" + yad --window-icon="$ICON_PATH" --center --height=150 --borders=10 --info --selectable-labels --title="yadshot" --button=gtk-ok --text="$FILE_URL" fi fi } @@ -223,7 +228,7 @@ function displayss() { convert -resize 50% /tmp/"$SS_NAME"_ORIGINAL /tmp/"$SS_NAME" fi fi - OUTPUT="$(yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --form --always-print-result --no-escape --image="/tmp/$SS_NAME" --image-on-top --buttons-layout="edge" --title="yadshot" --separator="," --borders="10" --columns="4" --field="Capture selection":CHK "$SELECTION" --field="Capture decorations":CHK "$DECORATIONS" --field="Delay before capture":NUM "$SS_DELAY!0..120" --field="!gtk-color-picker!Color Picker":FBTN "yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --color --center --title=yadshot" --button="Close"\!gtk-close:1 --button="Main Menu"\!gtk-home:2 --button="Copy to Clipboard"\!gtk-paste:3 --button="Upload to Teknik"\!gtk-go-up:4 --button=gtk-save:5 --button="New Screenshot"\!gtk-new:0)" + OUTPUT="$(yad --window-icon="$ICON_PATH" --center --form --always-print-result --no-escape --image="/tmp/$SS_NAME" --image-on-top --buttons-layout="edge" --title="yadshot" --separator="," --borders="10" --columns="4" --field="Capture selection":CHK "$SELECTION" --field="Capture decorations":CHK "$DECORATIONS" --field="Delay before capture":NUM "$SS_DELAY!0..120" --field="!gtk-color-picker!Color Picker":FBTN "yad --window-icon="$ICON_PATH" --color --center --title=yadshot" --button="Close"\!gtk-close:1 --button="Main Menu"\!gtk-home:2 --button="Copy to Clipboard"\!gtk-paste:3 --button="Upload to Teknik"\!gtk-go-up:4 --button=gtk-save:5 --button="New Screenshot"\!gtk-new:0)" BUTTON_PRESSED="$?" if [ -f /tmp/"$SS_NAME"_ORIGINAL ]; then rm -f /tmp/"$SS_NAME" @@ -270,7 +275,7 @@ function buttonpressed() { displayss ;; 1) - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --error --title="yadshot" --text="$SS_NAME upload failed; screenshot stored in $HOME/Pictures/$SS_NAME" + yad --window-icon="$ICON_PATH" --center --error --title="yadshot" --text="$SS_NAME upload failed; screenshot stored in $HOME/Pictures/$SS_NAME" displayss ;; esac @@ -280,7 +285,7 @@ function buttonpressed() { DECORATIONS="$(echo $OUTPUT | cut -f2 -d",")" SS_DELAY="$(echo $OUTPUT | cut -f3 -d",")" yadshotsavesettings - SAVE_DIR=$(yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --file --save --confirm-overwrite --title="yadshot" --width=800 --height=600 --text="Save $SS_NAME as...") + SAVE_DIR=$(yad --window-icon="$ICON_PATH" --center --file --save --confirm-overwrite --title="yadshot" --width=800 --height=600 --text="Save $SS_NAME as...") cp /tmp/"$SS_NAME" "$SAVE_DIR" displayss ;; @@ -297,7 +302,7 @@ function buttonpressed() { } # upload paste from clipboard to paste.rs with optional syntax function yadshotpaste() { - PASTE_CONTENT="$(yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --title="yadshot" --height=600 --width=800 --form --separator="" --borders="10" --button="Ok"\!gtk-ok --button="Cancel"\!gtk-cancel:1 \ + PASTE_CONTENT="$(yad --window-icon="$ICON_PATH" --center --title="yadshot" --height=600 --width=800 --form --separator="" --borders="10" --button="Ok"\!gtk-ok --button="Cancel"\!gtk-cancel:1 \ --field="Paste":TXT "$(xclip -o -selection clipboard)")" case $? in 0) @@ -313,18 +318,18 @@ function yadshotpaste() { PASTE_URL="$(curl -s --data-binary @/tmp/yadshotpaste.txt https://paste.rs/ | head -n 1)$PASTE_SYNTAX" rm -f /tmp/yadshotpaste.txt if [[ ! "$PASTE_URL" =~ "http" ]]; then - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --height=150 --borders=10 --info --title="yadshot" --button=gtk-ok --text="Failed to upload paste!" + yad --window-icon="$ICON_PATH" --center --height=150 --borders=10 --info --title="yadshot" --button=gtk-ok --text="Failed to upload paste!" exit 1 else echo -n "$PASTE_URL" | xclip -i -selection primary echo -n "$PASTE_URL" | xclip -i -selection clipboard echo "$PASTE_URL" >> ~/.teknik - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --height=150 --borders=10 --info --selectable-labels --title="yadshot" --button=gtk-ok --text="$PASTE_URL" + yad --window-icon="$ICON_PATH" --center --height=150 --borders=10 --info --selectable-labels --title="yadshot" --button=gtk-ok --text="$PASTE_URL" fi } # main yadshot window with screenshot options and dropdown menu function startfunc() { - yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --center --title="yadshot" --height=200 --width=325 --form --no-escape --separator="" --button-layout="center" \ + yad --window-icon="$ICON_PATH" --center --title="yadshot" --height=200 --width=325 --form --no-escape --separator="" --button-layout="center" \ --borders="20" --columns="1" --button="New Screenshot"\!gtk-add:0 --button="Close"\!gtk-cancel:1 \ --field="Upload File!gtk-go-up":FBTN "$YADSHOT_PATH -f" --field="Upload Paste!gtk-copy":FBTN "$YADSHOT_PATH -p" \ --field="Color Picker!gtk-color-picker":FBTN "$YADSHOT_PATH -C" --field="View Upload List!gtk-edit":FBTN "bash -c upload_list" \ @@ -343,7 +348,7 @@ function startfunc() { } # help function function yadshothelp() { -printf '%s\n' "yadshot v0.1.99 +printf '%s\n' "yadshot v0.1.99.1 yadshot provides a GUI frontend for taking screenshots with ImageMagick/slop. yadshot can upload screenshots and files to teknik.io, and it can also upload pastes to paste.rs @@ -408,7 +413,7 @@ case $1 in fi ;; -f|--file) - FILE="$(yad --window-icon="/usr/share/icons/hicolor/64x64/apps/yadshot.png" --file $PWD --center --title=yadshot --height 600 --width 800)" + FILE="$(yad --window-icon="$ICON_PATH" --file $PWD --center --title=yadshot --height 600 --width 800)" case $? in 0) yadshotupload "$FILE"