Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ If arguments are given, outputs the title of each arguments, otherwise outputs t
xtitle [-h|-v|-s|-e|-i|-f FORMAT|-t NUMBER] [WID ...]

# Options
- `-h` — Print the synopsis to standard output and exit.
- `-h` — Print usage information to standard output and exit.
- `-v` — Print the version to standard output and exit.
- `-s` — Activate the *snoop* mode.
- `-e` — Escape the following characters: ', " and \\.
Expand Down
23 changes: 22 additions & 1 deletion xtitle.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main(int argc, char *argv[])
while ((opt = getopt(argc, argv, "hvseif:t:")) != -1) {
switch (opt) {
case 'h':
printf("xtitle [-h|-v|-s|-e|-i|-f FORMAT|-t NUMBER] [WID ...]\n");
print_usage();
goto end;
break;
case 'v':
Expand Down Expand Up @@ -137,6 +137,26 @@ int main(int argc, char *argv[])
return ret;
}

void print_usage()
{
printf("%s",
"Description:\n"
" Output title of WID(s) or focused window\n\n"
"Synopsis:\n"
" xtitle [-h|-v|-s|-e|-i|-f FORMAT|-t NUMBER] [WID ...]\n\n"
"Options:\n"
" -h Print usage information to standard output and exit.\n"
" -v Print version to standard output and exit.\n"
" -s Snoop mode.\n"
" -e Escape the following characters: ', \" and \\.\n"
" -i Try to retrieve the title from the _NET_WM_VISIBLE_NAME atom.\n"
" -f FORMAT Use the given printf-style format.\n"
" Supported sequences are %s (for title), %u (for window id) and \\n.\n"
" -t NUMBER Truncate the title after |NUMBER| characters,\n"
" starting at the first (or the last if negative) character.\n"
);
}

bool setup(void)
{
dpy = xcb_connect(NULL, &default_screen);
Expand Down Expand Up @@ -331,3 +351,4 @@ void hold(int sig)
running = false;
}
}

1 change: 1 addition & 0 deletions xtitle.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ int default_screen;
xcb_window_t root;
bool running, visible;

void print_usage();
bool setup(void);
wchar_t* expand_escapes(const wchar_t *src);
void output_title(xcb_window_t win, wchar_t *format, bool escaped, int truncate);
Expand Down