ssfs view ssfs-box @ rev 78

Fix a few typo
author Christophe Lincoln <pankso@slitaz.org>
date Mon Jun 13 23:42:47 2011 +0200 (2011-06-13)
parents 3a2f682ce267
children 10d2e9fb6131
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=460 --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"):4" \
48 --button="$(gettext "Edit config"):3" \
49 --button="$(gettext "Browse files"):2" \
50 --button="gtk-close:1"
51 }
53 # Default tools functions.
54 tools() {
55 # Store box results
56 main=$(tools_main)
57 # Deal with --button values
58 case $? in
59 1) exit 0 ;;
60 2) file-manager $HOME/Sync ;;
61 3) editor $config ;;
62 4) $0 setup ;;
63 *) continue ;;
64 esac
65 case $main in
66 RSA*)
67 yad --text-info --title="RSA Key" \
68 --width=560 --height=420 \
69 --filename=$HOME/.ssh/id_rsa ;;
70 *)
71 continue ;;
72 esac
73 }
75 # Setup GUI box function.
76 setup_main() {
77 text=$(gettext \
78 "<b>Welcome to the Ssfs Setup</b>\n
79 Any account on a server yet ? You can vist www.slitaz.org
80 services or setup your own server in a few minutes!\n")
81 yad --form --title="Ssfs Setup" \
82 --window-icon=$pixmap \
83 --width=460 --height=200 --image-on-top \
84 --text="$text" --image=$pixmap \
85 --field="Login" --field="Server"
86 }
88 # Default tools functions.
89 setup() {
90 # Store box results and setup.
91 main=$(setup_main)
92 [ $? == 1 ] && exit 0
93 login=$(echo $main | cut -d '|' -f 1)
94 host=$(echo $main | cut -d '|' -f 2)
95 [ "$host" ] || exit 0
96 rm -f $config
97 terminal -hold -geometry 76x16 -T "Ssfs" \
98 -e "ssfs setup --login=$login --host=$host"
99 }
101 # Notification mode.
102 notify() {
103 export opts="--geometry=460x320-40+40 --timeout=6 --skip-taskbar"
104 yad --notification --image=$pixmap --command=$0 \
105 --text="$(gettext "Ssfs Live Sync storage")"
106 }
108 #
109 # Commands
110 #
112 case "$1" in
113 help)
114 echo "Usage: $app [command]" ;;
115 setup)
116 setup ;;
117 notify)
118 notify ;;
119 *)
120 tools ;;
121 esac
122 exit 0