river: remove system /etc dir from init search paths
A true "default" config doesn't make sense for river. Everyone who uses river seriously will customize their init script. Futhermore, the current behavior of embedding the install path of the default system config in the river binary is complex and prone to breaking.
This commit is contained in:
parent
28fc8792d7
commit
0063c722e5
4 changed files with 38 additions and 56 deletions
26
README.md
26
README.md
|
@ -10,11 +10,11 @@ and missing features. If you run into a bug don't hesitate to
|
||||||
|
|
||||||
## Design goals
|
## Design goals
|
||||||
|
|
||||||
- Simplicity and minimalism, river should not overstep the bounds of a
|
- Simple and predictable behavior, river should be easy to use and have a
|
||||||
window manager.
|
low cognitive load.
|
||||||
- Window management based on a stack of views and tags.
|
- Window management based on a stack of views and tags.
|
||||||
- Dynamic layouts generated by external, user-written executables. (A default
|
- Dynamic layouts generated by external, user-written executables. A default
|
||||||
`rivertile` layout generator is provided.)
|
`rivertile` layout generator is provided.
|
||||||
- Scriptable configuration and control through a custom wayland protocol and
|
- Scriptable configuration and control through a custom wayland protocol and
|
||||||
separate `riverctl` binary implementing it.
|
separate `riverctl` binary implementing it.
|
||||||
|
|
||||||
|
@ -53,20 +53,18 @@ To enable experimental Xwayland support pass the `-Dxwayland` option as well.
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
River can either be run nested in an X11/wayland session or directly
|
River can either be run nested in an X11/wayland session or directly
|
||||||
from a tty using KMS/DRM.
|
from a tty using KMS/DRM. Simply run the `river` command.
|
||||||
|
|
||||||
On startup river will look for and run an **executable** file at one of the
|
On startup river will run an executable file at `$XDG_CONFIG_HOME/river/init`
|
||||||
following locations, checked in the order listed:
|
if such an executable exists. If $XDG_CONFIG_HOME is not set, ~/.config/ will
|
||||||
|
be used instead.
|
||||||
|
|
||||||
- `$XDG_CONFIG_HOME/river/init`
|
Usually this executable is a shell script invoking *riverctl*(1) to create
|
||||||
- `$HOME/.config/river/init`
|
mappings, start programs such as a layout generator or status bar, and
|
||||||
- `/etc/river/init`
|
preform other configuration.
|
||||||
|
|
||||||
Usually this executable init file will be a shell script invoking riverctl
|
|
||||||
to create mappings and preform other configuration.
|
|
||||||
|
|
||||||
An example init script with sane defaults is provided [here](example/init)
|
An example init script with sane defaults is provided [here](example/init)
|
||||||
in the example directory and installed to `/etc/river/init`.
|
in the example directory.
|
||||||
|
|
||||||
For complete documentation see the `river(1)`, `riverctl(1)`, and
|
For complete documentation see the `river(1)`, `riverctl(1)`, and
|
||||||
`rivertile(1)` man pages.
|
`rivertile(1)` man pages.
|
||||||
|
|
|
@ -48,14 +48,6 @@ pub fn build(b: *zbs.Builder) !void {
|
||||||
|
|
||||||
const examples = b.option(bool, "examples", "Set to true to build examples") orelse false;
|
const examples = b.option(bool, "examples", "Set to true to build examples") orelse false;
|
||||||
|
|
||||||
const rel_config_path = if (mem.eql(u8, try fs.path.resolve(b.allocator, &[_][]const u8{b.install_prefix}), "/usr"))
|
|
||||||
"../etc/river/init"
|
|
||||||
else
|
|
||||||
"etc/river/init";
|
|
||||||
b.installFile("example/init", rel_config_path);
|
|
||||||
const abs_config_path = try fs.path.resolve(b.allocator, &[_][]const u8{ b.install_prefix, rel_config_path });
|
|
||||||
assert(fs.path.isAbsolute(abs_config_path));
|
|
||||||
|
|
||||||
const scanner = ScanProtocolsStep.create(b);
|
const scanner = ScanProtocolsStep.create(b);
|
||||||
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
|
scanner.addSystemProtocol("stable/xdg-shell/xdg-shell.xml");
|
||||||
scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml");
|
scanner.addSystemProtocol("unstable/pointer-gestures/pointer-gestures-unstable-v1.xml");
|
||||||
|
@ -72,7 +64,6 @@ pub fn build(b: *zbs.Builder) !void {
|
||||||
river.setTarget(target);
|
river.setTarget(target);
|
||||||
river.setBuildMode(mode);
|
river.setBuildMode(mode);
|
||||||
river.addBuildOption(bool, "xwayland", xwayland);
|
river.addBuildOption(bool, "xwayland", xwayland);
|
||||||
river.addBuildOption([]const u8, "default_config_path", abs_config_path);
|
|
||||||
|
|
||||||
addServerDeps(river, scanner);
|
addServerDeps(river, scanner);
|
||||||
|
|
||||||
|
|
|
@ -32,19 +32,17 @@ utility may be used to communicate with river over these protocols.
|
||||||
|
|
||||||
# CONFIGURATION
|
# CONFIGURATION
|
||||||
|
|
||||||
On startup river will look for and run an executable file at one of the
|
On startup river will run an executable file at `$XDG_CONFIG_HOME/river/init`
|
||||||
following locations, checked in the order listed:
|
if such an executable exists. If $XDG_CONFIG_HOME is not set, ~/.config/ will
|
||||||
|
be used instead.
|
||||||
- $XDG_CONFIG_HOME/river/init
|
|
||||||
- $HOME/.config/river/init
|
|
||||||
- /etc/river/init
|
|
||||||
|
|
||||||
The executable init file will be run as a process group leader after river's
|
The executable init file will be run as a process group leader after river's
|
||||||
wayland server is initialized but before entering the main loop. On exit,
|
wayland server is initialized but before entering the main loop. On exit,
|
||||||
river will send SIGTERM to this process group.
|
river will send SIGTERM to this process group.
|
||||||
|
|
||||||
Usually this will be a shell script invoking *riverctl*(1) to create mappings,
|
Usually this executable is a shell script invoking *riverctl*(1) to create
|
||||||
start programs such as a status bar, and preform other configuration.
|
mappings, start programs such as a layout generator or status bar, and
|
||||||
|
preform other configuration.
|
||||||
|
|
||||||
# ENVIRONMENT
|
# ENVIRONMENT
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
const fs = std.fs;
|
||||||
const os = std.os;
|
const os = std.os;
|
||||||
const wlr = @import("wlroots");
|
const wlr = @import("wlroots");
|
||||||
|
|
||||||
|
@ -86,9 +87,7 @@ pub fn main() anyerror!void {
|
||||||
.warn, .err, .crit, .alert, .emerg => .err,
|
.warn, .err, .crit, .alert, .emerg => .err,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (startup_command == null) {
|
if (startup_command == null) startup_command = try defaultInitPath();
|
||||||
if (try getStartupCommand()) |path| startup_command = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
std.log.info("initializing server", .{});
|
std.log.info("initializing server", .{});
|
||||||
try server.init();
|
try server.init();
|
||||||
|
@ -99,7 +98,7 @@ pub fn main() anyerror!void {
|
||||||
// Run the child in a new process group so that we can send SIGTERM to all
|
// Run the child in a new process group so that we can send SIGTERM to all
|
||||||
// descendants on exit.
|
// descendants on exit.
|
||||||
const child_pgid = if (startup_command) |cmd| blk: {
|
const child_pgid = if (startup_command) |cmd| blk: {
|
||||||
std.log.info("running startup command '{s}'", .{cmd});
|
std.log.info("running init executable '{s}'", .{cmd});
|
||||||
const child_args = [_:null]?[*:0]const u8{ "/bin/sh", "-c", cmd, null };
|
const child_args = [_:null]?[*:0]const u8{ "/bin/sh", "-c", cmd, null };
|
||||||
const pid = try os.fork();
|
const pid = try os.fork();
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
|
@ -111,8 +110,9 @@ pub fn main() anyerror!void {
|
||||||
// Since the child has called setsid, the pid is the pgid
|
// Since the child has called setsid, the pid is the pgid
|
||||||
break :blk pid;
|
break :blk pid;
|
||||||
} else null;
|
} else null;
|
||||||
defer if (child_pgid) |pgid|
|
defer if (child_pgid) |pgid| os.kill(-pgid, os.SIGTERM) catch |err| {
|
||||||
os.kill(-pgid, os.SIGTERM) catch |e| std.log.err("failed to kill startup process: {s}", .{e});
|
std.log.err("failed to kill init process group: {s}", .{@errorName(err)});
|
||||||
|
};
|
||||||
|
|
||||||
std.log.info("running server", .{});
|
std.log.info("running server", .{});
|
||||||
|
|
||||||
|
@ -127,29 +127,24 @@ fn printErrorExit(comptime format: []const u8, args: anytype) noreturn {
|
||||||
os.exit(1);
|
os.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn testConfigPath(comptime fmt: []const u8, args: anytype) std.fmt.AllocPrintError!?[:0]const u8 {
|
fn defaultInitPath() !?[:0]const u8 {
|
||||||
const path = try std.fmt.allocPrintZ(util.gpa, fmt, args);
|
const path = blk: {
|
||||||
os.access(path, os.X_OK) catch {
|
if (os.getenv("XDG_CONFIG_HOME")) |xdg_config_home| {
|
||||||
|
break :blk try fs.path.joinZ(util.gpa, &[_][]const u8{ xdg_config_home, "river/init" });
|
||||||
|
} else if (os.getenv("HOME")) |home| {
|
||||||
|
break :blk try fs.path.joinZ(util.gpa, &[_][]const u8{ home, ".config/river/init" });
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
os.accessZ(path, os.X_OK) catch |err| {
|
||||||
|
std.log.err("failed to run init executable {s}: {s}", .{ path, @errorName(err) });
|
||||||
util.gpa.free(path);
|
util.gpa.free(path);
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
return path;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn getStartupCommand() std.fmt.AllocPrintError!?[:0]const u8 {
|
|
||||||
if (os.getenv("XDG_CONFIG_HOME")) |xdg_config_home| {
|
|
||||||
if (try testConfigPath("{s}/river/init", .{xdg_config_home})) |path| {
|
|
||||||
return path;
|
return path;
|
||||||
}
|
|
||||||
} else if (os.getenv("HOME")) |home| {
|
|
||||||
if (try testConfigPath("{s}/.config/river/init", .{home})) |path| {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (try testConfigPath(build_options.default_config_path, .{})) |path| {
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log(
|
pub fn log(
|
||||||
|
|
Loading…
Reference in a new issue