diff --git a/.config/i3/config b/.config/i3/config index 08fb20e..96354ba 100755 --- a/.config/i3/config +++ b/.config/i3/config @@ -61,6 +61,10 @@ bindsym $mod+Ctrl+e exec thunar # open luakit bindsym $mod+Ctrl+b exec luakit +# vinput +bindsym $mod+Ctrl+v exec vinput +for_window [class="vinput-neovide"] floating enable + # kill focused window bindsym $mod+Shift+q kill @@ -200,7 +204,7 @@ mode "resize" { bindsym $mod+r mode "resize" -# enable icons (requires git version of i3 at the moment) +# enable icons for_window [class=".*"] title_window_icon on # random settings diff --git a/.config/nvim/lua/pluginconf/firenvim.lua b/.config/nvim/lua/pluginconf/firenvim.lua deleted file mode 100644 index da60962..0000000 --- a/.config/nvim/lua/pluginconf/firenvim.lua +++ /dev/null @@ -1,18 +0,0 @@ -local blacklistedSites = { - [[.*twitch\.tv.*]], - [[*twitter\.com.*]], - [[*koyu\.space.*]], -} - -local localSettings = { - [".*"] = { - cmdline = "neovim", - }, -} -for _, site in pairs(blacklistedSites) do - localSettings[site] = { takeover = "never" } -end - -vim.g.firenvim_config = { - localSettings = localSettings, -} diff --git a/.config/nvim/lua/pluginconf/nvimtree.lua b/.config/nvim/lua/pluginconf/nvimtree.lua index 6611e8f..6361cfc 100644 --- a/.config/nvim/lua/pluginconf/nvimtree.lua +++ b/.config/nvim/lua/pluginconf/nvimtree.lua @@ -1,6 +1,6 @@ require("nvim-tree").setup { - -- don't open tree when using firenvim - open_on_setup = not vim.g.started_by_firenvim, + open_on_setup = true, + open_on_setup_file = false, diagnostics = { enable = true, }, diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index ace99c1..6d3f583 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -63,13 +63,6 @@ return require("packer").startup(function(use) "dracula/vim", as = "dracula", } - use { - "glacambre/firenvim", - run = function() - vim.fn["firenvim#install"](0) - end, - config = pconf "firenvim", - } use { "lewis6991/gitsigns.nvim", config = function() diff --git a/justfile b/justfile index 95eac6d..0ec2ee0 100644 --- a/justfile +++ b/justfile @@ -17,6 +17,7 @@ install-scripts target=(`echo $HOME` + "/.local"): {{target}}/bin cd scripts/randomwallpaper && zig build -Drelease-fast -p {{target}} + cd scripts/vinput && zig build -Drelease-fast -p {{target}} cd scripts/playtwitch && gyro build -Drelease-fast -p {{target}} cd scripts/prompt && gyro build -Drelease-fast -p {{target}} cd scripts/mzteinit && gyro build -Drelease-fast -p {{target}} diff --git a/scripts/vinput/.gitignore b/scripts/vinput/.gitignore new file mode 100644 index 0000000..1ae1b10 --- /dev/null +++ b/scripts/vinput/.gitignore @@ -0,0 +1,5 @@ +zig-cache/ +zig-out/ +deps.zig +gyro.lock +.gyro diff --git a/scripts/vinput/build.zig b/scripts/vinput/build.zig new file mode 100644 index 0000000..96e8c3c --- /dev/null +++ b/scripts/vinput/build.zig @@ -0,0 +1,34 @@ +const std = @import("std"); + +pub fn build(b: *std.build.Builder) void { + // Standard target options allows the person running `zig build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. + const target = b.standardTargetOptions(.{}); + + // Standard release options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. + const mode = b.standardReleaseOptions(); + + const exe = b.addExecutable("vinput", "src/main.zig"); + exe.setTarget(target); + exe.setBuildMode(mode); + exe.install(); + + const run_cmd = exe.run(); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); + + const exe_tests = b.addTest("src/main.zig"); + exe_tests.setTarget(target); + exe_tests.setBuildMode(mode); + + const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&exe_tests.step); +} diff --git a/scripts/vinput/src/main.zig b/scripts/vinput/src/main.zig new file mode 100644 index 0000000..85fcfac --- /dev/null +++ b/scripts/vinput/src/main.zig @@ -0,0 +1,80 @@ +const std = @import("std"); + +pub const log_level = .debug; + +pub fn main() !void { + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + defer _ = gpa.deinit(); + + var alloc = gpa.allocator(); + + const filename = try std.fmt.allocPrint( + alloc, + "/tmp/vinput{}-{}", + .{ std.os.linux.getuid(), std.time.milliTimestamp() }, + ); + defer alloc.free(filename); + + const nvide_argv = [_][]const u8{ + "neovide", + "--nofork", + "--x11-wm-class", + "vinput-neovide", + filename, + }; + + std.log.info("invoking neovide with command {s}", .{&nvide_argv}); + + var nvide_child = std.ChildProcess.init(&nvide_argv, alloc); + _ = try nvide_child.spawnAndWait(); + + const stat = std.fs.cwd().statFile(filename) catch |e| { + switch (e) { + error.FileNotFound => { + std.log.warn("tempfile doesn't exist; aborting", .{}); + return; + }, + else => return e, + } + }; + { + var tempfile = try std.fs.openFileAbsolute(filename, .{}); + defer tempfile.close(); + + const xclip_argv = [_][]const u8{ + "xclip", + "-sel", + "clip", + }; + + std.log.info("invoking xclip with command {s}", .{&xclip_argv}); + + var xclip_child = std.ChildProcess.init(&xclip_argv, alloc); + xclip_child.stdin_behavior = .Pipe; + try xclip_child.spawn(); + defer _ = xclip_child.wait() catch {}; + if (xclip_child.stdin == null) { + return error.XclipNullStdin; + } + defer xclip_child.stdin = null; + defer xclip_child.stdin.?.close(); + + std.log.info("mmapping tempfile", .{}); + + // ooooh memmap, performance! + const fcontent = try std.os.mmap( + null, + stat.size, + std.os.PROT.READ, + std.os.MAP.PRIVATE, + tempfile.handle, + 0, + ); + defer std.os.munmap(fcontent); + + std.log.info("writing trimmed tempfile to xclip stdin", .{}); + try xclip_child.stdin.?.writeAll(std.mem.trim(u8, fcontent, " \n\r")); + } + std.log.info("deleting tempfile {s}", .{filename}); + try std.fs.deleteFileAbsolute(filename); +}