The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
apps.h
Go to the documentation of this file.
1
#pragma once
2
3
/**
4
* @file apps.h
5
* @brief the programs of the desktop: the .app files.
6
*
7
* each program the launcher shows has a file /usr/share/applications/
8
* <id>.app in the settings format of libconf:
9
*
10
* [app]
11
* name = Window demo
12
* comment = A test of the window server
13
* exec = heimdemo 2
14
* icon = application-x-executable
15
* category = Development
16
*
17
* name and exec must be there. icon is a Tela icon name (the icon library
18
* gives "unknown" for a name it does not have). category is one of
19
* APP_CATEGORIES; another or no category is "Other". hidden = true keeps
20
* the program out of the launcher (it can still be found by its id).
21
*
22
* exec is split into words at spaces. a word in double quotes can have
23
* spaces in it. the first word is the program: a path, or a name in /bin.
24
*/
25
26
#include <
stdbool.h
>
27
28
#define APPS_DIR "/usr/share/applications"
29
30
// the categories, in the order the launcher shows them
31
#define APP_CATEGORIES "Accessories", "Development", "Games", "Graphics", "Sound", "System", "Other"
32
33
#define APP_ARGS_MAX 16
34
35
typedef
struct
36
{
37
char
*
id
;
// the file name without .app
38
char
*
name
;
// "Window demo"
39
char
*
comment
;
// may be ""
40
char
*
exec
;
// "heimdemo 2"
41
char
*
icon
;
// "application-x-executable", may be ""
42
char
*
category
;
// one of APP_CATEGORIES
43
bool
hidden
;
44
}
app_t
;
45
46
typedef
struct
47
{
48
app_t
*
apps
;
// sorted by name (letter case is not looked at)
49
int
count
;
50
}
app_list_t
;
51
52
/**
53
* read the .app files of a directory (APPS_DIR for the system ones). a
54
* file without a name or exec is skipped, with a warning on stderr.
55
* @return the list (empty if there is no directory), or NULL (no memory).
56
*/
57
app_list_t
*
apps_load
(
const
char
*dir);
58
59
void
apps_free
(
app_list_t
*list);
60
61
/**
62
* the program with this id.
63
* @return it, or NULL.
64
*/
65
const
app_t
*
apps_find
(
const
app_list_t
*list,
const
char
*
id
);
66
67
/**
68
* split exec into words.
69
* @param buffer receives the words (it must hold strlen(exec) + 1 bytes).
70
* @param argv receives up to APP_ARGS_MAX words and a NULL.
71
* @return the number of words, or -1 (none, too many, or a quote that is
72
* not closed).
73
*/
74
int
app_split_exec
(
const
char
*
exec
,
char
*buffer,
char
*argv[
APP_ARGS_MAX
+ 1]);
app_split_exec
int app_split_exec(const char *exec, char *buffer, char *argv[APP_ARGS_MAX+1])
split exec into words.
Definition
apps.c:174
apps_free
void apps_free(app_list_t *list)
Definition
apps.c:35
apps_load
app_list_t * apps_load(const char *dir)
read the .app files of a directory (APPS_DIR for the system ones).
Definition
apps.c:111
apps_find
const app_t * apps_find(const app_list_t *list, const char *id)
the program with this id.
Definition
apps.c:162
APP_ARGS_MAX
#define APP_ARGS_MAX
Definition
apps.h:33
stdbool.h
bool, true and false.
app_list_t
Definition
apps.h:47
app_list_t::count
int count
Definition
apps.h:49
app_list_t::apps
app_t * apps
Definition
apps.h:48
app_t
Definition
apps.h:36
app_t::category
char * category
Definition
apps.h:42
app_t::hidden
bool hidden
Definition
apps.h:43
app_t::exec
char * exec
Definition
apps.h:40
app_t::comment
char * comment
Definition
apps.h:39
app_t::name
char * name
Definition
apps.h:38
app_t::icon
char * icon
Definition
apps.h:41
app_t::id
char * id
Definition
apps.h:37
exec
pid_t exec(const char *path, const char **argv)
execute a program, spawning a child process.
src
lib
apps
include
apps.h
Generated by
1.18.0