2021-11-13 21:56:53 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2023-05-13 16:10:33 +03:00
|
|
|
#ifndef LABWC_SESSION_H
|
|
|
|
|
#define LABWC_SESSION_H
|
2020-10-08 20:50:20 +01:00
|
|
|
|
2024-03-03 15:04:24 -05:00
|
|
|
struct server;
|
|
|
|
|
|
2024-07-20 04:40:11 -04:00
|
|
|
/**
|
|
|
|
|
* session_run_script - run a named session script (or, in merge-config mode,
|
|
|
|
|
* all named session scripts) from the XDG path.
|
|
|
|
|
*/
|
|
|
|
|
void session_run_script(const char *script);
|
|
|
|
|
|
2020-10-08 20:50:20 +01:00
|
|
|
/**
|
2024-03-08 21:59:20 +09:00
|
|
|
* session_environment_init - set environment variables based on <key>=<value>
|
|
|
|
|
* pairs in `${XDG_CONFIG_DIRS:-/etc/xdg}/labwc/environment` with user override
|
2021-03-18 19:39:08 +00:00
|
|
|
* in `${XDG_CONFIG_HOME:-$HOME/.config}`
|
2020-10-08 20:50:20 +01:00
|
|
|
*/
|
config: support merging multiple config files
Add the -m|--merge-config command line option to iterate backwards over
XDG Base Dir paths and read config/theme files multiple times.
For example if both ~/.config/labwc/rc.xml and /etc/xdg/labwc/rc.xml
exist, the latter will be read first and then the former (if
--merge-config is enabled).
When $XDG_CONFIG_HOME is defined, make it replace (not augment)
$HOME/.config. Similarly, make $XDG_CONFIG_DIRS replace /etc/xdg when
defined.
XDG Base Dir Spec does not specify whether or not an application (or a
compositor!) should (a) define that only the file under the most important
base directory should be used, or (b) define rules for merging the
information from the different files.
ref: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
In the case of labwc there is a use-case for both positions, just to be
clear, the default behaviour, described by position (a) above, does NOT
change.
This change affects the following config/theme files:
- rc.xml
- menu.xml
- autostart
- environment
- themerc
- themerc-override
- Theme buttons, for example max.xbm
Instead of caching global config/theme directories, create lists of paths
(e.g. '/home/foo/.config/labwc/rc.xml', '/etc/xdg/labwc/rc.xml', etc).
This creates more common parsing logic and just reversing the direction
of iteration and breaks early if config-merge is not wanted.
Enable better fallback for themes. For example if a particular theme does
not exist in $HOME/.local/share/themes, it will be searched for in
~/.themes/ and so on. This also applies to theme buttons which now
fallback on an individual basis.
Avoid using stat() in most situations and just go straight to fopen().
Fixes #1406
2024-01-09 22:00:45 +00:00
|
|
|
void session_environment_init(void);
|
2020-10-08 20:50:20 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* session_autostart_init - run autostart file as shell script
|
|
|
|
|
* Note: Same as `sh ~/.config/labwc/autostart` (or equivalent XDG config dir)
|
|
|
|
|
*/
|
tree-wide: auto-replace of (struct server *)
#!/bin/bash
read -r -d '' EXPRS << EOF
s/xwayland->server/xwayland->svr/g;
s/\t*struct server \*server;\n//g;
s/\t*struct server \*server =.*?;\n//gs;
s/\t*.* = ([a-z_]*->)*server[;,]\n//g;
s/\{\n\n/\{\n/g;
s/\n\n+/\n\n/g;
s/\(\s*struct server \*server\)/(void)/g;
s/\(\s*struct server \*server,\s*/(/g;
s/,\s*struct server \*server\)/)/g;
s/,\s*struct server \*server,\s*/, /g;
s/\(\s*([a-z_]*->)*server\)/()/g;
s/\(\s*([a-z_]*->)*server,\s*/(/g;
s/,\s*([a-z_]*->)*server\)/)/g;
s/,\s*([a-z_]*->)*server,\s*/, /g;
s/([a-z_]*->)*server->/g_server./g;
s/xwayland->svr/xwayland->server/g;
EOF
find src include \( -name \*.c -o -name \*.h \) -exec \
perl -0777 -i -pe "$EXPRS" \{\} \;
2026-02-23 11:56:39 -05:00
|
|
|
void session_autostart_init(void);
|
2020-10-08 20:50:20 +01:00
|
|
|
|
2024-02-18 12:23:14 -05:00
|
|
|
/**
|
|
|
|
|
* session_shutdown - run session shutdown file as shell script
|
|
|
|
|
* Note: Same as `sh ~/.config/labwc/shutdown` (or equivalent XDG config dir)
|
|
|
|
|
*/
|
tree-wide: auto-replace of (struct server *)
#!/bin/bash
read -r -d '' EXPRS << EOF
s/xwayland->server/xwayland->svr/g;
s/\t*struct server \*server;\n//g;
s/\t*struct server \*server =.*?;\n//gs;
s/\t*.* = ([a-z_]*->)*server[;,]\n//g;
s/\{\n\n/\{\n/g;
s/\n\n+/\n\n/g;
s/\(\s*struct server \*server\)/(void)/g;
s/\(\s*struct server \*server,\s*/(/g;
s/,\s*struct server \*server\)/)/g;
s/,\s*struct server \*server,\s*/, /g;
s/\(\s*([a-z_]*->)*server\)/()/g;
s/\(\s*([a-z_]*->)*server,\s*/(/g;
s/,\s*([a-z_]*->)*server\)/)/g;
s/,\s*([a-z_]*->)*server,\s*/, /g;
s/([a-z_]*->)*server->/g_server./g;
s/xwayland->svr/xwayland->server/g;
EOF
find src include \( -name \*.c -o -name \*.h \) -exec \
perl -0777 -i -pe "$EXPRS" \{\} \;
2026-02-23 11:56:39 -05:00
|
|
|
void session_shutdown(void);
|
2024-02-18 12:23:14 -05:00
|
|
|
|
2023-05-13 16:10:33 +03:00
|
|
|
#endif /* LABWC_SESSION_H */
|