wok rev 19523

Add yandex-disk (with custom desktop integration)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sun Nov 27 18:29:04 2016 +0200 (2016-11-27)
parents f2fe8c08dc89
children fcec81f66f99
files yandex-disk/description.txt yandex-disk/receipt yandex-disk/stuff/po/Makefile yandex-disk/stuff/po/ru.po yandex-disk/stuff/po/uk.po yandex-disk/stuff/po/yandex-disk-helper.pot yandex-disk/stuff/usr/bin/yandex-disk-helper yandex-disk/stuff/usr/libexec/yandex-disk/publish yandex-disk/stuff/usr/libexec/yandex-disk/status yandex-disk/stuff/usr/libexec/yandex-disk/test yandex-disk/stuff/usr/libexec/yandex-disk/unpublish yandex-disk/stuff/usr/share/applications/yandex-disk.desktop yandex-disk/stuff/usr/share/file-manager/actions/yd-publish.desktop yandex-disk/stuff/usr/share/file-manager/actions/yd-unpublish.desktop yandex-disk/stuff/usr/share/icons/hicolor/16x16/apps/yandex-disk.png yandex-disk/stuff/usr/share/icons/hicolor/48x48/apps/yandex-disk.png
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/yandex-disk/description.txt	Sun Nov 27 18:29:04 2016 +0200
     1.3 @@ -0,0 +1,8 @@
     1.4 +You can access photos, videos, and documents on Disk from anywhere in the world
     1.5 +where there's internet.
     1.6 +
     1.7 +The Yandex.Disk client console lets you:
     1.8 +
     1.9 +  * synchronize files and folders with your Disk
    1.10 +  * get public links to files and folders
    1.11 +  * customize folder syncing
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/yandex-disk/receipt	Sun Nov 27 18:29:04 2016 +0200
     2.3 @@ -0,0 +1,59 @@
     2.4 +# SliTaz package receipt.
     2.5 +
     2.6 +PACKAGE="yandex-disk"
     2.7 +VERSION="0.1.5.978"
     2.8 +CATEGORY="misc"
     2.9 +SHORT_DESC="Yandex.Disk keeps your files with you at all times"
    2.10 +MAINTAINER="al.bobylev@gmail.com"
    2.11 +LICENSE="custom"
    2.12 +WEB_SITE="https://disk.yandex.ru/"
    2.13 +#TARBALL="$PACKAGE-$VERSION.deb"
    2.14 +COOKOPTS="!extradesktops"
    2.15 +
    2.16 +DEPENDS="gcc-lib-base glibc-base zlib"
    2.17 +
    2.18 +# Rules to configure and make the package.
    2.19 +compile_rules()
    2.20 +{
    2.21 +	# Get current (and the one) version
    2.22 +	repo='http://repo.yandex.ru/yandex-disk/deb/pool/main/y/yandex-disk/'
    2.23 +	url=$(wget -q -T10 -O- $repo | fgrep i386 | cut -d'"' -f2)
    2.24 +	# for example, url='yandex-disk_0.1.5.978_i386.deb'
    2.25 +
    2.26 +	version=$(echo $url | cut -d'_' -f2)
    2.27 +	# for example, version='0.1.5.978'
    2.28 +	[ -n "$version" ] || exit 1
    2.29 +
    2.30 +	# Hot changing VERSION in this receipt
    2.31 +	sed -i "/^VERSION=/s/.*$/VERSION=\"$version\"/" $WOK/$PACKAGE/receipt
    2.32 +
    2.33 +	TARBALL="$PACKAGE-$version.deb"
    2.34 +
    2.35 +	# Get current package
    2.36 +	[ -s $SRC/$TARBALL ] || wget -O $SRC/$TARBALL "$repo$url"
    2.37 +
    2.38 +	# Extract filesystem from package
    2.39 +	mkdir -p $install
    2.40 +	dpkg-deb -x $SRC/$TARBALL $install
    2.41 +
    2.42 +	# Add SliTaz desktop integration
    2.43 +	cp -a $stuff/usr $install
    2.44 +
    2.45 +	# Add translations for desktop integration
    2.46 +	cd $stuff/po
    2.47 +	make DESTDIR=$install install
    2.48 +	make clean
    2.49 +}
    2.50 +
    2.51 +# Rules to gen a SliTaz package suitable for Tazpkg.
    2.52 +genpkg_rules()
    2.53 +{
    2.54 +	cook_copy_files yandex-disk copyright *.mo \
    2.55 +		publish unpublish test status *.desktop yandex-disk-helper
    2.56 +	cook_copy_icons
    2.57 +}
    2.58 +
    2.59 +pre_remove()
    2.60 +{
    2.61 +	killall -q yandex-disk
    2.62 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/yandex-disk/stuff/po/Makefile	Sun Nov 27 18:29:04 2016 +0200
     3.3 @@ -0,0 +1,37 @@
     3.4 +# Makefile for yandex-disk-helper
     3.5 +#
     3.6 +LINGUAS = ru uk
     3.7 +
     3.8 +pot:
     3.9 +	xgettext -o yandex-disk-helper.pot -L Shell -k -k_ \
    3.10 +		--package-name="Yandex.Disk helper" \
    3.11 +		../usr/bin/yandex-disk-helper \
    3.12 +		../usr/libexec/yandex-disk/publish \
    3.13 +		../usr/libexec/yandex-disk/status \
    3.14 +		../usr/libexec/yandex-disk/unpublish
    3.15 +
    3.16 +msgmerge:
    3.17 +	@for l in $(LINGUAS); do \
    3.18 +		if [ -f "$$l.po" ]; then \
    3.19 +			echo "Updating $$l po file."; \
    3.20 +			msgmerge -U $$l.po $$p.pot; \
    3.21 +		fi; \
    3.22 +	done;
    3.23 +
    3.24 +msgfmt:
    3.25 +	@for l in $(LINGUAS); do \
    3.26 +		if [ -f "$$l.po" ]; then \
    3.27 +			echo -e "Compiling $$l mo file...\n"; \
    3.28 +			mkdir -p mo/$$l/LC_MESSAGES; \
    3.29 +			msgfmt -o mo/$$l/LC_MESSAGES/yandex-disk-helper.mo $$l.po; \
    3.30 +		fi; \
    3.31 +	done;
    3.32 +
    3.33 +install: msgfmt
    3.34 +	mkdir -p   $(DESTDIR)/usr/share/locale
    3.35 +	cp -a mo/* $(DESTDIR)/usr/share/locale
    3.36 +
    3.37 +clean:
    3.38 +	rm -rf  mo
    3.39 +	rm -f *.mo
    3.40 +	rm -f *.*~
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/yandex-disk/stuff/po/ru.po	Sun Nov 27 18:29:04 2016 +0200
     4.3 @@ -0,0 +1,84 @@
     4.4 +# Russian translations for Yandex.Disk helper
     4.5 +# Copyright (C) 2016 Yandex
     4.6 +# This file is distributed under the same license as the Yandex.Disk helper package.
     4.7 +# Aleksej Bobylev <al.bobylev@gmail.com>, 2016.
     4.8 +#
     4.9 +msgid ""
    4.10 +msgstr ""
    4.11 +"Project-Id-Version: Yandex.Disk helper\n"
    4.12 +"Report-Msgid-Bugs-To: \n"
    4.13 +"POT-Creation-Date: 2016-11-27 17:09+0200\n"
    4.14 +"PO-Revision-Date: 2016-11-27 17:18+0200\n"
    4.15 +"Language: ru\n"
    4.16 +"MIME-Version: 1.0\n"
    4.17 +"Content-Type: text/plain; charset=UTF-8\n"
    4.18 +"Content-Transfer-Encoding: 8bit\n"
    4.19 +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
    4.20 +"Last-Translator: Aleksej Bobylev <al.bobylev@gmail.com>\n"
    4.21 +"Language-Team: \n"
    4.22 +"X-Generator: Poedit 1.8.6\n"
    4.23 +"X-Poedit-SourceCharset: UTF-8\n"
    4.24 +"X-Poedit-KeywordsList: _\n"
    4.25 +
    4.26 +#: ../usr/bin/yandex-disk-helper:21 ../usr/libexec/yandex-disk/publish:11
    4.27 +#: ../usr/libexec/yandex-disk/status:8 ../usr/libexec/yandex-disk/unpublish:8
    4.28 +msgid "Yandex.Disk"
    4.29 +msgstr "Яндекс.Диск"
    4.30 +
    4.31 +#: ../usr/bin/yandex-disk-helper:82
    4.32 +msgid "GB"
    4.33 +msgstr "ГБ"
    4.34 +
    4.35 +#: ../usr/bin/yandex-disk-helper:82
    4.36 +msgid "MB"
    4.37 +msgstr "МБ"
    4.38 +
    4.39 +#: ../usr/bin/yandex-disk-helper:119
    4.40 +msgid "Reconfigure"
    4.41 +msgstr "Перенастроить"
    4.42 +
    4.43 +#: ../usr/bin/yandex-disk-helper:120
    4.44 +msgid "Start"
    4.45 +msgstr "Запустить"
    4.46 +
    4.47 +#: ../usr/bin/yandex-disk-helper:121
    4.48 +msgid "Stop"
    4.49 +msgstr "Остановить"
    4.50 +
    4.51 +#: ../usr/bin/yandex-disk-helper:123
    4.52 +msgid "Open local folder"
    4.53 +msgstr "Открыть локальную папку"
    4.54 +
    4.55 +#: ../usr/bin/yandex-disk-helper:124
    4.56 +msgid "Open online folder"
    4.57 +msgstr "Открыть онлайн папку"
    4.58 +
    4.59 +#: ../usr/bin/yandex-disk-helper:135
    4.60 +msgid "Welcome to Yandex.Disk!"
    4.61 +msgstr "Добро пожаловать в Яндекс.Диск!"
    4.62 +
    4.63 +#: ../usr/bin/yandex-disk-helper:137
    4.64 +msgid "To use Yandex.Disk on this computer, you must first configure it."
    4.65 +msgstr ""
    4.66 +"Для того, чтобы использовать Яндекс.Диск на этом компьютере, его нужно "
    4.67 +"сначала настроить."
    4.68 +
    4.69 +#: ../usr/bin/yandex-disk-helper:180
    4.70 +msgid "Add folder to bookmarks"
    4.71 +msgstr "Добавить папку в закладки"
    4.72 +
    4.73 +#: ../usr/bin/yandex-disk-helper:181
    4.74 +msgid "Finish"
    4.75 +msgstr "Завершить"
    4.76 +
    4.77 +#: ../usr/libexec/yandex-disk/publish:13
    4.78 +msgid "Folder:"
    4.79 +msgstr "Папка:"
    4.80 +
    4.81 +#: ../usr/libexec/yandex-disk/publish:15
    4.82 +msgid "File:"
    4.83 +msgstr "Файл:"
    4.84 +
    4.85 +#: ../usr/libexec/yandex-disk/status:9
    4.86 +msgid "Please wait..."
    4.87 +msgstr "Пожалуйста, подождите…"
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/yandex-disk/stuff/po/uk.po	Sun Nov 27 18:29:04 2016 +0200
     5.3 @@ -0,0 +1,84 @@
     5.4 +# Ukrainian translations for Yandex.Disk helper
     5.5 +# Copyright (C) 2016 Yandex
     5.6 +# This file is distributed under the same license as the Yandex.Disk helper package.
     5.7 +# Aleksej Bobylev <al.bobylev@gmail.com>, 2016.
     5.8 +#
     5.9 +msgid ""
    5.10 +msgstr ""
    5.11 +"Project-Id-Version: Yandex.Disk helper\n"
    5.12 +"Report-Msgid-Bugs-To: \n"
    5.13 +"POT-Creation-Date: 2016-11-27 17:09+0200\n"
    5.14 +"PO-Revision-Date: 2016-11-27 18:18+0200\n"
    5.15 +"Language: uk\n"
    5.16 +"MIME-Version: 1.0\n"
    5.17 +"Content-Type: text/plain; charset=UTF-8\n"
    5.18 +"Content-Transfer-Encoding: 8bit\n"
    5.19 +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
    5.20 +"Last-Translator: Aleksej Bobylev <al.bobylev@gmail.com>\n"
    5.21 +"Language-Team: \n"
    5.22 +"X-Generator: Poedit 1.8.6\n"
    5.23 +"X-Poedit-SourceCharset: UTF-8\n"
    5.24 +"X-Poedit-KeywordsList: _\n"
    5.25 +
    5.26 +#: ../usr/bin/yandex-disk-helper:21 ../usr/libexec/yandex-disk/publish:11
    5.27 +#: ../usr/libexec/yandex-disk/status:8 ../usr/libexec/yandex-disk/unpublish:8
    5.28 +msgid "Yandex.Disk"
    5.29 +msgstr "Яндекс.Диск"
    5.30 +
    5.31 +#: ../usr/bin/yandex-disk-helper:82
    5.32 +msgid "GB"
    5.33 +msgstr "ГБ"
    5.34 +
    5.35 +#: ../usr/bin/yandex-disk-helper:82
    5.36 +msgid "MB"
    5.37 +msgstr "МБ"
    5.38 +
    5.39 +#: ../usr/bin/yandex-disk-helper:119
    5.40 +msgid "Reconfigure"
    5.41 +msgstr "Переналаштувати"
    5.42 +
    5.43 +#: ../usr/bin/yandex-disk-helper:120
    5.44 +msgid "Start"
    5.45 +msgstr "Запустити"
    5.46 +
    5.47 +#: ../usr/bin/yandex-disk-helper:121
    5.48 +msgid "Stop"
    5.49 +msgstr "Зупинити"
    5.50 +
    5.51 +#: ../usr/bin/yandex-disk-helper:123
    5.52 +msgid "Open local folder"
    5.53 +msgstr "Відкрити локальну папку"
    5.54 +
    5.55 +#: ../usr/bin/yandex-disk-helper:124
    5.56 +msgid "Open online folder"
    5.57 +msgstr "Відкрити онлайн папку"
    5.58 +
    5.59 +#: ../usr/bin/yandex-disk-helper:135
    5.60 +msgid "Welcome to Yandex.Disk!"
    5.61 +msgstr "Ласкаво просимо до Яндекс.Диску!"
    5.62 +
    5.63 +#: ../usr/bin/yandex-disk-helper:137
    5.64 +msgid "To use Yandex.Disk on this computer, you must first configure it."
    5.65 +msgstr ""
    5.66 +"Для того, щоб скористатися Яндекс.Диском на цьому комп'ютері, необхідно "
    5.67 +"спочатку його налаштувати."
    5.68 +
    5.69 +#: ../usr/bin/yandex-disk-helper:180
    5.70 +msgid "Add folder to bookmarks"
    5.71 +msgstr "Додати папку в закладки"
    5.72 +
    5.73 +#: ../usr/bin/yandex-disk-helper:181
    5.74 +msgid "Finish"
    5.75 +msgstr "Завершити"
    5.76 +
    5.77 +#: ../usr/libexec/yandex-disk/publish:13
    5.78 +msgid "Folder:"
    5.79 +msgstr "Папка:"
    5.80 +
    5.81 +#: ../usr/libexec/yandex-disk/publish:15
    5.82 +msgid "File:"
    5.83 +msgstr "Файл:"
    5.84 +
    5.85 +#: ../usr/libexec/yandex-disk/status:9
    5.86 +msgid "Please wait..."
    5.87 +msgstr "Будь ласка, зачекайте…"
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/yandex-disk/stuff/po/yandex-disk-helper.pot	Sun Nov 27 18:29:04 2016 +0200
     6.3 @@ -0,0 +1,79 @@
     6.4 +# SOME DESCRIPTIVE TITLE.
     6.5 +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
     6.6 +# This file is distributed under the same license as the PACKAGE package.
     6.7 +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
     6.8 +#
     6.9 +#, fuzzy
    6.10 +msgid ""
    6.11 +msgstr ""
    6.12 +"Project-Id-Version: Yandex.Disk helper\n"
    6.13 +"Report-Msgid-Bugs-To: \n"
    6.14 +"POT-Creation-Date: 2016-11-27 17:09+0200\n"
    6.15 +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    6.16 +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    6.17 +"Language-Team: LANGUAGE <LL@li.org>\n"
    6.18 +"Language: \n"
    6.19 +"MIME-Version: 1.0\n"
    6.20 +"Content-Type: text/plain; charset=CHARSET\n"
    6.21 +"Content-Transfer-Encoding: 8bit\n"
    6.22 +
    6.23 +#: ../usr/bin/yandex-disk-helper:21 ../usr/libexec/yandex-disk/publish:11
    6.24 +#: ../usr/libexec/yandex-disk/status:8 ../usr/libexec/yandex-disk/unpublish:8
    6.25 +msgid "Yandex.Disk"
    6.26 +msgstr ""
    6.27 +
    6.28 +#: ../usr/bin/yandex-disk-helper:82
    6.29 +msgid "GB"
    6.30 +msgstr ""
    6.31 +
    6.32 +#: ../usr/bin/yandex-disk-helper:82
    6.33 +msgid "MB"
    6.34 +msgstr ""
    6.35 +
    6.36 +#: ../usr/bin/yandex-disk-helper:119
    6.37 +msgid "Reconfigure"
    6.38 +msgstr ""
    6.39 +
    6.40 +#: ../usr/bin/yandex-disk-helper:120
    6.41 +msgid "Start"
    6.42 +msgstr ""
    6.43 +
    6.44 +#: ../usr/bin/yandex-disk-helper:121
    6.45 +msgid "Stop"
    6.46 +msgstr ""
    6.47 +
    6.48 +#: ../usr/bin/yandex-disk-helper:123
    6.49 +msgid "Open local folder"
    6.50 +msgstr ""
    6.51 +
    6.52 +#: ../usr/bin/yandex-disk-helper:124
    6.53 +msgid "Open online folder"
    6.54 +msgstr ""
    6.55 +
    6.56 +#: ../usr/bin/yandex-disk-helper:135
    6.57 +msgid "Welcome to Yandex.Disk!"
    6.58 +msgstr ""
    6.59 +
    6.60 +#: ../usr/bin/yandex-disk-helper:137
    6.61 +msgid "To use Yandex.Disk on this computer, you must first configure it."
    6.62 +msgstr ""
    6.63 +
    6.64 +#: ../usr/bin/yandex-disk-helper:180
    6.65 +msgid "Add folder to bookmarks"
    6.66 +msgstr ""
    6.67 +
    6.68 +#: ../usr/bin/yandex-disk-helper:181
    6.69 +msgid "Finish"
    6.70 +msgstr ""
    6.71 +
    6.72 +#: ../usr/libexec/yandex-disk/publish:13
    6.73 +msgid "Folder:"
    6.74 +msgstr ""
    6.75 +
    6.76 +#: ../usr/libexec/yandex-disk/publish:15
    6.77 +msgid "File:"
    6.78 +msgstr ""
    6.79 +
    6.80 +#: ../usr/libexec/yandex-disk/status:9
    6.81 +msgid "Please wait..."
    6.82 +msgstr ""
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/yandex-disk/stuff/usr/bin/yandex-disk-helper	Sun Nov 27 18:29:04 2016 +0200
     7.3 @@ -0,0 +1,210 @@
     7.4 +#!/bin/sh
     7.5 +# yandex-disk-helper - simple Yandex.Disk maintenance app
     7.6 +# Aleksei Bobylev <al.bobylev@gmail.com>, 2016
     7.7 +
     7.8 +
     7.9 +# Settings for usage statistics bar:
    7.10 +
    7.11 +barw='48'					# bar width in symbols
    7.12 +bars=' '					# bar symbol
    7.13 +barf='10'					# bar font (Pango markup)
    7.14 +baru='background="#4277CA"'	# style for 'used' part (Pango markup)
    7.15 +bart='background="#CA9342"'	# style for 'trash' part (Pango markup)
    7.16 +bara='background="#CACACA"'	# style for 'available' part (Pango markup)
    7.17 +
    7.18 +
    7.19 +# i18n
    7.20 +_() { gettext 'yandex-disk-helper' "$1"; }
    7.21 +
    7.22 +tmpid='/tmp/yandex-disk-notify.id'
    7.23 +
    7.24 +title="$(_ 'Yandex.Disk')"
    7.25 +
    7.26 +# Get untranslated status
    7.27 +statusC=$(LC_ALL=C yandex-disk status)
    7.28 +
    7.29 +
    7.30 +# Draw colored bar: used, trash, available, and print used %
    7.31 +
    7.32 +bar() {
    7.33 +	echo "$statusC" | awk -vwidth="$barw" -vsym="$bars" -vfont="$barf" \
    7.34 +	-vusedstyle="$baru" -vtrashstyle="$bart" -vavailstyle="$bara" '
    7.35 +	# Convert argument in human-readable form like "23.7 MB" into bytes
    7.36 +	function bytes() {
    7.37 +		split($0, a, ": ");
    7.38 +		split(a[2], s, " ");
    7.39 +		if (s[2] == "KB") { return (sprintf("%.0f", s[1] * 1024)); }
    7.40 +		if (s[2] == "MB") { return (sprintf("%.0f", s[1] * 1024 * 1024)); }
    7.41 +		if (s[2] == "GB") { return (sprintf("%.0f", s[1] * 1024 * 1024 * 1024)); }
    7.42 +	}
    7.43 +
    7.44 +	# Draw bar using specified symbol
    7.45 +	function bar(n) {
    7.46 +		num = 1 * sprintf("%.0f", n);
    7.47 +		out = "";
    7.48 +		if (num > 0)
    7.49 +			for (i = 1; i <= num; i++) out = out sym;
    7.50 +		return out;
    7.51 +	}
    7.52 +
    7.53 +	# Get sizes
    7.54 +	/Total:/      { total = bytes(); }
    7.55 +	/Used:/       { used  = bytes(); }
    7.56 +	/Trash size:/ { trash = bytes(); }
    7.57 +	/Available:/  { avail = bytes(); }
    7.58 +
    7.59 +	END {
    7.60 +		# If daemon stopped, we got no values, then skip
    7.61 +		if (total) {
    7.62 +			# Calculate bar parts width in symbols
    7.63 +			usedbar  = width * (used - trash) / total;
    7.64 +			trashbar = width *      trash     / total;
    7.65 +			availbar = width *      avail     / total;
    7.66 +
    7.67 +			usedpct  =  100  *       used     / total;
    7.68 +
    7.69 +			# Print complete bar
    7.70 +			printf("<span font=\"%s\"><tt>", font);
    7.71 +			printf("<span %s>%s</span>",     usedstyle,  bar(usedbar));
    7.72 +			printf("<span %s>%s</span>",     trashstyle, bar(trashbar));
    7.73 +			printf("<span %s>%s</span>",     availstyle, bar(availbar));
    7.74 +			printf("</tt></span>");
    7.75 +			printf(" %.1f %%", usedpct);
    7.76 +		}
    7.77 +	}
    7.78 +'
    7.79 +}
    7.80 +
    7.81 +
    7.82 +# Localize 'GB' and 'MB' at the end of line
    7.83 +
    7.84 +gbmb() {
    7.85 +	local GB=$(_ 'GB') MB=$(_ 'MB')
    7.86 +	sed "s|GB$|$GB|;s|MB$|$MB|"
    7.87 +}
    7.88 +
    7.89 +
    7.90 +# Display Yad window with Yandex.Disk status
    7.91 +
    7.92 +status() {
    7.93 +	version=$(yandex-disk -v | head -n1)
    7.94 +	copyright=$(yandex-disk -v | tail -n1)
    7.95 +
    7.96 +	yandex-disk status | gbmb | \
    7.97 +	yad --window-icon='yandex-disk' --center \
    7.98 +		--title="$title" --width='500' --height='300' \
    7.99 +		--image='yandex-disk' \
   7.100 +		--text="\
   7.101 +<span size='4000'> </span>
   7.102 +<span size='x-large'>$version</span>
   7.103 +<small>$copyright</small>
   7.104 +
   7.105 +$(bar)" \
   7.106 +		--text-align='center' \
   7.107 +		--text-info \
   7.108 +		--button='gtk-preferences:2' \
   7.109 +		--button='gtk-close'
   7.110 +}
   7.111 +
   7.112 +
   7.113 +# Display Yad window with Yandex.Disk preferences
   7.114 +
   7.115 +preferences() {
   7.116 +	# Get the value of variable $dir
   7.117 +	. "$HOME/.config/yandex-disk/config.cfg"
   7.118 +
   7.119 +	yad --window-icon='yandex-disk' --center \
   7.120 +		--title="$title" --image='yandex-disk' --fixed \
   7.121 +		--form --columns="2" \
   7.122 +		--field="$(_ 'Reconfigure')!system-run:FBTN"           "$0 configure" \
   7.123 +		--field="$(_ 'Start')!media-playback-start:FBTN"       "$0 start" \
   7.124 +		--field="$(_ 'Stop')!media-playback-stop:FBTN"         "$0 stop" \
   7.125 +		--field=" :LBL" "" \
   7.126 +		--field="$(_ 'Open local folder')!folder:FBTN"         "pcmanfm $dir" \
   7.127 +		--field="$(_ 'Open online folder')!folder-remote:FBTN" "$BROWSER https://disk.yandex.ru/" \
   7.128 +		--button='gtk-close' \
   7.129 +		>/dev/null
   7.130 +}
   7.131 +
   7.132 +
   7.133 +# Display Yad window when Yandex.Disk not configured yet
   7.134 +
   7.135 +firstrun() {
   7.136 +	yad --window-icon='yandex-disk' --center \
   7.137 +		--title="$title" --width='300' --image='yandex-disk' \
   7.138 +		--text="<b>$(_ 'Welcome to Yandex.Disk!')</b>
   7.139 +
   7.140 +$(_ 'To use Yandex.Disk on this computer, you must first configure it.')" || exit 0
   7.141 +
   7.142 +	$0 configure
   7.143 +	exit 0
   7.144 +}
   7.145 +
   7.146 +
   7.147 +# Check commands: start, stop, and configure
   7.148 +
   7.149 +case $1 in
   7.150 +	start|stop)
   7.151 +		answer=$(yandex-disk $1)
   7.152 +		if [ -e "$tmpid" ]; then
   7.153 +			# Replace existing notification
   7.154 +			notify_id=$(head -n1 $tmpid)
   7.155 +			notify-send -i 'yandex-disk' -r "${notify_id:-1}" -a tazweb "$title" "$answer"
   7.156 +		else
   7.157 +			# Make new notification
   7.158 +			notify-send -i 'yandex-disk' -p -a tazweb "$title" "$answer" > "$tmpid"
   7.159 +		fi
   7.160 +
   7.161 +		# Remove tmpid if it expired 5 sec (notification closed by timeout);
   7.162 +		# leave it if it updated (new notification was replaced the existing)
   7.163 +		# For example: press Stop, wait a second, press Start: there should be the single notification
   7.164 +		touch "$tmpid"; sleep 1; tmp_anchor=$(mktemp); sleep 4
   7.165 +		[ "$tmpid" -ot "$tmp_anchor" ] && rm "$tmpid"
   7.166 +		rm "$tmp_anchor"
   7.167 +
   7.168 +		exit 0
   7.169 +		;;
   7.170 +
   7.171 +	configure)
   7.172 +		# Stop daemon before, because it will not get the same path instead
   7.173 +		yandex-disk stop
   7.174 +
   7.175 +		# Run configuration in the terminal window
   7.176 +		answer=$(terminal -t "$title" -e yandex-disk setup)
   7.177 +
   7.178 +		# Additional configuration in the YAD window
   7.179 +		# Add bookmark if: checkbox checked and Finish pressed and bookmark absent yet
   7.180 +		answer=$(yad --window-icon='yandex-disk' --center \
   7.181 +			--title="$title" --image='yandex-disk' --fixed \
   7.182 +			--form --always-print-result \
   7.183 +			--field="$(_ 'Add folder to bookmarks'):CHK" "true" \
   7.184 +			--button="$(_ 'Finish')")
   7.185 +		[ $? -eq 0 ] || exit 0
   7.186 +
   7.187 +		case "$answer" in
   7.188 +			*TRUE*)
   7.189 +				. "$HOME/.config/yandex-disk/config.cfg"
   7.190 +				bookmarks="$HOME/.config/gtk-3.0/bookmarks"
   7.191 +				fgrep -q "$dir" "$bookmarks" && exit 0
   7.192 +				echo "file://$dir $title" >> "$bookmarks"
   7.193 +				;;
   7.194 +		esac
   7.195 +
   7.196 +		exit 0
   7.197 +		;;
   7.198 +esac
   7.199 +
   7.200 +
   7.201 +# Run without commands
   7.202 +
   7.203 +# Is Yandex.Disk already configured?
   7.204 +[ ! -e "$HOME/.config/yandex-disk/iid" ] && firstrun
   7.205 +
   7.206 +# Display status
   7.207 +status
   7.208 +[ $? -ne 2 ] && exit 0
   7.209 +
   7.210 +# Button Preferences pressed
   7.211 +preferences
   7.212 +
   7.213 +exit 0
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/yandex-disk/stuff/usr/libexec/yandex-disk/publish	Sun Nov 27 18:29:04 2016 +0200
     8.3 @@ -0,0 +1,62 @@
     8.4 +#!/bin/sh
     8.5 +# Publish file on the Yandex.Disk
     8.6 +# Aleksei Bobylev <al.bobylev@gmail.com>, 2016
     8.7 +
     8.8 +# i18n
     8.9 +_() { gettext 'yandex-disk-helper' "$1"; }
    8.10 +
    8.11 +# Read configuration
    8.12 +. $HOME/.config/yandex-disk/config.cfg
    8.13 +
    8.14 +title="$(_ 'Yandex.Disk')"
    8.15 +if [ -d "$1" ]; then
    8.16 +	type="$(_ 'Folder:')"
    8.17 +else
    8.18 +	type="$(_ 'File:')"
    8.19 +fi
    8.20 +name=$(basename "$1")
    8.21 +tmpid='/tmp/yandex-disk-notify.id'
    8.22 +
    8.23 +# Start notification in background
    8.24 +/usr/libexec/yandex-disk/status "$1" &
    8.25 +
    8.26 +# Publish the file/folder using yandex-disk CLI
    8.27 +answer=$(yandex-disk publish "$1")
    8.28 +case $? in
    8.29 +	0)	# OK
    8.30 +		;;
    8.31 +	*)	# Error
    8.32 +		# Wait a bit for notification to share its id
    8.33 +		sleep 1
    8.34 +		# Get notification id
    8.35 +		notify_id=$(fgrep "$1" $tmpid | cut -d$'\t' -f2)
    8.36 +		# Replace the notification with the error message
    8.37 +		notify-send --icon='dialog-error' -r ${notify_id:-999} \
    8.38 +			"$title" "<b>$name:</b>\n$answer"
    8.39 +		exit 1
    8.40 +		;;
    8.41 +esac
    8.42 +
    8.43 +# New file that copied to synced Yandex.Disk folder
    8.44 +y="$dir/$(basename "$1")"
    8.45 +# Set GVFS attributes
    8.46 +gvfs-set-attribute "$1" -t stringv metadata::emblems            yandex-disk
    8.47 +gvfs-set-attribute "$y" -t stringv metadata::emblems            emblem-shared
    8.48 +gvfs-set-attribute "$y" -t string  metadata::yandex-disk-origin "$1"
    8.49 +gvfs-set-attribute "$y" -t string  metadata::yandex-disk-uri    "$answer"
    8.50 +
    8.51 +# FIXME: PCManFM currently not update the emblem
    8.52 +
    8.53 +# Display YAD dialog where user can copy share URI or open it in default browser
    8.54 +echo $answer | \
    8.55 +yad \
    8.56 +	--title="$title" \
    8.57 +	--window-icon='yandex-disk' \
    8.58 +	--image='yandex-disk' \
    8.59 +	--center \
    8.60 +	--width=400 \
    8.61 +	--text="<b>$type</b> $name
    8.62 +<b>$(gettext 'yandex-disk-helper' 'Share URL:')</b>" \
    8.63 +	--text-info --show-url \
    8.64 +	--button='gtk-open' --button='gtk-close' &&
    8.65 +$BROWSER $answer
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/yandex-disk/stuff/usr/libexec/yandex-disk/status	Sun Nov 27 18:29:04 2016 +0200
     9.3 @@ -0,0 +1,44 @@
     9.4 +#!/bin/sh
     9.5 +# Live status of the publishing on the Yandex.Disk
     9.6 +# Aleksei Bobylev <al.bobylev@gmail.com>, 2016
     9.7 +
     9.8 +# i18n
     9.9 +_() { gettext 'yandex-disk-helper' "$1"; }
    9.10 +
    9.11 +title="$(_ 'Yandex.Disk')"
    9.12 +message="$(_ 'Please wait...')"
    9.13 +tmpid='/tmp/yandex-disk-notify.id'
    9.14 +
    9.15 +# Display initial notification
    9.16 +notify_id=$(notify-send -i 'yandex-disk' -p "$title" "$message")
    9.17 +
    9.18 +# Put the (filename and) notification id to tmp file
    9.19 +echo -e "$1\t$notify_id" >> $tmpid
    9.20 +
    9.21 +# Wait a bit (max 3s: avoid endless loop) before `yandex-disk status` will
    9.22 +# show 'Sync progress'
    9.23 +while [ wait != '###' ]; do
    9.24 +	LC_ALL=C yandex-disk status | fgrep -q 'Sync progress' && break
    9.25 +	sleep 1
    9.26 +	wait="$wait#"
    9.27 +done
    9.28 +
    9.29 +# Update notification in loop
    9.30 +while true; do
    9.31 +	# Exit loop if 'Sync progress' (probably) gone
    9.32 +	LC_ALL=C yandex-disk status | fgrep -q 'Sync progress' || break
    9.33 +
    9.34 +	# Get localized progress
    9.35 +	progress=$(yandex-disk status | head -n1)
    9.36 +	# Replace notification with the new info
    9.37 +	notify-send -i 'yandex-disk' -r "$notify_id" "$title" "$progress"
    9.38 +	sleep 1
    9.39 +done
    9.40 +
    9.41 +# Wait 5s: after that default time notification will gone
    9.42 +sleep 5
    9.43 +
    9.44 +# Remove id from tmp file
    9.45 +sed -i "/\t$notify_id$/d" $tmpid
    9.46 +# Remove file if it empty
    9.47 +[ -s "$tmpid" ] || rm $tmpid
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/yandex-disk/stuff/usr/libexec/yandex-disk/test	Sun Nov 27 18:29:04 2016 +0200
    10.3 @@ -0,0 +1,8 @@
    10.4 +#!/bin/sh
    10.5 +# Test if given file somewhere inside Yandex.Disk synced folder
    10.6 +# Aleksei Bobylev <al.bobylev@gmail.com>, 2016
    10.7 +
    10.8 +# Read configuration
    10.9 +. $HOME/.config/yandex-disk/config.cfg
   10.10 +
   10.11 +echo "$1" | fgrep -q "$dir"
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/yandex-disk/stuff/usr/libexec/yandex-disk/unpublish	Sun Nov 27 18:29:04 2016 +0200
    11.3 @@ -0,0 +1,19 @@
    11.4 +#!/bin/sh
    11.5 +# Unpublish file from Yandex.Disk: revoke sharing of the selected file
    11.6 +# Aleksei Bobylev <al.bobylev@gmail.com>, 2016
    11.7 +
    11.8 +# i18n
    11.9 +_() { gettext 'yandex-disk-helper' "$1"; }
   11.10 +
   11.11 +title="$(_ 'Yandex.Disk')"
   11.12 +name=$(basename "$1")
   11.13 +
   11.14 +# Unpublish file/folder using yandex-disk CLI
   11.15 +answer=$(yandex-disk unpublish "$1")
   11.16 +
   11.17 +# Display localized notification
   11.18 +notify-send -i 'yandex-disk' "$title" "$name:\n$answer"
   11.19 +
   11.20 +# Reset GVFS attributes
   11.21 +gvfs-set-attribute "$1" -t stringv metadata::emblems         none
   11.22 +gvfs-set-attribute "$1" -t string  metadata::yandex-disk-uri ''
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/yandex-disk/stuff/usr/share/applications/yandex-disk.desktop	Sun Nov 27 18:29:04 2016 +0200
    12.3 @@ -0,0 +1,8 @@
    12.4 +[Desktop Entry]
    12.5 +Type=Application
    12.6 +Name=Yandex.Disk
    12.7 +Name[ru]=Яндекс.Диск
    12.8 +Name[uk]=Яндекс.Диск
    12.9 +Exec=yandex-disk-helper
   12.10 +Icon=yandex-disk
   12.11 +Categories=GTK;Network;FileTransfer;
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/yandex-disk/stuff/usr/share/file-manager/actions/yd-publish.desktop	Sun Nov 27 18:29:04 2016 +0200
    13.3 @@ -0,0 +1,11 @@
    13.4 +[Desktop Entry]
    13.5 +Type=Action
    13.6 +Name=Publish on Yandex.Disk
    13.7 +Name[ru]=Опубликовать в Яндекс.Диск
    13.8 +Name[uk]=Опублікувати на Яндекс.Диск
    13.9 +Icon=yandex-disk
   13.10 +Profiles=PublishToYandex;
   13.11 +ShowIfRunning=/usr/bin/yandex-disk
   13.12 +
   13.13 +[X-Action-Profile PublishToYandex]
   13.14 +Exec=sh -c "/usr/libexec/yandex-disk/publish %f"
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/yandex-disk/stuff/usr/share/file-manager/actions/yd-unpublish.desktop	Sun Nov 27 18:29:04 2016 +0200
    14.3 @@ -0,0 +1,12 @@
    14.4 +[Desktop Entry]
    14.5 +Type=Action
    14.6 +Name=Withdraw from public access
    14.7 +Name[ru]=Убрать из публичного доступа
    14.8 +Name[uk]=Вилучити з публічного доступу
    14.9 +Icon=yandex-disk
   14.10 +Profiles=UnpublishFromYandex;
   14.11 +ShowIfRunning=/usr/bin/yandex-disk
   14.12 +
   14.13 +[X-Action-Profile UnpublishFromYandex]
   14.14 +ShowIfTrue=sh -c "/usr/libexec/yandex-disk/test %f"
   14.15 +Exec=sh -c "/usr/libexec/yandex-disk/unpublish %f"
    15.1 Binary file yandex-disk/stuff/usr/share/icons/hicolor/16x16/apps/yandex-disk.png has changed
    16.1 Binary file yandex-disk/stuff/usr/share/icons/hicolor/48x48/apps/yandex-disk.png has changed