okshot 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.org +25 -13
- data/bin/take_screenshot.sh +21 -10
- data/lib/ok/shot.rb +19 -9
- data/lib/ok/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dac8faf503714e6c195b6d07c2b046b873d857df50e72e33ae3d227081fcbe3e
|
|
4
|
+
data.tar.gz: 485a3c0fa9c11e545adad059dd6f9e36dbba8fc154c10914c79358ce953402c5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dcf40412c7284cfaebb31e74d68a504363b70ff87a5dea4dfdfd208878906c6d4a027dcac758a118226c6115f2ef376ad7ba442c5fc251ded89f12f0ffc40375
|
|
7
|
+
data.tar.gz: 490d644591fc142ef9fcf3c40aab21731d2f70596fe4d4dadf2d2347ee097ad1658369424f8df0d8f1b922419bc0318b76dee7c18f36607ab37a1375e796a82c
|
data/README.org
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
\___/|_|\_\___/_| |_|\___/ \__|
|
|
7
7
|
#+end_example
|
|
8
8
|
|
|
9
|
-
# #+html: <img src="https://github.com/200ok-ch/okshot/workflows/CI/badge.svg"/>
|
|
10
9
|
#+html: <a href="https://rubygems.org/gems/okshot"> <img src="https://badge.fury.io/rb/okshot.svg"/></a>
|
|
11
10
|
|
|
12
11
|
* NAME
|
|
@@ -17,18 +16,21 @@
|
|
|
17
16
|
|
|
18
17
|
#+begin_example
|
|
19
18
|
Usage: okshot [options]
|
|
19
|
+
-C, --copy-to-clipboard Copy PNG file from clipboard and upload
|
|
20
20
|
-s, --simple Take a screenshot without annotation and upload
|
|
21
|
-
-c, --copy-clipboard
|
|
21
|
+
-c, --copy-from-clipboard Copy PNG file from clipboard and upload
|
|
22
22
|
-i, --inkscape Use inkscape to edit the screenshot and upload
|
|
23
23
|
#+end_example
|
|
24
24
|
|
|
25
25
|
* DESCRIPTION
|
|
26
26
|
|
|
27
|
-
=okshot= takes a screenshot,
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
=okshot= takes a screenshot, optionally annotates it and then saves it
|
|
28
|
+
either to the clipboard or uploads it to a FTP server and copies a web
|
|
29
|
+
accessible URL to your clipboard.
|
|
30
30
|
|
|
31
31
|
This gem is inspired by the lack of good screenshot tooling in Linux.
|
|
32
|
+
However, Linux has all the tools available that can easily be strung
|
|
33
|
+
together to get the ultimate screenshot tool.
|
|
32
34
|
|
|
33
35
|
For uploading the files via FTP, it needs these environment variables set:
|
|
34
36
|
|
|
@@ -57,21 +59,31 @@ export OKSHOT_URL_PREFIX=https://okshot.your_domain.ch
|
|
|
57
59
|
|
|
58
60
|
It uses the following standard Linux tools. For all flags, it requires:
|
|
59
61
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
| Program | Rationale |
|
|
63
|
+
|-------------+------------------------------------------------------------------|
|
|
64
|
+
| [[https://imagemagick.org/][imagemagick]] | Takes the actual screenshot as a PNG file. |
|
|
65
|
+
| [[https://linux.die.net/man/1/uuidgen][uuigen]] | Adds a partial UUID to the screenshot name to ensure uniqueness. |
|
|
66
|
+
| [[https://linux.die.net/man/1/xclip][xclip]] | Copies the public screenshot URL to the clipboard. |
|
|
67
|
+
| [[http://manpages.ubuntu.com/manpages/xenial/man1/notify-send.1.html][notify-send]] | Creates a desktop notification that the URL is in the clipboard. |
|
|
68
|
+
|
|
69
|
+
Without the flag =-C= (=--copy-to-clipboard=), the file is uploaded to
|
|
70
|
+
an FTP server and requires:
|
|
71
|
+
|
|
72
|
+
| Program | Rationale |
|
|
73
|
+
|-------------+------------------------------------------------------------------|
|
|
74
|
+
| [[https://linux.die.net/man/1/ftp][ftp]] | Uploads the final screenshot to a FTP server. |
|
|
64
75
|
|
|
65
76
|
For the flag =-i=, it additionally requires:
|
|
66
77
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
| Program | Rationale |
|
|
79
|
+
|----------+-------------------------------------|
|
|
80
|
+
| [[https://inkscape.org/][inkscape]] | Annotate the image in all the ways. |
|
|
81
|
+
| [[https://linux.die.net/man/1/wmctrl][wmctrl]] | Starts Inkscape in full screen. |
|
|
70
82
|
|
|
71
83
|
Install dependencies:
|
|
72
84
|
|
|
73
85
|
#+begin_src shell
|
|
74
|
-
apt-get install imagemagick ftp inkscape wmctrl uuid-runtime xclip
|
|
86
|
+
apt-get install imagemagick ftp inkscape wmctrl uuid-runtime xclip libnotify-bin
|
|
75
87
|
#+end_src
|
|
76
88
|
|
|
77
89
|
* DEVELOPMENT
|
data/bin/take_screenshot.sh
CHANGED
|
@@ -14,7 +14,6 @@ elif [[ $1 == -h ]]; then
|
|
|
14
14
|
echo " -c: Copy clipboard to file and upload"
|
|
15
15
|
echo " -i: Use inkscape to edit the screenshot and upload"
|
|
16
16
|
echo " -h: Show this help"
|
|
17
|
-
exit 0
|
|
18
17
|
elif [[ $1 == -i ]]; then
|
|
19
18
|
import /tmp/$screenshot
|
|
20
19
|
|
|
@@ -62,19 +61,31 @@ else
|
|
|
62
61
|
exit 1
|
|
63
62
|
fi
|
|
64
63
|
|
|
65
|
-
|
|
66
|
-
USER=$OKSHOT_USER
|
|
67
|
-
PASSWD=$OKSHOT_PASSWORD
|
|
64
|
+
echo "SCREENSHOT FILE: "
|
|
68
65
|
|
|
69
|
-
|
|
66
|
+
echo "/tmp/${screenshot}"
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if [[ $2 == -C ]]; then
|
|
70
|
+
# Copy to clipboard
|
|
71
|
+
xclip -selection clipboard -t image/png -i /tmp/$screenshot
|
|
72
|
+
|
|
73
|
+
notify-send "Copied screenshot to clipboard"
|
|
74
|
+
else
|
|
75
|
+
# Upload to host
|
|
76
|
+
HOST=$OKSHOT_HOST
|
|
77
|
+
USER=$OKSHOT_USER
|
|
78
|
+
PASSWD=$OKSHOT_PASSWORD
|
|
79
|
+
|
|
80
|
+
ftp -p -n -v $HOST <<END_SCRIPT
|
|
70
81
|
user $USER $PASSWD
|
|
71
82
|
put /tmp/$screenshot $screenshot
|
|
72
83
|
quit
|
|
73
84
|
END_SCRIPT
|
|
74
85
|
|
|
75
|
-
screenshot_url="$OKSHOT_URL_PREFIX/$screenshot"
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
screenshot_url="$OKSHOT_URL_PREFIX/$screenshot"
|
|
87
|
+
echo $screenshot_url | xclip -selection c
|
|
88
|
+
notify-send "Copied $screenshot_url to clipboard"
|
|
89
|
+
fi
|
|
78
90
|
|
|
79
|
-
|
|
80
|
-
rm /tmp/$screenshot
|
|
91
|
+
exit 0
|
data/lib/ok/shot.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# coding: utf-8
|
|
3
3
|
|
|
4
4
|
require 'optparse'
|
|
5
|
+
require 'ostruct'
|
|
5
6
|
require 'set'
|
|
6
7
|
require 'readline'
|
|
7
8
|
require 'fileutils'
|
|
@@ -11,40 +12,49 @@ module OK
|
|
|
11
12
|
class Error < StandardError; end
|
|
12
13
|
extend self
|
|
13
14
|
|
|
14
|
-
def take_screenshot(
|
|
15
|
+
def take_screenshot(options)
|
|
15
16
|
bin_dir = File.expand_path(File.join(%w[.. .. .. bin]), __FILE__)
|
|
16
|
-
shell_script_path = File.join(bin_dir, "take_screenshot.sh -#{flag}")
|
|
17
|
+
shell_script_path = File.join(bin_dir, "take_screenshot.sh -#{options.flag}")
|
|
18
|
+
shell_script_path += " -C" if options.copy_to_clipboard
|
|
17
19
|
`#{shell_script_path}`
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def main
|
|
23
|
+
options = OpenStruct.new
|
|
21
24
|
OptionParser.new do |opts|
|
|
22
25
|
opts.banner = 'Usage: okshot [options]'
|
|
26
|
+
opts.on(
|
|
27
|
+
'-C',
|
|
28
|
+
'--copy-to-clipboard',
|
|
29
|
+
'Copy PNG file from clipboard and upload'
|
|
30
|
+
) do |c|
|
|
31
|
+
options.copy_to_clipboard = true
|
|
32
|
+
end
|
|
23
33
|
opts.on(
|
|
24
34
|
'-s',
|
|
25
35
|
'--simple',
|
|
26
36
|
'Take a screenshot without annotation and upload'
|
|
27
37
|
) do |c|
|
|
28
|
-
|
|
29
|
-
exit
|
|
38
|
+
options.flag = 's'
|
|
30
39
|
end
|
|
31
40
|
opts.on(
|
|
32
41
|
'-c',
|
|
33
|
-
'--copy-clipboard',
|
|
42
|
+
'--copy-from-clipboard',
|
|
34
43
|
'Copy PNG file from clipboard and upload'
|
|
35
44
|
) do |c|
|
|
36
|
-
|
|
37
|
-
exit
|
|
45
|
+
options.flag = 'c'
|
|
38
46
|
end
|
|
39
47
|
opts.on(
|
|
40
48
|
'-i',
|
|
41
49
|
'--inkscape',
|
|
42
50
|
'Use inkscape to edit the screenshot and upload'
|
|
43
51
|
) do |c|
|
|
44
|
-
|
|
45
|
-
exit
|
|
52
|
+
options.flag = 'i'
|
|
46
53
|
end
|
|
47
54
|
end.parse!
|
|
55
|
+
|
|
56
|
+
take_screenshot(options)
|
|
57
|
+
exit
|
|
48
58
|
end
|
|
49
59
|
end
|
|
50
60
|
end
|
data/lib/ok/version.rb
CHANGED