pax_global_header00006660000000000000000000000064112626651000014511gustar00rootroot0000000000000052 comment=f4e6dcfff2a40cd92af29c44df490c847e5fc79c settitle-0.0.5/000075500000000000000000000000001126266510000133465ustar00rootroot00000000000000settitle-0.0.5/.gear/000075500000000000000000000000001126266510000143425ustar00rootroot00000000000000settitle-0.0.5/.gear/rules000064400000000000000000000000101126266510000154060ustar00rootroot00000000000000tar: . settitle-0.0.5/.gitignore000064400000000000000000000000331126266510000153320ustar00rootroot00000000000000*~ *.o is_screen settitle settitle-0.0.5/Makefile000064400000000000000000000005311126266510000150050ustar00rootroot00000000000000CFLAGS=-Os -pedantic -Wall -Werror -std=c99 LDFLAGS=-Wl,-O9 all: settitle is_screen install: install -D -m755 settitle ${bindir}/settitle install -D -m755 is_screen ${bindir}/is_screen clean: rm -f *.o settitle is_screen *~ settitle.o: settitle.c screen.h is_screen.o: is_screen.c screen.h settitle: settitle.o is_screen: is_screen.o settitle-0.0.5/TODO/000075500000000000000000000000001126266510000141135ustar00rootroot00000000000000settitle-0.0.5/TODO/hpterm.c000064400000000000000000000003341126266510000155560ustar00rootroot00000000000000/* if TERM=hpterm */ #include int main(int argc, char *argv[]) { /* title */ printf("\033&f0k%dD%s", strlen(argv[1]), argv[1]); /* icon */ printf("\033&f-1k%dD%s", strlen(argv[1]), argv[1]); return(0); } settitle-0.0.5/is_screen.c000064400000000000000000000007001126266510000154610ustar00rootroot00000000000000/*=========================================================================*/ /* Test for running in 'screen' enviroment */ /*=========================================================================*/ /* (C) Denis Smirnov, 25 Dec 2007 */ /*=========================================================================*/ #include "screen.h" int main() { return !is_screen(); } settitle-0.0.5/screen.h000064400000000000000000000007401126266510000147770ustar00rootroot00000000000000#include #include static inline char* getterm() { static char *term = NULL; if( !term ) { term = getenv("TERM"); if( term == NULL ) term = ""; } return term; } static inline int is_term(const char *name) { return strcmp(getterm(), name) == 0 ? 1 : 0; } static inline int is_screen() { return is_term("screen") || is_term("screen-bce"); } static inline int is_display_set() { char *term = getenv("DISPLAY"); return term == NULL ? 0 : 1; } settitle-0.0.5/settitle.c000064400000000000000000000050011126266510000153430ustar00rootroot00000000000000/*=========================================================================*/ /* Set window name in 'screen' enviroment */ /*=========================================================================*/ /* (C) Denis Smirnov, 25 Dec 2007 */ /*=========================================================================*/ #include #include #include #include "screen.h" inline static void dumpcode(int argc, char **argv, const char *prefix, const char *postfix) { int iovcnt = argc * 2; struct iovec iov[iovcnt]; struct iovec *io = iov; io[0].iov_base = (void *) prefix; io[0].iov_len = strlen(prefix); io++; while (--argc) { io[0].iov_base = *(++argv); io[0].iov_len = strlen(*argv); io++; io[0].iov_base = " "; io[0].iov_len = 1; io++; } iov[iovcnt - 1].iov_base = (void *) postfix; iov[iovcnt - 1].iov_len = strlen(postfix); while (writev(1, iov, iovcnt) == 0); } inline static void set_xterm_title_and_icon(int argc, char **argv) { dumpcode(argc, argv, "\033]0;", "\x07"); } inline static void set_icon(int argc, char **argv) { /* Set title in 'screen' */ if (is_screen()) return; else if (is_display_set()) { char *term = getterm(); if ( !strcmp(term, "aixterm") ) dumpcode(argc, argv, "\033]1;", "\x07"); else if ( !strcmp(term, "iris-ansi")) dumpcode(argc, argv, "\033P3.y", "\033\\"); else if ( !strcmp(term, "sun-cmd")) dumpcode(argc, argv, "\033]L", "\033\\"); else if ( !strcmp(term, "dtterm")) dumpcode(argc, argv, "\033]1;", "\x07"); else /* Set title in 'xterm' and derivatives */ dumpcode(argc, argv, "\033]1;", "\x07"); } } inline static void set_title(int argc, char **argv) { /* Set title in 'screen' */ if (is_screen()) dumpcode(argc, argv, "\x1bk", "\x1b\\"); else if (is_display_set()) { char *term = getterm(); if (strcmp(term, "")) return; else if (strcmp(term, "aixterm") == 0) dumpcode(argc, argv, "\033]2;", "\x07"); else if ( !strcmp(term, "iris-ansi")) dumpcode(argc, argv, "\033P1.y", "\033\\"); else if ( !strcmp(term, "sun-cmd")) dumpcode(argc, argv, "\033]l", "\033\\"); else if ( !strcmp(term, "dtterm")) dumpcode(argc, argv, "\033]2;", "\x07"); else /* Set title in 'xterm' and derivatives */ dumpcode(argc, argv, "\033]2;", "\x07"); } } /* * I use writev here, because we can use network terminal, and want that all * data would be sent with one packet */ int main(int argc, char **argv) { set_title(argc, argv); } settitle-0.0.5/settitle.spec000064400000000000000000000016711126266510000160640ustar00rootroot00000000000000Name: settitle Summary: Set Screen or Xterm window title Version: 0.0.5 Release: alt2 License: GPL Group: System/Base Packager: Denis Smirnov Url: http://sisyphus.ru/ru/srpm/Sisyphus/settitle Source: %name-%version.tar %description %summary %prep %setup %build %make all %install %makeinstall %files %_bindir/is_screen %_bindir/settitle %changelog * Tue Oct 06 2009 Denis Smirnov 0.0.5-alt2 - add Url tag * Thu Nov 20 2008 Denis Smirnov 0.0.5-alt1 - fix is_screen in screen-bce term - cleanup spec * Sun Nov 16 2008 Denis Smirnov 0.0.4-alt1 - fix crash if TERM not set * Fri Nov 14 2008 Denis Smirnov 0.0.3-alt1 - fix TERM=screen-bce support * Fri Feb 29 2008 Denis Smirnov 0.0.2-alt1 - package binary files :) * Sun Feb 24 2008 Denis Smirnov 0.0.1-alt1 - first build for Sisyphus