ssfs view ssfs-box @ rev 109
Remove ashism ==
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Feb 26 12:27:01 2019 +0100 (2019-02-26) |
parents | 10d2e9fb6131 |
children |
line source
1 #!/bin/sh
2 #
3 # SliTaz Secure File Storage GTK user interface using Yad.
4 #
5 # Copyright (C) SliTaz GNU/Linux - BSD License
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
9 app=$(basename $0)
10 config=$HOME/.config/ssfs/client.lua
11 pixmap=/usr/share/pixmaps/ssfs.png
13 # Internationalization
14 . /usr/bin/gettext.sh
15 TEXTDOMAIN='ssfs'
16 export TEXTDOMAIN
18 #
19 # Functions
20 #
22 info() {
23 size=$(du -sh $HOME/Sync | awk '{print $1}')
24 files=$(find $HOME/Sync | wc -l)
25 host=$(fgrep 'host' $config | cut -d '"' -f 2)
26 login=${host%@*}
27 host=${host#*@}
28 echo -e "Login\n$login
29 Host\n$host
30 Size\n$size
31 Files\n$files
32 RSA Key\n~/.ssh/id_rsa"
33 }
35 # Default tools GUI box function.
36 tools_main() {
37 if [ ! -s "$config" ]; then
38 $0 setup && exit 0
39 fi
40 [ "$opts" ] || opts="--width=520 --height=320"
41 text=$(gettext "<b>Welcome to the Ssfs Client user interface</b>")
42 info | yad $opts \
43 --list --title="Ssfs Box" \
44 --image-on-top --window-icon=$pixmap \
45 --text="$text" --image=$pixmap \
46 --column "Ssfs" --column "$(gettext "Value")" \
47 --button="$(gettext "Setup client"):5" \
48 --button="$(gettext "Edit config"):4" \
49 --button="$(gettext "Browse files"):3" \
50 --button="$(gettext "SSH Login"):2" \
51 --button="gtk-close:1"
52 }
54 # Default tools functions.
55 tools() {
56 # Store box results
57 main=$(tools_main)
58 # Deal with --button values
59 case $? in
60 1) exit 0 ;;
61 2) terminal -e "ssfs login" ;;
62 3) file-manager $HOME/Sync ;;
63 4) editor $config ;;
64 5) $0 setup ;;
65 *) continue ;;
66 esac
67 case $main in
68 Files*) file-manager $HOME/Sync ;;
69 RSA*)
70 yad --text-info --title="RSA Key" \
71 --width=560 --height=420 \
72 --filename=$HOME/.ssh/id_rsa \
73 --button="gtk-close:1" ;;
74 *)
75 continue ;;
76 esac
77 }
79 # Setup GUI box function.
80 setup_main() {
81 text=$(gettext \
82 "<b>Welcome to the Ssfs Setup</b>\n
83 Any account on a server yet ? You can vist www.slitaz.org
84 services or setup your own server in a few minutes!\n")
85 yad --form --title="Ssfs Setup" \
86 --window-icon=$pixmap \
87 --width=460 --height=200 --image-on-top \
88 --text="$text" --image=$pixmap \
89 --field="Login" --field="Server"
90 }
92 # Default tools functions.
93 setup() {
94 # Store box results and setup.
95 main=$(setup_main)
96 [ $? = 1 ] && exit 0
97 login=$(echo $main | cut -d '|' -f 1)
98 host=$(echo $main | cut -d '|' -f 2)
99 [ "$host" ] || exit 0
100 rm -f $config
101 terminal -hold -geometry 76x16 -T "Ssfs" \
102 -e "ssfs setup --login=$login --host=$host"
103 }
105 # Notification mode.
106 notify() {
107 export opts="--geometry=520x320-40+40 --timeout=6 --skip-taskbar"
108 yad --notification --image=$pixmap --command=$0 \
109 --text="$(gettext "Ssfs Live Sync storage")"
110 }
112 #
113 # Commands
114 #
116 case "$1" in
117 help)
118 echo "Usage: $app [command]" ;;
119 setup)
120 setup ;;
121 notify)
122 notify ;;
123 *)
124 tools ;;
125 esac
126 exit 0