📜 ⬆️ ⬇️

Interface for Yandex.Disk in Ubuntu 14.04

image

As you know, Yandex.Disk on Ubuntu exists only as a console client. Today I decided to “endure it enough” and wrote for myself a simple script that greatly simplifies working with it (the sources at the bottom of the article).

It is necessary to clarify that this script was written for personal use, but a friend persuaded to put it here, so things like absolute file addresses will not be absolute and you should correct them for your own system.

To work, we need only three files:
  1. Startup file for user interaction
  2. Bash script to interact with the client
  3. Yandex.Disk service icon

')
Let's start with BASH. Create a file ya-disk.sh in any convenient place:

#!/bin/bash case $1 in start) #   deamon=`yandex-disk start` notify-send -i "$HOME//yandex-disk/icon.png" "$deamon" ;; stop) #   deamon=`yandex-disk stop` notify-send -i "$HOME//yandex-disk/icon.png" "$deamon" ;; *) #    deamon=`yandex-disk status` if [[ "$deamon" == ":   " ]] #         - . then deamon=`yandex-disk start` notify-send -i "$HOME//yandex-disk/icon.png" "$deamon" else #         status=`yandex-disk status | grep -o '^  : .*$' | grep -o ': .*$'` all=`yandex-disk status | grep -o ':.*'` nfree=`yandex-disk status | grep -o ':.*'` free=`yandex-disk status | grep -o ':.*'` maxfile=`yandex-disk status | grep -o '  :.*'` trash=`yandex-disk status | grep -o ' :.*'` if [[ "$status" == ": " ]] #      then SUNC=`yandex-disk status | grep -o ' : .*' | grep -o '[^:]*$'` notify-send -i "$HOME//yandex-disk/icon.png" "" ":$SUNC\n$all\n$nfree\n$free\n$maxfile\n$trash" elif [[ "$status" == ":  " ]]; then #      notify-send -i "$HOME//yandex-disk/icon.png" "$status" else #    notify-send -i "$HOME//yandex-disk/icon.png" "$status" "$all\n$nfree\n$free\n$maxfile\n$trash" fi fi ;; esac #  case. exit 0 


Now create the startup file.

Go to the address where all our application shortcuts are:

 cd /usr/share/applications/ 

Now create a shortcut to our new application with the command:

 sudo gedit ya-disk.desktop 

With the following content:

 [Desktop Entry] Version=1.0 Type=Application Name=. Comment= ,        . Exec=/home/alex//yandex-disk/ya-disk.sh Terminal=false Icon=/home/alex//yandex-disk/icon.png StartupNotify=true Actions=Window;Document; [Desktop Action Window] Name= Exec=/home/alex//yandex-disk/ya-disk.sh start OnlyShowIn=Unity; [Desktop Action Document] Name= Exec=/home/alex//yandex-disk/ya-disk.sh stop OnlyShowIn=Unity; 

Do not forget to change the value of the Exec and Icon parameters. They should lead to the appropriate files on your.

And the final touch. Download and place the icon at the address specified in the Icon parameter.
For me it:

 /home/alex//yandex-disk/icon.png 

That's all.

The Yandex.Disk icon will appear in the Dash. If you put it on the Unity panel, then with the right button you can stop and start the daemon.

Promised source code .

Source: https://habr.com/ru/post/249267/


All Articles