1 /* See LICENSE file for copyright and license details.*/
2 
3 #ifndef CONFIG_H
4 #define CONFIG_H
5 
6 /* colors                      fg,  bg */
7 static const Cpair cdir    = { 31, 0 };
8 static const Cpair cfile   = { 243, 0 };
9 static const Cpair clnk    = { 96, 0 };
10 static const Cpair cblk    = { 95, 0 };
11 static const Cpair cchr    = { 94, 0 };
12 static const Cpair cifo    = { 93, 0 };
13 static const Cpair csock   = { 92, 0 };
14 static const Cpair cexec   = { 91, 0 };
15 static const Cpair cother  = { 90, 0 };
16 
17 static const Cpair cframe  = { 233, 233 };
18 static const Cpair cpanell = { 166, 233 };
19 static const Cpair cpanelr = { 5,   233 };
20 static const Cpair cerr    = { 124, 0 };
21 static const Cpair cprompt = { 33,  0 };
22 static const Cpair csearch = { 255, 0 };
23 static const Cpair cstatus = { 243, 0 };
24 
25 /* commands */
26 #if defined(__linux__)
27 #define CHFLAG "chattr"
28 #else
29 #define CHFLAG "chflags"
30 #endif
31 static const char *rm_cmd[]      = { "rm", "-rf" }; /* delete */
32 static const char *cp_cmd[]      = { "cp", "-r" }; /* copy */
33 static const char *chown_cmd[]   = { "chown", "-R" }; /* change file owner and group */
34 static const char *chmod_cmd[]   = { "chmod" }; /* change file mode bits */
35 static const char *chflags_cmd[] = { CHFLAG }; /* change file flags */
36 static const char *mv_cmd[]      = { "mv" }; /* move */
37 static const char delconf[]      = "yes";
38 
39 static const size_t rm_cmd_len      = LEN(rm_cmd);
40 static const size_t cp_cmd_len      = LEN(cp_cmd);
41 static const size_t chown_cmd_len   = LEN(chown_cmd);
42 static const size_t chmod_cmd_len   = LEN(chmod_cmd);
43 static const size_t chflags_cmd_len = LEN(chflags_cmd);
44 static const size_t mv_cmd_len      = LEN(mv_cmd);
45 static const size_t delconf_len     = LEN(delconf);
46 
47 /* bookmarks */
48 static const char root[]   = "/";
49 
50 /* software */
51 static const char *mpv[]          = { "mpv", "--fullscreen" };
52 static const char *sxiv[]         = { "sxiv" };
53 static const char *mupdf[]        = { "mupdf", "-I" };
54 static const char *libreoffice[]  = { "libreoffice" };
55 static const char *gimp[]         = { "gimp" };
56 static const char *r2[]           = { "r2", "-c", "vv" };
57 
58 /* extensions*/
59 static const char *images[]    = { "bmp", "jpg", "jpeg", "png", "gif", "xpm" };
60 static const char *pdf[]       = { "epub", "pdf" };
61 static const char *arts[]      = { "xcf" };
62 static const char *obj[]       = { "o", "a", "so" };
63 static const char *videos[]    = { "avi", "flv", "wav", "webm", "wma", "wmv",
64 				   "m2v", "m4a", "m4v", "mkv", "mov", "mp3",
65 				   "mp4", "mpeg", "mpg" };
66 static const char *documents[] = { "odt", "doc", "docx", "xls", "xlsx", "odp",
67 				   "ods", "pptx", "odg" };
68 
69 static Rule rules[] = {
70 	{videos,    LEN(videos),    mpv,         LEN(mpv)         },
71 	{images,    LEN(images),    sxiv,        LEN(sxiv)        },
72 	{pdf,       LEN(pdf),       mupdf,       LEN(mupdf)       },
73 	{documents, LEN(documents), libreoffice, LEN(libreoffice) },
74 	{arts,      LEN(arts),      gimp,        LEN(gimp)        },
75 	{obj,       LEN(obj),       r2,          LEN(r2)          },
76 };
77 
78 /* normal keys */
79 static Key nkeys[] = {
80 	/* keyval                      function      arg */
81 	{ {.ch = 'j'},                 mv_ver,       {.i = -1}       },
82 	{ {.key = TB_KEY_ARROW_DOWN},  mv_ver,       {.i = -1}       },
83 	{ {.ch = 'k'},                 mv_ver,       {.i = +1}       },
84 	{ {.key = TB_KEY_ARROW_UP},    mv_ver,       {.i = +1}       },
85 	{ {.key = TB_KEY_CTRL_U},      mv_ver,       {.i = +3}       },
86 	{ {.key = TB_KEY_CTRL_D},      mv_ver,       {.i = -3}       },
87 	{ {.ch = 'l'},                 mvfwd,        {.i = 0}        },
88 	{ {.key = TB_KEY_ARROW_RIGHT}, mvfwd,        {.i = 0}        },
89 	{ {.ch = 'h'},                 mvbk,         {.i = 0}        },
90 	{ {.key = TB_KEY_ARROW_LEFT},  mvbk,         {.i = 0}        },
91 	{ {.ch = 'g'},                 mvtop,        {.i = 0}        },
92 	{ {.ch = 'G'},                 mvbtm,        {.i = 0}        },
93 	{ {.ch = 'n'},                 crnf,         {0}             },
94 	{ {.ch = 'N'},                 crnd,         {0}             },
95 	{ {.ch = 'd'},                 delent,       {0}             },
96 	{ {.ch = 'D'},                 dupl,         {0}             },
97 	{ {.ch = 'x'},                 calcdir,      {0}             },
98 	{ {.ch = '/'},                 start_filter, {0}             },
99 	{ {.ch = 'q'},                 quit,         {0}             },
100 	{ {.ch = 'v'},                 start_vmode,  {0}             },
101 	{ {.ch = 'y'},                 yank,         {0}             },
102 	{ {.ch = 'p'},                 paste,        {0}             },
103 	{ {.ch = 'P'},                 selmv,        {0}             },
104 	{ {.ch = 'c'},                 start_change, {0}             },
105 	{ {.ch = 'b'},                 opnsh,        {0}             },
106 	{ {.key = TB_KEY_SPACE},       switch_pane,  {0}             },
107 	{ {.key = TB_KEY_CTRL_R},      refresh,      {0}             },
108 	{ {.ch = '\\'},                bkmrk,        {.v = root}     },
109 	{ {.ch = '.'},                 toggle_df,    {0}             },
110 };
111 
112 /* change keys */
113 static Key ckeys[] = {
114 	/* keyval                      function         arg */
115 	{ {.ch = 'w'},                 rname,            {0}            },
116 	{ {.ch = 'o'},                 chngo,            {0}            },
117 	{ {.ch = 'm'},                 chngm,            {0}            },
118 	{ {.ch = 'f'},                 chngf,            {0}            },
119 	{ {.ch = 'q'},                 exit_change,      {0}            },
120 	{ {.ch = 'c'},                 exit_change,      {0}            },
121 	{ {.key = TB_KEY_ESC},         exit_change,      {0}            },
122 };
123 
124 /* visual keys */
125 static Key vkeys[] = {
126 	/* keyval                      function         arg */
127 	{ {.ch = 'j'},                 seldwn,          {.i = -1}      },
128 	{ {.key = TB_KEY_ARROW_DOWN},  seldwn,          {.i = -1}      },
129 	{ {.ch = 'k'},                 selup,           {.i = +1}      },
130 	{ {.key = TB_KEY_ARROW_UP},    selup,           {.i = +1}      },
131 	{ {.ch = 'a'},                 selall,          {0}            },
132 	{ {.ch = 'y'},                 selynk,          {0}            },
133 	{ {.ch = 'd'},                 seldel,          {.v = delconf} },
134 	{ {.ch = 'q'},                 exit_vmode,      {0}            },
135 	{ {.ch = 'v'},                 exit_vmode,      {0}            },
136 	{ {.key = TB_KEY_ESC},         exit_vmode,      {0}            },
137 };
138 
139 static const size_t nkeyslen = LEN(nkeys);
140 static const size_t vkeyslen = LEN(vkeys);
141 static const size_t ckeyslen = LEN(ckeys);
142 
143 /* permissions */
144 static const mode_t ndir_perm = S_IRWXU;
145 static const mode_t nf_perm   = S_IRUSR | S_IWUSR;
146 
147 /* dotfiles */
148 static int show_dotfiles = 1;
149 
150 /* statusbar */
151 static const char dtfmt[] = "%F %R"; /* date time format */
152 
153 /* unicode chars */
154 #define u_hl  0x2500 /* ─ */
155 #define u_vl  0x2502 /* │ */
156 #define u_cnw 0x250C /* ┌ */
157 #define u_cne 0x2510 /* ┐ */
158 #define u_csw 0x2514 /* └ */
159 #define u_cse 0x2518 /* ┘ */
160 #define u_mn  0x252C /* ┬ */
161 #define u_ms  0x2534 /* ┴ */
162 
163 #endif /* CONFIG_H */
164