Skip to content

Commit

Permalink
Merge pull request #1 from onodera-punpun/patch-1
Browse files Browse the repository at this point in the history
Add --bottom option
  • Loading branch information
Samuel Hand committed Mar 21, 2016
2 parents 5aeda9d + 39f0cf3 commit e95d194
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions n30f.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,12 @@ struct xcb_display_info
// name: the name the program was called using
void usage (char *name)
{
printf("usage: %s [-x xposition] [-y yposition] [-h, --help] [-d, --dock] [-c, --command] FILE\n", name);
printf("usage: %s [-x xposition] [-y yposition] [-h, --help] [-d, --dock] [-b, --bottom] [-c, --command] FILE\n", name);
printf(" -h, --help print this message\n");
printf(" -x set the x position\n");
printf(" -y set the y position\n");
printf(" -d, --dock force docking for non ewmh WMs\n");
printf(" -b, --bottom put n30f at the bottom of the screen\n");
printf(" -c, --command set the command to run on click\n");
}

Expand Down Expand Up @@ -175,6 +176,7 @@ int main (int argc, char **argv)
int x = 0;
int y = 0;
int dock = 0;
int bottom = 0;
char *filename;

int help_flag = 0;
Expand All @@ -188,13 +190,14 @@ int main (int argc, char **argv)
{
{"help", no_argument, &help_flag, 1},
{"dock", no_argument, &dock, 1},
{"bottom", no_argument, &bottom, 1},
{"command", required_argument, 0, 'c'},
{0, 0, 0, 0}
};
char *command;
// parse options using getopt_long
while(option != -1){
option = getopt_long(argc, argv, "hdc:x:y:", long_options, &option_index);
option = getopt_long(argc, argv, "hdbc:x:y:", long_options, &option_index);
switch(option){
case 'h':
option = -1;
Expand All @@ -205,6 +208,10 @@ int main (int argc, char **argv)
dock = 1;
break;

case 'b':
bottom = 1;
break;

case 'c':
command = strdup(optarg);
strcat(command, " &");
Expand Down Expand Up @@ -254,6 +261,9 @@ int main (int argc, char **argv)
// connect to the xserver
struct xcb_display_info display_info = init();

if(bottom)
y = display_info.s->height_in_pixels - cairo_image_surface_get_height(image) - y;

// create the window
xcb_window_t window = create_window(display_info, x, y,
cairo_image_surface_get_width(image), cairo_image_surface_get_height(image), dock);
Expand Down

0 comments on commit e95d194

Please sign in to comment.