-
Notifications
You must be signed in to change notification settings - Fork 14
Useful configs
Ken Enda edited this page Feb 7, 2023
·
2 revisions
local tym = require('tym')
tym.set_config({
shell = '/bin/bash',
})
tym.set_timeout(coroutine.wrap(function()
local i = 0
local message = 'echo "hello World!"'
while i < #message do
i = i + 1
tym.put(message:sub(i, i))
coroutine.yield(true)
end
coroutine.yield(true)
tym.send_key('<Ctrl>m')
coroutine.yield(false)
end), 100)
Key inputs alt-h,j,k,l for switching tmux's pane is often delayed when tmux is busy. This is the fix for it.
local tym = require('tym')
local remap = function (a, b)
tym.set_keymap(a, function()
tym.send_key(b)
end)
end
remap('<Alt>h', '<Alt>Left') -- remap as meta key inputs
remap('<Alt>l', '<Alt>Right')
remap('<Alt><Shift>h', '<Alt><Shift>Left')
remap('<Alt><Shift>l', '<Alt><Shift>Right')
You can increase/decrease window transparency by pressing Ctrl + Shift + Down
/ Ctrl + Shift + Up
or Shift
+ mouse wheel and increase/decrease font scale by Ctrl
+ mouse wheel.
local tym = require('tym')
function update_alpha(delta)
r, g, b, a = tym.color_to_rgba(tym.get('color_background'))
a = math.max(math.min(1.0, a + delta), 0.0)
bg = tym.rgba_to_color(r, g, b, a)
tym.set('color_background', bg)
tym.notify(string.format('%s alpha to %f', (delta > 0 and 'Inc' or 'Dec'), a))
end
tym.set_keymaps({
['<Ctrl><Shift>Up'] = function()
update_alpha(0.05)
end,
['<Ctrl><Shift>Down'] = function()
update_alpha(-0.05)
end,
})
tym.set_hook('scroll', function(dx, dy, x, y)
if tym.check_mod_state('<Ctrl>') then
if dy > 0 then
s = tym.get('scale') - 10
else
s = tym.get('scale') + 10
end
tym.set('scale', s)
tym.notify('set scale: ' .. s .. '%')
return true
end
if tym.check_mod_state('<Shift>') then
update_alpha(dy < 0 and 0.05 or -0.05)
return true
end
end)