cursor: make xcursor theme configurable

- add a new command to set the theme
- export the theme of the default seat through environment variables
This commit is contained in:
Isaac Freund
2020-07-14 17:34:29 +02:00
parent f3d4e5ac53
commit 6bdb152808
4 changed files with 100 additions and 30 deletions

View File

@ -0,0 +1,38 @@
// This file is part of river, a dynamic tiling wayland compositor.
//
// Copyright 2020 Isaac Freund
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
const std = @import("std");
const Error = @import("../command.zig").Error;
const Seat = @import("../Seat.zig");
pub fn xcursorTheme(
allocator: *std.mem.Allocator,
seat: *Seat,
args: []const []const u8,
out: *?[]const u8,
) Error!void {
if (args.len < 2) return Error.NotEnoughArguments;
if (args.len > 3) return Error.TooManyArguments;
// TODO: get rid of this allocation
const name = try std.cstr.addNullByte(allocator, args[1]);
defer allocator.free(name);
const size = if (args.len == 3) try std.fmt.parseInt(u32, args[2], 10) else null;
try seat.cursor.setTheme(name, size);
}