Skip to content

Commit

Permalink
Add ability to print version
Browse files Browse the repository at this point in the history
  • Loading branch information
domsson committed Jun 11, 2020
1 parent 9122bad commit cefdd3f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ The special section `bar` configures Lemonbar itself and can define common forma
| `line-width` | number | Thickness of all underlines / overlines, if any, in pixels. |
| `overline` | boolean | Whether or not to draw an overline for all blocks. |
| `underline` | boolean | Whether or not to draw an underline for all blocks. |
| `block-margin` | number | Sets margin-left and margin-right for all blocks. |
| `block-margin` | number | Sets margin-left and margin-right for all blocks, in pixels. |
| `block-padding` | number | Adds the given number of spaces to both sides of the block's output. |

## blocks

Expand Down
5 changes: 4 additions & 1 deletion src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ void parse_args(int argc, char **argv, prefs_s *prefs)
// Get arguments, if any
opterr = 0;
int o;
while ((o = getopt(argc, argv, "c:ehs:")) != -1)
while ((o = getopt(argc, argv, "c:ehs:V")) != -1)
{
switch (o)
{
Expand All @@ -22,6 +22,9 @@ void parse_args(int argc, char **argv, prefs_s *prefs)
case 's': // section name for bar
prefs->section = optarg;
break;
case 'V': // print version and exit:
prefs->version = 1;
break;
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions src/succade.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,13 @@ static void help(const char *invocation, FILE *where)
fprintf(where, "\t-s\tINI section name for the bar.\n");
}

static void version()
{
fprintf(stdout, "%s %d.%d.%d\n%s\n", SUCCADE_NAME,
SUCCADE_VER_MAJOR, SUCCADE_VER_MINOR, SUCCADE_VER_PATCH,
SUCCADE_URL);
}

int main(int argc, char **argv)
{
//
Expand Down Expand Up @@ -1163,6 +1170,13 @@ int main(int argc, char **argv)
return EXIT_SUCCESS;
}

// PRINT VERSION AND EXIT, MAYBE
if (prefs->version)
{
version();
return EXIT_SUCCESS;
}

//
// PREFERENCES / DEFAULTS
//
Expand Down
17 changes: 4 additions & 13 deletions src/succade.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,18 @@
#include "libkita.h"
#include <unistd.h> // STDOUT_FILENO, STDIN_FILENO, STDERR_FILENO

#define DEBUG 1
#define DEBUG 0

#define SUCCADE_NAME "succade"
#define SUCCADE_URL "https://github.com/domsson/succade"
#define SUCCADE_VER_MAJOR 0
#define SUCCADE_VER_MINOR 3
#define SUCCADE_VER_MAJOR 1
#define SUCCADE_VER_MINOR 0
#define SUCCADE_VER_PATCH 0

#define BUFFER_NUMERIC 8
#define BUFFER_LEMON_ARG 1024
#define BUFFER_LEMON_INPUT 2048

#define BUFFER_BLOCK_FORMAT 256
#define BUFFER_BLOCK_NAME 64
#define BUFFER_BLOCK_AFFIX 16
#define BUFFER_BLOCK_LABEL 64
#define BUFFER_BLOCK_UNIT 16
#define BUFFER_BLOCK_OUTPUT 512
#define BUFFER_BLOCK_STR 2048

#define BLOCK_WAIT_TOLERANCE 0.1
Expand All @@ -33,10 +27,6 @@
#define DEFAULT_LEMON_NAME "succade_lemonbar"
#define DEFAULT_LEMON_SECTION "bar"

#define STR_DASH "-"
#define STR_PLUS "+"
#define STR_NONE ""

//
// ENUMS
//
Expand Down Expand Up @@ -170,6 +160,7 @@ struct succade_prefs
char *section; // INI section name for the bar
unsigned char empty : 1; // Run bar even if no blocks present?
unsigned char help : 1; // Show help text and exit?
unsigned char version : 1; // Show version and exit?
};

struct succade_state
Expand Down

0 comments on commit cefdd3f

Please sign in to comment.