staging.inyokaproject.org

systemd/localectl

Status: Ungelöst | Ubuntu-Version: Xubuntu 16.04 (Xenial Xerus)
Antworten |
Dieses Thema ist die Diskussion des Artikels systemd/localectl.

picnerd

Avatar von picnerd

Anmeldungsdatum:
17. März 2016

Beiträge: 872

Ich habe mal einen neuen Artikel angefangen. Ist aber noch nicht fertig. 😉 Eure Meinung ist natürlich erwünscht. Auch über zusätzliche Infos freue ich mich. 😛

mfg

noisefloor Team-Icon

Ehemaliger
Avatar von noisefloor

Anmeldungsdatum:
6. Juni 2006

Beiträge: 28316

Hallo,

ist soweit ok, denke ich. Was aber noch fehlt:

  • ein Hinweis, dass localectl Teil von systemd ist

  • der obligatorische Abschnitt zur Installation. Den kannst du z.B aus dem Artikel zu systemctl übernehmen.

Gruß, noisefloor

picnerd

(Themenstarter)
Avatar von picnerd

Anmeldungsdatum:
17. März 2016

Beiträge: 872

Habe ich erledigt und so noch mal drüber geschaut. Rechtschreibung(ist nicht mein Steckenpferd 🙄 ), kleine Korrekturen und eine Hinweisbox am Ende.

Ich bin aber mit der Ermittlung der vorhandenen Tastatur (Desktop oder Laptop) über „lsusb" nicht zufrieden. Vielleicht hat da jemand eine bessere Idee ansonsten muss ich dafür mal einen Thread starten.

mfg

noisefloor Team-Icon

Ehemaliger
Avatar von noisefloor

Anmeldungsdatum:
6. Juni 2006

Beiträge: 28316

Hallo,

Ich bin aber mit der Ermittlung der vorhandenen Tastatur (Desktop oder Laptop) über „lsusb" nicht zufrieden.

habe gerade mal kurz recherchiert: habe keinen Weg gefunden, wie man via Software feststellen kann, on man eine pc104, pc105 oder sonst was Tastatur hat...

Gruß, noisefloor

picnerd

(Themenstarter)
Avatar von picnerd

Anmeldungsdatum:
17. März 2016

Beiträge: 872

Wenn sonst keiner Einwände hat würde ich sagen das ich das erst einmal soweit fertig habe. Die Arbeit ab diesem Artikel überschneidet sich auch mit dem noch nicht vorhandenen Artikel „locale". Mal schauen 😉 Deshalb sind vielleicht Änderungen oder Erweiterungen möglich. Alles von mir getestet und kann auf die Menschheit losgelassen werden ohne dass sie ihre Kiste schrotten.

evt. mit TAG Ausbaufähig

mfg

Heinrich_Schwietering Team-Icon

Wikiteam
Avatar von Heinrich_Schwietering

Anmeldungsdatum:
12. November 2005

Beiträge: 11288

Hi!

Hab rein formal (Syntax, Rechtschreibung, Zeichensetzung, tags etc.) einmal durchgeschliffen.

so long
hank

picnerd

(Themenstarter)
Avatar von picnerd

Anmeldungsdatum:
17. März 2016

Beiträge: 872

Heinrich_Schwietering schrieb:

Hi!

Hab rein formal (Syntax, Rechtschreibung, Zeichensetzung, tags etc.) einmal durchgeschliffen.

so long
hank

Herzlichen Dank für das Korrekturlesen und korrigieren. 👍 Ist mir sofort ins Auge gefallen.

mfg

Heinrich_Schwietering Team-Icon

Wikiteam
Avatar von Heinrich_Schwietering

Anmeldungsdatum:
12. November 2005

Beiträge: 11288

Hi!

Habe den Artikel verschoben - allerdings wäre vielleicht auch eine Einordnung unter systemd sinnvoll? Also systemd/localectl?

Zur Verlinkung: Momentan taucht es auf, wenn man in systemd den Link zu Artikelliste anklickt. Wo wäre es sonst noch sinnvoll? Spracheinstellungen, Tastatur?

Auf alle Fälle aber schon mal besten Dank an picnerd 👍

so long
hank

noisefloor Team-Icon

Ehemaliger
Avatar von noisefloor

Anmeldungsdatum:
6. Juni 2006

Beiträge: 28316

Hallo,

konsistent wäre es, wenn der Artikel systemd/localectl heißt und localectl ein Redirect auf ersteres wäre. So sind jedenfalls die anderen systemd-Artikel angelegt, AFAIR.

Gruß, noisefloor

Heinrich_Schwietering Team-Icon

Wikiteam
Avatar von Heinrich_Schwietering

Anmeldungsdatum:
12. November 2005

Beiträge: 11288

Hi!

OK, dann verändere ich das so.

so long
hank

picnerd

(Themenstarter)
Avatar von picnerd

Anmeldungsdatum:
17. März 2016

Beiträge: 872

Danke fürs verschieben. 😉

War jetzt kein Ding das erstellen. Ich bleibe aber noch dran am Thema da ich mich noch mit locale beschäftige. Der ist aber schon ein wenig schwieriger vom Aufbau und Themenumfang.

Einen Link im Artikel Spracheinstellungen fände ich jetzt auch irgendwie logisch vor allem da dort beim Einstellen der Tastatur nicht tiefer darauf eingegangen wird. Ich behalte es jedenfalls im Hinterkopf da auch in diesem Artikel locale angesprochen wird. Ich muss erst einmal den Input sortieren. 😀

mfg

BillMaier Team-Icon

Supporter

Anmeldungsdatum:
4. Dezember 2008

Beiträge: 6389

picnerd schrieb:

Einen Link im Artikel Spracheinstellungen fände ich jetzt auch irgendwie logisch vor allem da dort beim Einstellen der Tastatur nicht tiefer darauf eingegangen wird. Ich behalte es jedenfalls im Hinterkopf da auch in diesem Artikel locale angesprochen wird. Ich muss erst einmal den Input sortieren. 😀

👍 siehe https://forum.ubuntuusers.de/post/8928967/ 😉

picnerd

(Themenstarter)
Avatar von picnerd

Anmeldungsdatum:
17. März 2016

Beiträge: 872

BillMaier schrieb:

picnerd schrieb:

Einen Link im Artikel Spracheinstellungen fände ich jetzt auch irgendwie logisch vor allem da dort beim Einstellen der Tastatur nicht tiefer darauf eingegangen wird. Ich behalte es jedenfalls im Hinterkopf da auch in diesem Artikel locale angesprochen wird. Ich muss erst einmal den Input sortieren. 😀

👍 siehe https://forum.ubuntuusers.de/post/8928967/ 😉

Ähh, ja gerne aber wie stellst du dir jetzt die Kontrolle vor und wo soll ich den Link einbauen. Ach so, DANKE für das überarbeiten. 👍

mfg

seahawk1986

Anmeldungsdatum:
27. Oktober 2006

Beiträge: 10978

Ich habe eine kleine Anmerkung zur Hinweisbox aus dem Artikel:

Hinweis:

Einstellungen für die Konsole werden in /etc/vconsole.conf gespeichert. Falls vorhanden werden Einstellungen der Arbeitsumgebung in /etc/X11/xorg.conf.d/00-keyboard.conf gespeichert. Manuelle Änderungen an diesen Dateien werden beim nächsten Aufruf von localectl überschrieben.

Im Systemd-Quellpaket gibt es den Patch Update-localed-to-use-the-Debian-config-files.patch, der dafür sorgt, dass localectl die Keyboard-Einstellungen nach /etc/default/keyboard schreibt und die /etc/X11/xorg.conf.d/00-keyboard.conf nicht mehr anfasst:

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
From: Michael Biebl <biebl@debian.org>
Date: Thu, 18 Jul 2013 20:18:31 +0200
Subject: Update localed to use the Debian config files

Prefer /etc/default/locale over /etc/locale.conf when writing the locale
configuration and use /etc/default/keyboard instead of
/etc/X11/xorg.conf.d/00-keyboard.conf.

Patch courtesy of Steve Langasek.
---
 src/locale/localed.c | 205 ++++++++++++++++++++++++++-------------------------
 1 file changed, 106 insertions(+), 99 deletions(-)

diff --git a/src/locale/localed.c b/src/locale/localed.c
index f0fe59c..236fba7 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -163,6 +163,24 @@ static int locale_read_data(Context *c) {
                            "LC_IDENTIFICATION", &c->locale[LOCALE_LC_IDENTIFICATION],
                            NULL);
 
+        if (r == -ENOENT)
+                r = parse_env_file("/etc/default/locale", NEWLINE,
+                                   "LANG",              &c->locale[LOCALE_LANG],
+                                   "LANGUAGE",          &c->locale[LOCALE_LANGUAGE],
+                                   "LC_CTYPE",          &c->locale[LOCALE_LC_CTYPE],
+                                   "LC_NUMERIC",        &c->locale[LOCALE_LC_NUMERIC],
+                                   "LC_TIME",           &c->locale[LOCALE_LC_TIME],
+                                   "LC_COLLATE",        &c->locale[LOCALE_LC_COLLATE],
+                                   "LC_MONETARY",       &c->locale[LOCALE_LC_MONETARY],
+                                   "LC_MESSAGES",       &c->locale[LOCALE_LC_MESSAGES],
+                                   "LC_PAPER",          &c->locale[LOCALE_LC_PAPER],
+                                   "LC_NAME",           &c->locale[LOCALE_LC_NAME],
+                                   "LC_ADDRESS",        &c->locale[LOCALE_LC_ADDRESS],
+                                   "LC_TELEPHONE",      &c->locale[LOCALE_LC_TELEPHONE],
+                                   "LC_MEASUREMENT",    &c->locale[LOCALE_LC_MEASUREMENT],
+                                   "LC_IDENTIFICATION", &c->locale[LOCALE_LC_IDENTIFICATION],
+                                   NULL);
+
         if (r == -ENOENT) {
                 int p;
 
@@ -200,67 +218,17 @@ static int vconsole_read_data(Context *c) {
 }
 
 static int x11_read_data(Context *c) {
-        _cleanup_fclose_ FILE *f;
-        char line[LINE_MAX];
-        bool in_section = false;
         int r;
 
         context_free_x11(c);
 
-        f = fopen("/etc/X11/xorg.conf.d/00-keyboard.conf", "re");
-        if (!f)
-                return errno == ENOENT ? 0 : -errno;
-
-        while (fgets(line, sizeof(line), f)) {
-                char *l;
-
-                char_array_0(line);
-                l = strstrip(line);
-
-                if (l[0] == 0 || l[0] == '#')
-                        continue;
-
-                if (in_section && first_word(l, "Option")) {
-                        _cleanup_strv_free_ char **a = NULL;
-
-                        r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
-                        if (r < 0)
-                                return r;
-
-                        if (strv_length(a) == 3) {
-                                char **p = NULL;
-
-                                if (streq(a[1], "XkbLayout"))
-                                        p = &c->x11_layout;
-                                else if (streq(a[1], "XkbModel"))
-                                        p = &c->x11_model;
-                                else if (streq(a[1], "XkbVariant"))
-                                        p = &c->x11_variant;
-                                else if (streq(a[1], "XkbOptions"))
-                                        p = &c->x11_options;
-
-                                if (p) {
-                                        free(*p);
-                                        *p = a[2];
-                                        a[2] = NULL;
-                                }
-                        }
-
-                } else if (!in_section && first_word(l, "Section")) {
-                        _cleanup_strv_free_ char **a = NULL;
-
-                        r = strv_split_extract(&a, l, WHITESPACE, EXTRACT_QUOTES);
-                        if (r < 0)
-                                return -ENOMEM;
-
-                        if (strv_length(a) == 2 && streq(a[1], "InputClass"))
-                                in_section = true;
-
-                } else if (in_section && first_word(l, "EndSection"))
-                        in_section = false;
-        }
-
-        return 0;
+        r = parse_env_file("/etc/default/keyboard", NEWLINE,
+                           "XKBMODEL",          &c->x11_model,
+                           "XKBLAYOUT",         &c->x11_layout,
+                           "XKBVARIANT",        &c->x11_variant,
+                           "XKBOPTIONS",        &c->x11_options,
+                           NULL);
+        return r;
 }
 
 static int context_read_data(Context *c) {
@@ -276,10 +244,15 @@ static int context_read_data(Context *c) {
 static int locale_write_data(Context *c, char ***settings) {
         int r, p;
         _cleanup_strv_free_ char **l = NULL;
+        const char *path = "/etc/locale.conf";
 
         /* Set values will be returned as strv in *settings on success. */
 
-        r = load_env_file(NULL, "/etc/locale.conf", NULL, &l);
+        r = load_env_file(NULL, path, NULL, &l);
+        if (r < 0 && r == -ENOENT) {
+                path = "/etc/default/locale";
+                r = load_env_file(NULL, path, NULL, &l);
+        }
         if (r < 0 && r != -ENOENT)
                 return r;
 
@@ -306,13 +279,13 @@ static int locale_write_data(Context *c, char ***settings) {
         }
 
         if (strv_isempty(l)) {
-                if (unlink("/etc/locale.conf") < 0)
+                if (unlink(path) < 0)
                         return errno == ENOENT ? 0 : -errno;
 
                 return 0;
         }
 
-        r = write_env_file_label("/etc/locale.conf", l);
+        r = write_env_file_label(path, l);
         if (r < 0)
                 return r;
 
@@ -433,65 +406,99 @@ static int vconsole_write_data(Context *c) {
 }
 
 static int x11_write_data(Context *c) {
-        _cleanup_fclose_ FILE *f = NULL;
-        _cleanup_free_ char *temp_path = NULL;
         int r;
+        char *t, **u, **l = NULL;
 
-        if (isempty(c->x11_layout) &&
-            isempty(c->x11_model) &&
-            isempty(c->x11_variant) &&
-            isempty(c->x11_options)) {
+        r = load_env_file(NULL, "/etc/default/keyboard", NULL, &l);
+        if (r < 0 && r != -ENOENT)
+                return r;
 
-                if (unlink("/etc/X11/xorg.conf.d/00-keyboard.conf") < 0)
-                        return errno == ENOENT ? 0 : -errno;
+        /* This could perhaps be done more elegantly using an array
+         * like we do for the locale, instead of struct
+         */
+        if (isempty(c->x11_layout)) {
+                l = strv_env_unset(l, "XKBLAYOUT");
+        } else {
+                if (asprintf(&t, "XKBLAYOUT=%s", c->x11_layout) < 0) {
+                        strv_free(l);
+                        return -ENOMEM;
+                }
 
-                return 0;
+                u = strv_env_set(l, t);
+                free(t);
+                strv_free(l);
+
+                if (!u)
+                        return -ENOMEM;
+
+                l = u;
         }
 
-        mkdir_p_label("/etc/X11/xorg.conf.d", 0755);
+        if (isempty(c->x11_model)) {
+                l = strv_env_unset(l, "XKBMODEL");
+        } else {
+                if (asprintf(&t, "XKBMODEL=%s", c->x11_model) < 0) {
+                        strv_free(l);
+                        return -ENOMEM;
+                }
 
-        r = fopen_temporary("/etc/X11/xorg.conf.d/00-keyboard.conf", &f, &temp_path);
-        if (r < 0)
-                return r;
+                u = strv_env_set(l, t);
+                free(t);
+                strv_free(l);
 
-        fchmod(fileno(f), 0644);
+                if (!u)
+                        return -ENOMEM;
 
-        fputs("# Read and parsed by systemd-localed. It's probably wise not to edit this file\n"
-              "# manually too freely.\n"
-              "Section \"InputClass\"\n"
-              "        Identifier \"system-keyboard\"\n"
-              "        MatchIsKeyboard \"on\"\n", f);
+                l = u;
+        }
 
-        if (!isempty(c->x11_layout))
-                fprintf(f, "        Option \"XkbLayout\" \"%s\"\n", c->x11_layout);
+        if (isempty(c->x11_variant)) {
+                l = strv_env_unset(l, "XKBVARIANT");
+        } else {
+                if (asprintf(&t, "XKBVARIANT=%s", c->x11_variant) < 0) {
+                        strv_free(l);
+                        return -ENOMEM;
+                }
 
-        if (!isempty(c->x11_model))
-                fprintf(f, "        Option \"XkbModel\" \"%s\"\n", c->x11_model);
+                u = strv_env_set(l, t);
+                free(t);
+                strv_free(l);
 
-        if (!isempty(c->x11_variant))
-                fprintf(f, "        Option \"XkbVariant\" \"%s\"\n", c->x11_variant);
+                if (!u)
+                        return -ENOMEM;
 
-        if (!isempty(c->x11_options))
-                fprintf(f, "        Option \"XkbOptions\" \"%s\"\n", c->x11_options);
+                l = u;
+        }
+
+        if (isempty(c->x11_options)) {
+                l = strv_env_unset(l, "XKBOPTIONS");
+        } else {
+                if (asprintf(&t, "XKBOPTIONS=%s", c->x11_options) < 0) {
+                        strv_free(l);
+                        return -ENOMEM;
+                }
 
-        fputs("EndSection\n", f);
+                u = strv_env_set(l, t);
+                free(t);
+                strv_free(l);
 
-        r = fflush_and_check(f);
-        if (r < 0)
-                goto fail;
+                if (!u)
+                        return -ENOMEM;
 
-        if (rename(temp_path, "/etc/X11/xorg.conf.d/00-keyboard.conf") < 0) {
-                r = -errno;
-                goto fail;
+                l = u;
         }
 
-        return 0;
+        if (strv_isempty(l)) {
+                strv_free(l);
+
+                if (unlink("/etc/default/keyboard") < 0)
+                        return errno == ENOENT ? 0 : -errno;
 
-fail:
-        (void) unlink("/etc/X11/xorg.conf.d/00-keyboard.conf);
+                return 0;
+        }
 
-        if (temp_path)
-                (void) unlink(temp_path);
+        r = write_env_file("/etc/default/keyboard", l);
+        strv_free(l);
 
         return r;
 }

picnerd

(Themenstarter)
Avatar von picnerd

Anmeldungsdatum:
17. März 2016

Beiträge: 872

Danke für den Hinweis seahawk1986.

Ich würde die Hinweisbox dann dahin gehend ändern.

Hinweis:

Manuelle Änderungen können in einer selbst erstellten Datei /etc/locale.conf vorgenommen werden. Manuelle Änderungen in der oft noch empfohlenen selbst erstellten Datei /etc/X11/xorg.conf.d/00-keyboard.conf werden vollständig ignoriert. Beim nächsten Aufruf von localectl werden manuelle Änderungen an den Dateien /etc/vconsole.conf und /etc/default/locale überschrieben.

Wäre das OK?

mfg

Antworten |