mirror of
https://mzte.de/git/LordMZTE/dotfiles.git
synced 2024-12-13 12:53:00 +01:00
add vinput
This commit is contained in:
parent
72d52e10cd
commit
34ea3a88d8
8 changed files with 127 additions and 28 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
}
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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()
|
||||
|
|
1
justfile
1
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}}
|
||||
|
|
5
scripts/vinput/.gitignore
vendored
Normal file
5
scripts/vinput/.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
zig-cache/
|
||||
zig-out/
|
||||
deps.zig
|
||||
gyro.lock
|
||||
.gyro
|
34
scripts/vinput/build.zig
Normal file
34
scripts/vinput/build.zig
Normal file
|
@ -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);
|
||||
}
|
80
scripts/vinput/src/main.zig
Normal file
80
scripts/vinput/src/main.zig
Normal file
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue