localectl.c revision 3ffd4af22052963e7a29431721ee204e634bea75
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore This file is part of systemd.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore Copyright 2012 Lennart Poettering
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore Copyright 2013 Kay Sievers
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore systemd is free software; you can redistribute it and/or modify it
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore under the terms of the GNU Lesser General Public License as published by
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore the Free Software Foundation; either version 2.1 of the License, or
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore (at your option) any later version.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore systemd is distributed in the hope that it will be useful, but
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore WITHOUT ANY WARRANTY; without even the implied warranty of
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore Lesser General Public License for more details.
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore You should have received a copy of the GNU Lesser General Public License
538aa54d819fa7751ca82bcc30d4ed8c57ec2ef2Garrett D'Amore along with systemd; If not, see <http://www.gnu.org/licenses/>.
#include <ftw.h>
#include <getopt.h>
#include <locale.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "sd-bus.h"
#include "bus-error.h"
#include "bus-util.h"
#include "def.h"
#include "fd-util.h"
#include "fileio.h"
#include "locale-util.h"
#include "pager.h"
#include "set.h"
#include "spawn-polkit-agent.h"
#include "strv.h"
#include "util.h"
#include "virt.h"
static bool arg_no_pager = false;
static bool arg_ask_password = true;
static bool arg_convert = true;
static void pager_open_if_enabled(void) {
if (arg_no_pager)
pager_open(false);
static void polkit_agent_open_if_enabled(void) {
if (!arg_ask_password)
typedef struct StatusInfo {
char **locale;
char *vconsole_keymap;
char *vconsole_keymap_toggle;
char *x11_layout;
char *x11_model;
char *x11_variant;
char *x11_options;
} StatusInfo;
if (info) {
static void print_overridden_variables(void) {
bool print_warning = true;
NULL);
if (r < 0 && r != -ENOENT) {
goto finish;
for (j = 0; j < _VARIABLE_LC_MAX; j++)
if (variables[j]) {
if (print_warning) {
log_warning("Warning: Settings on kernel command line override system locale settings in /etc/locale.conf.\n"
print_warning = false;
for (j = 0; j < _VARIABLE_LC_MAX; j++)
assert(i);
"/org/freedesktop/locale1",
map,
&info);
bus,
"/org/freedesktop/locale1",
return bus_log_create_error(r);
return bus_log_create_error(r);
return bus_log_create_error(r);
r = get_locales(&l);
strv_print(l);
return -EINVAL;
r = sd_bus_call_method(
bus,
"/org/freedesktop/locale1",
&error,
NULL,
static int nftw_cb(
const char *fpath,
int tflag,
return log_oom();
if (r < 0 && r != -EEXIST)
const char *dir;
if (!keymaps)
return log_oom();
return log_oom();
if (strv_isempty(l)) {
return -ENOENT;
strv_sort(l);
strv_print(l);
return -EINVAL;
r = sd_bus_call_method(
bus,
"/org/freedesktop/locale1",
&error,
NULL,
NONE,
return -EINVAL;
if (isempty(l))
return log_oom();
return -ENOENT;
static void help(void) {
help();
case ARG_VERSION:
return version();
case ARG_NO_CONVERT:
arg_convert = false;
case ARG_NO_PAGER:
arg_no_pager = true;
case ARG_NO_ASK_PASSWORD:
arg_ask_password = false;
return -EINVAL;
const char* verb;
MORE,
LESS,
} argc_cmp;
const int argc;
} verbs[] = {
int left;
if (left <= 0)
help();
return -EINVAL;
case EQUAL:
return -EINVAL;
case MORE:
return -EINVAL;
case LESS:
return -EINVAL;
log_open();
goto finish;
goto finish;
pager_close();