diff --git a/config/wezterm/events.lua b/config/wezterm/events.lua index 67dd0f0..82da2a9 100644 --- a/config/wezterm/events.lua +++ b/config/wezterm/events.lua @@ -33,10 +33,10 @@ end) wezterm.on('toggle-opacity', function(window, _) local overrides = window:get_config_overrides() or {} - if not overrides.window_background_opacity then + if not overrides.window_background_opacity or overrides.window_background_opacity == 1.0 then overrides.window_background_opacity = 0.9 else - overrides.window_background_opacity = nil + overrides.window_background_opacity = 1.0 end window:set_config_overrides(overrides) end) diff --git a/config/wezterm/functions.lua b/config/wezterm/functions.lua index f60019a..00a0476 100644 --- a/config/wezterm/functions.lua +++ b/config/wezterm/functions.lua @@ -3,14 +3,23 @@ local wezterm = require 'wezterm' local M = {} function M.get_windows() - -- return wezterm.gui.gui_windows() - return wezterm.mux.all_windows() + return wezterm.gui.gui_windows() +end + +function M.get_active_window() + local windows = wezterm.gui.gui_windows() + local win + for _, win in ipairs(windows) do + if win:is_focused() then + return win + end + end + return windows[1] end function M.get_active_tab(window) if not window then - local windows = wezterm.mux.all_windows() - window = windows[1] + window = M.get_active_window() end local tab = window:active_tab() return tab diff --git a/config/wezterm/sys.lua b/config/wezterm/sys.lua index 4033dd7..aa70430 100644 --- a/config/wezterm/sys.lua +++ b/config/wezterm/sys.lua @@ -1,4 +1,4 @@ --- NOTE: We cannot import anything outside of the wezterm confif dir yet +-- NOTE: We cannot import anything outside of the wezterm config dir yet -- we first need to patch the runtime local wezterm = require 'wezterm' local is_windows = wezterm.target_triple == 'x86_64-pc-windows-msvc' @@ -65,19 +65,7 @@ function sys.basename(str) end function sys.open(uri) - local cmd = {} - if sys.name == 'windows' then - table.insert(cmd, 'powershell') - require('utils.tables').list_extend(cmd, { '-noexit', '-executionpolicy', 'bypass', 'Start-Process' }) - elseif sys.name == 'linux' then - table.insert(cmd, 'xdg-open') - else - -- Problably macos - table.insert(cmd, 'open') - end - table.insert(cmd, uri) - local success, _, _ = wezterm.run_child_process(cmd) - return success + wezterm.open_with(uri) end return sys diff --git a/config/wezterm/wezterm.lua b/config/wezterm/wezterm.lua index f5572b0..c727c98 100644 --- a/config/wezterm/wezterm.lua +++ b/config/wezterm/wezterm.lua @@ -1,4 +1,6 @@ -_G['unpack'] = _G['unpack'] or _G['table'].unpack +if not unpack then + _G['unpack'] = _G['table'].unpack +end require 'patch_runtime'