vinput update

This commit is contained in:
LordMZTE 2022-10-17 18:44:31 +02:00
parent 922c4d06bd
commit 3ec44ef835
Signed by: LordMZTE
GPG key ID: B64802DC33A64FF6
4 changed files with 17 additions and 9 deletions

View file

@ -62,8 +62,8 @@ bindsym $mod+Ctrl+e exec thunar
bindsym $mod+Ctrl+b exec luakit
# vinput
bindsym $mod+Ctrl+v exec vinput
for_window [class="vinput-neovide"] floating enable
bindsym $mod+Ctrl+v exec vinput md
for_window [class="vinput-editor"] floating enable
# kill focused window
bindsym $mod+Shift+q kill

View file

@ -1,2 +1,3 @@
local g = vim.g
g.markdown_composer_syntax_theme = "dracula"
g.markdown_composer_autostart = not vim.g.started_by_vinput;

View file

@ -5,8 +5,7 @@ const c = ffi.c;
const log = std.log.scoped(.clipboard);
/// Provides the given data to the X clipboard ONCE
pub fn provideClipboard(data: []const u8, alloc: std.mem.Allocator) !void {
_ = alloc;
pub fn provideClipboard(data: []const u8) !void {
const dpy = c.XOpenDisplay(
c.getenv("DISPLAY") orelse return error.DisplayNotSet,
) orelse return error.OpenDisplay;

View file

@ -7,12 +7,20 @@ pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
if (std.os.argv.len == 1 or std.os.argv.len > 2) {
std.log.err(
\\ Invalid usage.
\\ Usage: {s} FILE_EXTENSION
, .{std.os.argv[0]});
return error.InvalidCli;
}
var alloc = gpa.allocator();
const filename = try std.fmt.allocPrint(
alloc,
"/tmp/vinput{}-{}",
.{ std.os.linux.getuid(), std.time.milliTimestamp() },
"/tmp/vinput{}-{}.{s}",
.{ std.os.linux.getuid(), std.time.milliTimestamp(), std.os.argv[1] },
);
defer alloc.free(filename);
@ -20,14 +28,14 @@ pub fn main() !void {
// "neovide",
// "--nofork",
// "--x11-wm-class",
// "vinput-neovide",
// "vinput-editor",
// filename,
//};
const editor_argv = [_][]const u8{
"alacritty",
"--class",
"vinput-neovide",
"vinput-editor",
"-e",
"nvim",
"--cmd",
@ -66,7 +74,7 @@ pub fn main() !void {
);
defer std.os.munmap(fcontent);
try clipboard.provideClipboard(std.mem.trim(u8, fcontent, " \n\r"), alloc);
try clipboard.provideClipboard(std.mem.trim(u8, fcontent, " \n\r"));
}
std.log.info("deleting tempfile {s}", .{filename});
try std.fs.deleteFileAbsolute(filename);