make ty* fail nicely when in tmux/screen

devs/bu5hm4n/next
Boris Faure 6 years ago
parent e549612ab2
commit 0e0105e559
  1. 14
      src/bin/Makefile.am
  2. 6
      src/bin/tyalpha.c
  3. 7
      src/bin/tybg.c
  4. 5
      src/bin/tycat.c
  5. 21
      src/bin/tycommon.c
  6. 18
      src/bin/tycommon.h
  7. 6
      src/bin/tyls.c
  8. 8
      src/bin/typop.c
  9. 8
      src/bin/tyq.c

@ -63,43 +63,48 @@ gravatar.c gravatar.h \
tty_keys.h
tybg_SOURCES = \
tycommon.c \
tybg.c
tybg_CPPFLAGS = -I. \
-DPACKAGE_BIN_DIR=\"$(bindir)\" -DPACKAGE_LIB_DIR=\"$(libdir)\" \
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\"
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" @TERMINOLOGY_CFLAGS@
tybg_LDADD =
tyalpha_SOURCES = \
tycommon.c \
tyalpha.c
tyalpha_CPPFLAGS = -I. \
-DPACKAGE_BIN_DIR=\"$(bindir)\" -DPACKAGE_LIB_DIR=\"$(libdir)\" \
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\"
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" @TERMINOLOGY_CFLAGS@
tyalpha_LDADD =
typop_SOURCES = \
tycommon.c \
typop.c
typop_CPPFLAGS = -I. \
-DPACKAGE_BIN_DIR=\"$(bindir)\" -DPACKAGE_LIB_DIR=\"$(libdir)\" \
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\"
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" @TERMINOLOGY_CFLAGS@
typop_LDADD =
tyq_SOURCES = \
tycommon.c \
tyq.c
tyq_CPPFLAGS = -I. \
-DPACKAGE_BIN_DIR=\"$(bindir)\" -DPACKAGE_LIB_DIR=\"$(libdir)\" \
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\"
-DPACKAGE_DATA_DIR=\"$(pkgdatadir)\" @TERMINOLOGY_CFLAGS@
tyq_LDADD =
tycat_SOURCES = \
tycat.c \
tycommon.c \
extns.c extns.h
tycat_CPPFLAGS = -I. \
@ -110,6 +115,7 @@ tycat_LDADD = @TERMINOLOGY_LIBS@
tyls_SOURCES = \
tyls.c \
tycommon.c \
extns.h
tyls_CPPFLAGS = -I. \

@ -4,12 +4,16 @@
#include <unistd.h>
#include <string.h>
#include <Eina.h>
#include "tycommon.h"
int
main(int argc, char **argv)
{
int i, perm = 0;
if (!getenv("TERMINOLOGY")) return 0;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
if (argc <= 1)
{
printf("Usage: %s [-p] on|off|<opacity level>\n"

@ -4,12 +4,17 @@
#include <unistd.h>
#include <string.h>
#include <Eina.h>
#include "tycommon.h"
int
main(int argc, char **argv)
{
int i, perm = 0;
if (!getenv("TERMINOLOGY")) return 0;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
if (argc > 1 &&
(!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))
{

@ -11,6 +11,8 @@
#include <unistd.h>
#include <string.h>
#include "tycommon.h"
enum {
CENTER,
FILL,
@ -308,7 +310,8 @@ main(int argc, char **argv)
char *rp;
Eina_List *file_q = NULL;
if (!getenv("TERMINOLOGY")) return 0;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
if (argc <= 1)
{
print_usage(argv[0]);

@ -0,0 +1,21 @@
#include <stdlib.h>
#include <Eina.h>
#include "tycommon.h"
Eina_Bool
is_running_in_terminology(void)
{
if (!getenv("TERMINOLOGY"))
return EINA_FALSE;
// Terminology's escape codes do not got through tmux
if (getenv("TMUX"))
return EINA_FALSE;
// Terminology's escape codes do not got through screen
if (getenv("STY"))
return EINA_FALSE;
return EINA_TRUE;
}

@ -0,0 +1,18 @@
#ifndef _TY_COMMON_H__
#define _TY_COMMON_H__ 1
Eina_Bool is_running_in_terminology(void);
#define ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1() \
do \
{ \
if (!is_running_in_terminology()) \
{ \
fprintf(stderr, "not running in terminology\n"); \
exit(1); \
} \
} \
while (0)
#endif

@ -11,6 +11,7 @@
#include <unistd.h>
#include <string.h>
#include <fnmatch.h>
#include "tycommon.h"
// this code sucks. just letting you know... in advance... in case you
// might be tempted to think otherwise... :)
@ -725,8 +726,9 @@ main(int argc, char **argv)
char *path;
Eina_List *dirs = NULL;
Tyls_Options options = {SMALL, EINA_FALSE};
if (!getenv("TERMINOLOGY")) return 0;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
if ((argc == 2) && (!strcmp(argv[1], "-h")))
{
printf("Usage: %s [-a] [-s|-m] FILE1 [FILE2 ...]\n"

@ -4,12 +4,16 @@
#include <unistd.h>
#include <string.h>
#include <Eina.h>
#include "tycommon.h"
int
main(int argc, char **argv)
{
int i;
if (!getenv("TERMINOLOGY")) return 0;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
if (argc <= 1)
{
printf("Usage: %s FILE1 [FILE2 ...]\n"

@ -4,12 +4,16 @@
#include <unistd.h>
#include <string.h>
#include <Eina.h>
#include "tycommon.h"
int
main(int argc, char **argv)
{
int i;
if (!getenv("TERMINOLOGY")) return 0;
ON_NOT_RUNNING_IN_TERMINOLOGY_EXIT_1();
if (argc <= 1)
{
printf("Usage: %s FILE1 [FILE2 ...]\n"

Loading…
Cancel
Save