/*
* rofi
*
* MIT/X11 License
* Copyright © 2013-2022 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", "Don't Display"};
/** Enumerator of different sources of configuration. */
enum ConfigSource {
CONFIG_DEFAULT = 0,
CONFIG_FILE = 1,
CONFIG_FILE_THEME = 2,
CONFIG_CMDLINE = 3,
CONFIG_NO_DISPLAY = 4
};
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.modes}, NULL, "", CONFIG_DEFAULT},
{xrm_String,
"modi",
{.str = &config.modes},
NULL,
"Enabled modes",
CONFIG_DEFAULT},
{xrm_String,
"modes",
{.str = &config.modes},
NULL,
"Enable modes",
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. *DEPRECATED* see rofi-theme manpage for "
"new option",
CONFIG_DEFAULT},
{xrm_SNumber,
"xoffset",
{.snum = &config.x_offset},
NULL,
"X-offset relative to location. *DEPRECATED* see rofi-theme manpage for "
"new option",
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",