-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstickynote
More file actions
executable file
·127 lines (114 loc) · 3.07 KB
/
Copy pathstickynote
File metadata and controls
executable file
·127 lines (114 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
:<<BLOCK
-*- coding:utf-8 -*-
Name: stickynote
Usage:v1.0 I always use windows and linux both in one computer, because windows
is good at documents writing and gaming. And I used to use sticky notes
which supported by Win7 to record something I am going to do. And I
want to know what I record in the windows when I was playing with Linux.
v1.1 I try to add function about add notes but it seems that I should
learn more about the stickynote instead of realizing it's just as a file.
v1.2 I change the way about loading notes. Add a history file as cache
Example: stickynote
Author: andy (andy.at.working@gmail.com)
Version: 1.2
Date: Jul 3 2014
Base: soffice(libreofficei v4.2.3.3 420m0 Build:3) 7z(v9.20)
Notes; The order is only suitable for my computer because the file called
sticynotes.snt is stored in different place in different PCs.
BLOCK
SYS_DISK='/dev/sda2'
MOUNT_PATH='/mnt'
NOTE_PATH='Users/Andy/AppData/Roaming/Microsoft/Sticky Notes'
MY_NOTE_PATH="$HOME/.config/myconfig/stickynote"
function help()
{
# echo "stickynote [-a <message-added>] [-d <deleting-message-number>] [-h]"
# echo -e "Tips: If there is space in the sentence. you should use \c"
# echo "quoting to quote the whole words"
echo "stickynote [-u] [-h]"
echo "u: update notes"
echo "h: this message"
exit
}
function check()
{
if [ -z "$*" ]
then
exit
fi
}
function open_windows()
{
sudo umount $MOUNT_PATH &>/dev/null
sudo umount $SYS_DISK &>/dev/null
sudo mount $SYS_DISK $MOUNT_PATH &>/dev/null
}
function close_windows()
{
sudo umount $SYS_DISK &>/dev/null
}
function update_note()
{
open_windows
cp "$MOUNT_PATH/$NOTE_PATH/StickyNotes.snt" _snt
7z -o_s e _snt &>/dev/null
cd _s
soffice --headless --convert-to xml 0 &>/dev/null
grep -E "<Text" 0.xml |awk -F "<Text " '{print $1}'|sed -e '/^ *$/d'|awk '{print NR ": " $0 "\n"}' > "$MY_NOTE_PATH/stickynote_history"
cd ..
rm -f _snt
rm -rf _s
close_windows
}
function show_note()
{
if [ -s "$MY_NOTE_PATH/stickynote_history" ]
then
cat "$MY_NOTE_PATH/stickynote_history" 2>/dev/null
else
update_note
$0
fi
}
function delete_msg()
{
exit
}
function add_msg()
{
sudo umount $MOUNT_PATH &>/dev/null
sudo umount $SYS_DISK &>/dev/null
sudo mount $SYS_DISK $MOUNT_PATH &>/dev/null
cp "$MOUNT_PATH/$NOTE_PATH/StickyNotes.snt" _snt
7z -o_s e _snt &>/dev/null
cd _s
soffice --headless --convert-to xml 0 &>/dev/null
cd ..
LAST_WORDS=`grep -E "<Text" _s/0.xml |awk -F "<Text " '{print $1}'|sed -e '/^ *$/d'|awk 'END{print $0}' `
sed -e "/^`echo $LAST_WORDS`.*/a\\``\\\\par" "$MOUNT_PATH/$NOTE_PATH/StickyNotes.snt" -e "/^`echo $LAST_WORDS`.*/a\\`echo $@`\\\\par" "$MOUNT_PATH/$NOTE_PATH/StickyNotes.snt" -e "/^`echo $LAST_WORDS`.*/a\\``\\\\par" "$MOUNT_PATH/$NOTE_PATH/StickyNotes.snt"
}
while getopts "ua:d:h" arg
do
case $arg in
a)
break
MSG=$OPTARG
check $MSG
add_msg $MSG
;;
d)
break
MSG=$OPTARG
check $MSG
delete_msg $MSG
;;
u)
update_note
;;
h)
help
;;
esac
done
show_note