aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--README3
-rw-r--r--doc/info/chap/invoking.texinfo7
-rw-r--r--doc/man/scrotty.111
-rw-r--r--doc/man/scrotty.sv.111
-rw-r--r--po/sv.po48
-rw-r--r--src/common.h1
-rw-r--r--src/info.c3
-rw-r--r--src/scrotty.auto-completion3
-rw-r--r--src/scrotty.c48
-rw-r--r--src/scrotty.sv.auto-completion5
11 files changed, 112 insertions, 31 deletions
diff --git a/NEWS b/NEWS
index 59a8cdc..3d039e4 100644
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,9 @@ scrotty NEWS -*- outline -*-
Tab-completion for GNU Bash, fish, and Z shell has been
added as an optional features.
+ The option --device have been added to let you screenshot
+ just one framebuffer.
+
** Translations
The program and the man page has been translated to Swedish.
diff --git a/README b/README
index 16ec4f6..50b5f1c 100644
--- a/README
+++ b/README
@@ -24,6 +24,9 @@ OPTIONS
-c, --copyright
Print copyright information.
+ -d, --device NO
+ Select framebuffer device.
+
-e, --exec CMD
Command to run for each saved image.
diff --git a/doc/info/chap/invoking.texinfo b/doc/info/chap/invoking.texinfo
index 46d6e58..31e0530 100644
--- a/doc/info/chap/invoking.texinfo
+++ b/doc/info/chap/invoking.texinfo
@@ -13,6 +13,11 @@ Print program name and version and exit.
@item -c
@itemx --copyright
Print copyright information and exit.
+@item -d
+@itemx --device NO
+Select a framebuffer device, by index, to
+screenshot. All framebuffers are screenshoot
+if this option is omitted.
@item -e
@itemx --exec CMD
Run a command for each saved image.
@@ -20,6 +25,8 @@ Run a command for each saved image.
Can only be specified once.
@end table
+Each option can only ube used once.
+
In addition to these options, a filename
pattern, that does not start with a dash,
can be added. This filename pattern selects
diff --git a/doc/man/scrotty.1 b/doc/man/scrotty.1
index 5cce851..227c98d 100644
--- a/doc/man/scrotty.1
+++ b/doc/man/scrotty.1
@@ -24,17 +24,22 @@ and a utility such as
.BR convert (1).
.SH OPTIONS
.TP
-.B \-h ,\ \-\-help
+.BR \-h ,\ \-\-help
Print usage information.
.TP
-.B \-v ,\ \-\-version
+.BR \-v ,\ \-\-version
Print program name and version.
.TP
-.B \-c ,\ \-\-copyright
+.BR \-c ,\ \-\-copyright
Print copyright information.
.TP
+.BR \-d ,\ \-\-device \ \fINO\fP
+Select framebuffer device.
+.TP
.BR \-e ,\ \-\-exec \ \fICMD\fP
Command to run for each saved image.
+.PP
+Each option can only be used once.
.SH "SPECIAL STRINGS"
Both the
.B \-\-exec
diff --git a/doc/man/scrotty.sv.1 b/doc/man/scrotty.sv.1
index b60ce87..e87fe1c 100644
--- a/doc/man/scrotty.sv.1
+++ b/doc/man/scrotty.sv.1
@@ -25,17 +25,22 @@ och verktyg såsom
.BR convert (1).
.SH ALTERNATIV
.TP
-.B \-h ,\ \-\-help
+.BR \-h ,\ \-\-help
Skriv ut burksanvisningar.
.TP
-.B \-v ,\ \-\-version
+.BR \-v ,\ \-\-version
Skriv ut programmets namn och version.
.TP
-.B \-c ,\ \-\-copyright
+.BR \-c ,\ \-\-copyright
Skriv ut upphovsrättsinformation.
.TP
+.BR \-d ,\ \-\-device \ \fINO\fP
+Välj bildrutebuffertenhet.
+.TP
.BR \-e ,\ \-\-exec \ \fIKMD\fP
Kommando att köra för varje sparad bild.
+.PP
+oVarje alternative kan endast användst en gång.
.SH "SÄRSKILDA STRÄNGAR"
Både
.B \-\-exec
diff --git a/po/sv.po b/po/sv.po
index 6852174..99d47a5 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: scrotty 1.1\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2015-12-11 16:12+0100\n"
+"POT-Creation-Date: 2015-12-12 08:34+0100\n"
"PO-Revision-Date: 2015-12-07 18:50+0100\n"
"Last-Translator: Mattias Andrée <maandree@member.fsf.org>\n"
"Language-Team: none\n"
@@ -17,39 +17,57 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-#: src/scrotty.c:229
+#: src/scrotty.c:226
#, c-format
msgid "Saved framebuffer %i to %s.\n"
msgstr "Bildrutebuffert %i sparad till %s.\n"
-#: src/scrotty.c:361 src/scrotty.c:365 src/scrotty.c:371
+#: src/scrotty.c:361 src/scrotty.c:364 src/scrotty.c:370 src/scrotty.c:376
+#: src/scrotty.c:380 src/scrotty.c:386
#, c-format
msgid "%s: %s. Type '%s --help' for help.\n"
msgstr "%s: %s. Kör '%s --help' för hjälp.\n"
#: src/scrotty.c:361
-msgid "--exec is used twice."
+#, fuzzy
+msgid "--device is used twice"
msgstr "--exec förkommer mer än en gång."
-#: src/scrotty.c:365
-msgid "Invalid input."
+#: src/scrotty.c:364 src/scrotty.c:370
+msgid "Invalid device number, not an integer"
+msgstr ""
+
+#: src/scrotty.c:376
+#, fuzzy
+msgid "--exec is used twice"
+msgstr "--exec förkommer mer än en gång."
+
+#: src/scrotty.c:380
+#, fuzzy
+msgid "Invalid input"
msgstr "Ogiltig indata."
-#: src/scrotty.c:371
-msgid "FILENAME-PATTERN is used twice."
+#: src/scrotty.c:386
+#, fuzzy
+msgid "FILENAME-PATTERN is used twice"
msgstr "FILNAMNSMÖNSTER förekommer mer än en gång"
-#: src/scrotty.c:384
+#: src/scrotty.c:399
#, c-format
msgid "%s: It looks like you are inside a display server. If this is correct, what you see is probably not what you get.\n"
msgstr "%s: Det ser ut som att du är innan för en grafikserver. Om detta är korrect, vad de ser är troligtvis inte vad du får.\n"
-#: src/scrotty.c:394
+#: src/scrotty.c:409
#, c-format
msgid "%s: %s: %s\n"
msgstr "%s: %s: %s\n"
-#: src/kern-linux.c:42
+#: src/scrotty.c:417
+#, c-format
+msgid "%s: The selected device does not exist.\n"
+msgstr ""
+
+#: src/kern-linux.c:41
#, c-format
msgid "%s: Unable to find a framebuffer. If you have a file named %s/MAKEDEV, run it with '-d /dev/fb' as root, or try running '%s'.\n"
msgstr "%s: Kunde inte hitta någon bildrutebuffert. Om filen %s/MAKEDEV finns ditt system, kör den med '-d /dev/fb' som root, eller testa att köra '%s'.\n"
@@ -64,8 +82,10 @@ msgid ""
"\t-h, --help Print usage information.\n"
"\t-v, --version Print program name and version.\n"
"\t-c, --copyright Print copyright information.\n"
+"\t-d, --device NO Select framebuffer device.\n"
"\t-e, --exec CMD Command to run for each saved image.\n"
"\n"
+"\tEach option can only be used once.\n"
"SPECIAL STRINGS\n"
"\tBoth the --exec and filename-pattern parameters can take format specifiers\n"
"\tthat are expanded by scrotty when encountered. There are two types of format\n"
@@ -97,8 +117,10 @@ msgstr ""
"\t-h, --help Skriv ut burksanvisningar.\n"
"\t-v, --version Skriv ut programmets namn och version.\n"
"\t-c, --copyright Skriv ut upphovsrättsinformation.\n"
+"\t-d, --device NO Välj bildrutebuffertenhet.\n"
"\t-e, --exec KMD Kommando att köra för varje sparad bild.\n"
"\n"
+"\tVarje alternative kan endast användst en gång.\n"
"SÄRSKILDA STRÄNGAR\n"
"\tBåde --exec och filnamnsmönstrets tar formatspecifikationsargument som\n"
"\tersätts av scrotty. Det finns två typer av formatspecifikationsargument.\n"
@@ -123,7 +145,7 @@ msgstr ""
"\tslutet av strängen, och om ett sådant även förekom direkt framför.\n"
"\n"
-#: src/info.c:77
+#: src/info.c:79
#, c-format
msgid ""
"%s\n"
@@ -142,7 +164,7 @@ msgstr ""
"\n"
"Skriven av Mattias Andrée.\n"
-#: src/info.c:97
+#: src/info.c:99
#, c-format
msgid ""
"scrotty -- Screenshot program for Linux's TTY\n"
diff --git a/src/common.h b/src/common.h
index 573a257..2e5deb2 100644
--- a/src/common.h
+++ b/src/common.h
@@ -30,6 +30,7 @@
#include <stdint.h>
#include <string.h>
#include <time.h>
+#include <limits.h>
#ifdef USE_GETTEXT
diff --git a/src/info.c b/src/info.c
index a60ed3e..a9a0d09 100644
--- a/src/info.c
+++ b/src/info.c
@@ -36,8 +36,11 @@ print_help (void)
"\t-h, --help Print usage information.\n"
"\t-v, --version Print program name and version.\n"
"\t-c, --copyright Print copyright information.\n"
+ "\t-d, --device NO Select framebuffer device.\n"
"\t-e, --exec CMD Command to run for each saved image.\n"
"\n"
+ "\tEach option can only be used once."
+ "\n"
"SPECIAL STRINGS\n"
"\tBoth the --exec and filename-pattern parameters can take format specifiers\n"
"\tthat are expanded by scrotty when encountered. There are two types of format\n"
diff --git a/src/scrotty.auto-completion b/src/scrotty.auto-completion
index 83cb284..e385e00 100644
--- a/src/scrotty.auto-completion
+++ b/src/scrotty.auto-completion
@@ -11,6 +11,9 @@
(unargumented (options -c --copyright) (complete --copyright)
(desc 'Print copyright information.'))
+ (argumented (options -d --device) (complete --device) (arg NUMBER) (files -0)
+ (desc 'Select framebuffer device.'))
+
(argumented (options -e --exec) (complete --exec) (arg COMMAND) (files -0)
(desc 'Command to run for each saved image.'))
diff --git a/src/scrotty.c b/src/scrotty.c
index e95b4e3..0faa685 100644
--- a/src/scrotty.c
+++ b/src/scrotty.c
@@ -23,6 +23,7 @@
#include "png.h"
#include "pattern.h"
+#include <ctype.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/wait.h>
@@ -251,21 +252,24 @@ save_fb (int fbno, const char *filepattern, const char *execpattern)
/**
- * Take a screenshot of all framebuffers.
+ * Take a screenshot of all, or one, framebuffers.
*
* @param filepattern The pattern for the filename, `NULL` for default.
* @param execpattern The pattern for the command to run to
* process thes image, `NULL` for none.
+ * @param all All framebuffers?
+ * @param devno The index of the framebuffer.
* @return Zero on success, -1 on error, 1 if no framebuffer exists.
*/
static
-int save_fbs (const char *filepattern, const char *exec)
+int save_fbs (const char *filepattern, const char *exec, int all, int devno)
{
int r, fbno, found = 0;
+ int last = all ? INT_MAX : (devno + 1);
retry:
/* Take a screenshot of each framebuffer. */
- for (fbno = 0;; fbno++)
+ for (fbno = (all ? 0 : devno); fbno < last; fbno++)
{
r = save_fb (fbno, filepattern, exec);
if (r < 0)
@@ -281,7 +285,7 @@ int save_fbs (const char *filepattern, const char *exec)
/* Did not find any framebuffer? */
if (found == 0)
{
- if (try_alt_fbpath++ < alt_fbpath_limit)
+ if (all && (try_alt_fbpath++ < alt_fbpath_limit))
goto retry;
return 1;
}
@@ -321,14 +325,17 @@ main (int argc, char *argv[])
#define USAGE_ASSERT(ASSERTION, MSG) \
do { if (!(ASSERTION)) EXIT_USAGE (MSG); } while (0)
- int r, all = 1, devno = 0;
+ int r, all = 1, devno = -1;
+ long devno_;
char *exec = NULL;
char *filepattern = NULL;
+ char *p;
struct option long_options[] =
{
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"copyright", no_argument, NULL, 'c'},
+ {"device", required_argument, NULL, 'd'},
{"exec", required_argument, NULL, 'e'},
{NULL, 0, NULL, 0 }
};
@@ -344,29 +351,44 @@ main (int argc, char *argv[])
execname = argc ? *argv : "scrotty";
for (;;)
{
- r = getopt_long (argc, argv, "hvcre:", long_options, NULL);
+ r = getopt_long (argc, argv, "hvcd:e:", long_options, NULL);
if (r == -1) break;
else if (r == 'h') return -(print_help ());
else if (r == 'v') return -(print_version ());
else if (r == 'c') return -(print_copyright ());
+ else if (r == 'd')
+ {
+ USAGE_ASSERT (all, _("--device is used twice"));
+ all = 0;
+ if (!isdigit (*optarg))
+ EXIT_USAGE (_("Invalid device number, not an integer"));
+ errno = 0;
+ devno_ = strtol (optarg, &p, 10);
+ if ((devno_ == 0) && (errno == ERANGE))
+ devno = -1;
+ else if (*p)
+ EXIT_USAGE (_("Invalid device number, not an integer"));
+ else
+ devno = (devno_ >= INT_MAX ? (INT_MAX - 1) : (int)devno_);
+ }
else if (r == 'e')
{
- USAGE_ASSERT (exec == NULL, _("--exec is used twice."));
+ USAGE_ASSERT (exec == NULL, _("--exec is used twice"));
exec = optarg;
}
else if (r == '?')
- EXIT_USAGE (_("Invalid input."));
+ EXIT_USAGE (_("Invalid input"));
else
abort ();
}
while (optind < argc)
{
- USAGE_ASSERT (filepattern == NULL, _("FILENAME-PATTERN is used twice."));
+ USAGE_ASSERT (filepattern == NULL, _("FILENAME-PATTERN is used twice"));
filepattern = argv[optind++];
}
/* Take a screenshot of each framebuffer. */
- r = save_fbs (filepattern, exec);
+ r = save_fbs (filepattern, exec, all, devno);
if (r < 0)
goto fail;
if (r > 0)
@@ -389,7 +411,11 @@ main (int argc, char *argv[])
return 1;
no_fb:
- print_not_found_help ();
+ if (all)
+ print_not_found_help ();
+ else
+ fprintf (stderr, _("%s: The selected device does not exist.\n"),
+ execname);
return 1;
}
diff --git a/src/scrotty.sv.auto-completion b/src/scrotty.sv.auto-completion
index 73e2c2a..817b4a8 100644
--- a/src/scrotty.sv.auto-completion
+++ b/src/scrotty.sv.auto-completion
@@ -11,8 +11,11 @@
(unargumented (options -c --copyright) (complete --copyright)
(desc 'Skriv ut upphovsrättsinformation.'))
+ (argumented (options -d --device) (complete --device) (arg NUMMER) (files -0)
+ (desc 'Välj bildrutebuffertenhet'))
+
(argumented (options -e --exec) (complete --exec) (arg KOMMANDO) (files -0)
- (desc 'Kör ett Kommando för varje sparad bild.'))
+ (desc 'Kör ett kommando för varje sparad bild.'))
(suggestion filename (verbatim '%Y-%m-%d_%H:%M:%S_$wx$h.$i.png'
'%Y-%m-%d_%H:%M:%S.$i.png'))