/*
* rofi
*
* MIT/X11 License
* Copyright © 2013-2021 Qball Cow <qball@gmpclient.org>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
/** Log domain for this module */
#define G_LOG_DOMAIN "XrmOptions"
#include "xrmoptions.h"
#include "helper.h"
#include "rofi-types.h"
#include "rofi.h"
#include "settings.h"
#include "xcb-internal.h"
#include "xcb.h"
#include <ctype.h>
#include <glib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/xkb.h>
ThemeWidget *rofi_configuration = NULL;
/** Different sources of configuration. */
const char *const ConfigSourceStr[] = {
"Default",
"File",
"Rasi File",
"Commandline",
};
/** Enumerator of different sources of configuration. */
enum ConfigSource {
CONFIG_DEFAULT = 0,
CONFIG_FILE = 1,
CONFIG_FILE_THEME = 2,
CONFIG_CMDLINE = 3
};
typedef struct {
int type;
const char *name;
union {
unsigned int *num;
int *snum;
char **str;
void *pointer;
char *charc;
} value;
char *mem;
const char *comment;
enum ConfigSource source;
} XrmOption;
/**
* Map X resource and commandline options to internal options
* Currently supports string, boolean and number (signed and unsigned).
*/
static XrmOption xrmOptions[] = {
{xrm_String, "switchers", {.str = &config.modi}, NULL, "", CONFIG_DEFAULT},
{xrm_String,
"modi",
{.str = &config.modi},
NULL,
"Enabled modi",
CONFIG_DEFAULT},
{xrm_String,
"font",
{.str = &config.menu_font},
NULL,
"Font to use",
CONFIG_DEFAULT},
{xrm_Number,
"location",
{.num = &config.location},
NULL,
"Location on screen",
CONFIG_DEFAULT},
{xrm_SNumber,
"yoffset",
{.snum = &config.y_offset},
NULL,
"Y-offset relative to location",
CONFIG_DEFAULT},
{xrm_SNumber,
"xoffset",
{.snum = &config.x_offset},
NULL,
"X-offset relative to location",
CONFIG_DEFAULT},
{xrm_Boolean,
"fixed-num-lines",
{.num = &config.fixed_num_lines},
NULL,
"Always show number of lines",
CONFIG_DEFAULT},
{xrm_Boolean,
"show-icons",
{.snum = &config.show_icons},
NULL,
"Whether to load and show icons",
CONFIG_DEFAULT},
{xrm_String,
"terminal",
{.str = &config.terminal_emulator},
NULL,
"Terminal to use",
CONFIG_DEFAULT},
{xrm_String,
"ssh-client",
{.str = &config.ssh_client},
NULL,
"Ssh client to use",
CONFIG_DEFAULT},
{xrm_String,
"ssh-command",
{.str = &config.ssh_command},
NULL,
"Ssh command to execute",
CONFIG_DEFAULT},
{xrm_String,
"run-command",
{.str = &config.run_command},
NULL,
"Run command to execute",
CONFIG_DEFAULT},
{xrm_String,
"run-list-command",
{.str = &config.run_list_command},
NULL,
"Command to get extra run targets",
CONFIG_DEFAULT},
{xrm_String,
"run-shell-command",
{.str = &config.run_shell_command},
NULL,
"Run command to execute that runs in shell",
CONFIG_DEFAULT},
{xrm_String,
"window-command",
{.str = &config.window_command},
NULL,
"Command to executed when -kb-accept-alt binding is hit on selected "
"window ",
CONFIG_DEFAULT},
{xrm_String,
"window-match-fields",
{.