File tree Expand file tree Collapse file tree 3 files changed +45
-22
lines changed Expand file tree Collapse file tree 3 files changed +45
-22
lines changed Original file line number Diff line number Diff line change 1
1
kc
2
2
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.
4
5
5
6
6
7
BACKGROUND
7
8
----------
8
9
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.
21
13
22
14
23
15
INSTALLATION
Original file line number Diff line number Diff line change 5
5
#include <dirent.h>
6
6
#include <string.h>
7
7
#include "kc.h"
8
+ #include <time.h>
8
9
9
10
int
10
11
find_palettes (void )
@@ -67,17 +68,9 @@ select_palette(void)
67
68
fclose (p .fp );
68
69
sprintf (p .CLI , "%s > /dev/fd/0" , p .PRI );
69
70
system (p .CLI );
70
- sprintf (p .CLI , "%s > /dev/pts/0" , p .PRI );
71
- system (p .CLI );
72
71
return 0 ;
73
72
}
74
73
75
- int
76
- random_palette (void )
77
- {
78
- return 0 ;
79
- }
80
-
81
74
int
82
75
list_palette (void )
83
76
{
@@ -99,6 +92,40 @@ list_palette(void)
99
92
return 0 ;
100
93
}
101
94
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
+
102
129
int
103
130
print_palette (void )
104
131
{
@@ -151,8 +178,11 @@ main(int argc, char **argv)
151
178
switch (p .cval )
152
179
{
153
180
case 'r' :
181
+ sprintf (p .SEL , "%s/%s" , p .SEQ , p .MODE );
154
182
random_palette ();
155
- break ;
183
+ select_palette ();
184
+ print_palette ();
185
+ break ;
156
186
case 'l' :
157
187
sprintf (p .SEL , "%s/%s" , p .SEQ , p .MODE );
158
188
list_palette ();
Original file line number Diff line number Diff line change 2
2
{
3
3
int cval ;
4
4
int errf ;
5
+ int randf ;
5
6
FILE * fp ;
6
7
DIR * dr ;
7
8
char * line ;
You can’t perform that action at this time.
0 commit comments