Skip to content

Commit 819324e

Browse files
committed
update
1 parent e809fc8 commit 819324e

File tree

3 files changed

+45
-22
lines changed

3 files changed

+45
-22
lines changed

README

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
11
kc
22

3-
KISS colors, an on-the-fly color palette changer written in C.
3+
KISS colors, an on-the-fly color palette changer written in C and designed for
4+
KISS Linux.
45

56

67
BACKGROUND
78
----------
89

9-
This project was inspired by Dylan Arap's okpal [0] palette change. This code
10-
base is partially-functional at this time and will be promoted to release once
11-
the following features are implemented:
12-
13-
- [x] Select palette
14-
- [ ] Select random palette
15-
- [x] List all palettes
16-
- [x] Set light theme
17-
- [x] Print help/usage.
18-
- [x] Print Version
19-
- [x] Print current palette
20-
- [x] save new palette to .config/
10+
This project was inspired by Dylan Arap's okpal [0] palette changer. This code
11+
base is "mostly" functional at this time and will be promoted to release once
12+
known bugs have been closed.
2113

2214

2315
INSTALLATION

kc.c

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <dirent.h>
66
#include <string.h>
77
#include "kc.h"
8+
#include <time.h>
89

910
int
1011
find_palettes(void)
@@ -67,17 +68,9 @@ select_palette(void)
6768
fclose(p.fp);
6869
sprintf(p.CLI, "%s > /dev/fd/0", p.PRI);
6970
system(p.CLI);
70-
sprintf(p.CLI, "%s > /dev/pts/0", p.PRI);
71-
system(p.CLI);
7271
return 0;
7372
}
7473

75-
int
76-
random_palette(void)
77-
{
78-
return 0;
79-
}
80-
8174
int
8275
list_palette(void)
8376
{
@@ -99,6 +92,40 @@ list_palette(void)
9992
return 0;
10093
}
10194

95+
int
96+
random_palette(void)
97+
{
98+
struct dirent *de;
99+
p.dr = opendir(p.SEL);
100+
p.randf = 0;
101+
if (p.dr == NULL)
102+
{
103+
printf("Could not open directory");
104+
return 1;
105+
}
106+
107+
while((de = readdir(p.dr)) != NULL)
108+
{
109+
p.randf++;
110+
}
111+
closedir(p.dr);
112+
srand(time(0));
113+
int v = (rand() % (p.randf - 2 + 1)) + 2;
114+
printf("%d %d\n", v, p.randf);
115+
p.randf = 0;
116+
p.dr = opendir(p.SEL);
117+
while((de = readdir(p.dr)) != NULL)
118+
{
119+
if (v == p.randf)
120+
{
121+
strcat(p.SEL, "/");
122+
strcat(p.SEL, de->d_name);
123+
}
124+
p.randf++;
125+
}
126+
return 0;
127+
}
128+
102129
int
103130
print_palette(void)
104131
{
@@ -151,8 +178,11 @@ main(int argc, char **argv)
151178
switch (p.cval)
152179
{
153180
case 'r':
181+
sprintf(p.SEL, "%s/%s", p.SEQ, p.MODE);
154182
random_palette();
155-
break;
183+
select_palette();
184+
print_palette();
185+
break;
156186
case 'l':
157187
sprintf(p.SEL, "%s/%s", p.SEQ, p.MODE);
158188
list_palette();

kc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ struct
22
{
33
int cval;
44
int errf;
5+
int randf;
56
FILE *fp;
67
DIR *dr;
78
char *line;

0 commit comments

Comments
 (0)