Compare commits

...

5 Commits

5 changed files with 78 additions and 31 deletions

View File

@@ -484,7 +484,8 @@ awful.rules.rules = {
keys = clientkeys, keys = clientkeys,
buttons = clientbuttons, buttons = clientbuttons,
screen = awful.screen.preferred, screen = awful.screen.preferred,
placement = awful.placement.no_overlap + awful.placement.no_offscreen placement = awful.placement.no_overlap + awful.placement.no_offscreen,
size_hints_honor = false,
} }
}, },
@@ -536,6 +537,19 @@ awful.rules.rules = {
-- }}} -- }}}
-- {{{ Signals -- {{{ Signals
local function set_border_width(c)
local t = awful.screen.focused().selected_tag
if #t:clients() == 1 or t.layout.name == 'max' then
c = c or client.focus
c.border_width = 0
else
for _, cl in ipairs(t:clients()) do
cl.border_width = beautiful.border_width
end
end
end
-- Signal function to execute when a new client appears. -- Signal function to execute when a new client appears.
client.connect_signal("manage", function(c) client.connect_signal("manage", function(c)
-- Set the windows at the slave, -- Set the windows at the slave,
@@ -548,6 +562,7 @@ client.connect_signal("manage", function(c)
-- Prevent clients from being unreachable after screen count changes. -- Prevent clients from being unreachable after screen count changes.
awful.placement.no_offscreen(c) awful.placement.no_offscreen(c)
end end
set_border_width(c)
end) end)
-- Enable sloppy focus, so that focus follows mouse. -- Enable sloppy focus, so that focus follows mouse.
@@ -555,6 +570,23 @@ client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", { raise = false }) c:emit_signal("request::activate", "mouse_enter", { raise = false })
end) end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) -- local function set_border(c)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) -- local s = awful.screen.focused()
-- if c.maximized
-- or (#s.tiled_clients == 1 and not c.floating)
-- or (s.selected_tag and s.selected_tag.layout.name == 'max')
-- then
-- c.border_width = 0
-- else
-- c.border_width = beautiful.border_width
-- end
-- end
client.connect_signal("focus", function(c)
c.border_color = beautiful.border_focus
set_border_width(c)
end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal; end)
tag.connect_signal("property::layout", function() set_border_width(nil) end)
-- }}} -- }}}

View File

@@ -22,6 +22,7 @@ theme.fg_urgent = theme.bg_focus
theme.fg_minimize = theme.fg_normal theme.fg_minimize = theme.fg_normal
theme.taglist_fg_empty = "#454f54" -- hsl(200 10% 30%) theme.taglist_fg_empty = "#454f54" -- hsl(200 10% 30%)
theme.gap_single_client = false
theme.useless_gap = dpi(1) theme.useless_gap = dpi(1)
theme.border_width = dpi(2) theme.border_width = dpi(2)
theme.border_normal = "#73848c" -- hsl(200 10% 50%) theme.border_normal = "#73848c" -- hsl(200 10% 50%)

View File

@@ -22,6 +22,7 @@ theme.fg_urgent = "#70675c" -- hsl(34 10% 40%)
theme.fg_minimize = "#70675c" -- hsl(34 10% 40%) theme.fg_minimize = "#70675c" -- hsl(34 10% 40%)
theme.taglist_fg_empty = theme.fg_minimize theme.taglist_fg_empty = theme.fg_minimize
theme.gap_single_client = false
theme.useless_gap = dpi(1) theme.useless_gap = dpi(1)
theme.border_width = dpi(2) theme.border_width = dpi(2)
theme.border_normal = theme.bg_minimize theme.border_normal = theme.bg_minimize

View File

@@ -29,5 +29,5 @@ ta() {
} }
vf() { vf() {
fzf --bind 'enter:become:vis {}' -q "$1" vis "+fzf-files auto-files '$1'"
} }

View File

@@ -91,7 +91,7 @@ local function cmd_action(cmd, action)
end end
end end
local function fzf_sh(arg) local function fzf_sh(arg, query)
action = function(out) action = function(out)
if (out:find('\n') or #out) == #out then if (out:find('\n') or #out) == #out then
open_file_pos(out, vis.win.file.modified and 'o' or 'e') open_file_pos(out, vis.win.file.modified and 'o' or 'e')
@@ -102,16 +102,19 @@ local function fzf_sh(arg)
local home = os.getenv('HOME') local home = os.getenv('HOME')
local path = vis.win.file.path or '' local path = vis.win.file.path or ''
local dir = path:match('^.*/') or '' local dir = path:match('^.*/') or ''
local reg = '' if not query and vis.register ~= '"' then
if vis.register ~= '"' then query = string.gsub(vis.registers[vis.register][1], '%z', '')
reg = string.gsub(vis.registers[vis.register][1], '%z', '')
end end
local cmd = home .. local cmd = home ..
'/.config/vis/fzf.sh ' .. '/.config/vis/fzf.sh ' ..
escape_and_quoted(arg) .. ' ' .. escape_and_quoted(dir) .. ' ' .. escape_and_quoted(reg) escape_and_quoted(arg) .. ' ' .. escape_and_quoted(dir) .. ' ' .. escape_and_quoted(query or '')
cmd_action(cmd, action) cmd_action(cmd, action)
end end
vis:command_register('fzf-files', function(argv, force, win, selection, range)
fzf_sh(argv[1] or 'auto-files', argv[2])
end)
local function search(cmd, action) local function search(cmd, action)
if action == nil then if action == nil then
action = function(out) action = function(out)
@@ -189,12 +192,27 @@ local function add_global_mark()
end end
end end
local lfs = require('lfs')
local theme_modification = 0
local last_theme = 'default'
function set_current_theme() function set_current_theme()
local f = io.open(os.getenv('HOME') .. '/.config/xsettingsd/xsettingsd.conf') local path = os.getenv('HOME') .. '/.config/xsettingsd/xsettingsd.conf'
local m = lfs.attributes(path, 'modification')
if m == theme_modification then
return
end
theme_modification = m
local f = io.open(path)
if f then if f then
local s = f:read('*all') local s = f:read('*all')
f:close() f:close()
if s:match('light') then local theme = s:match('light') and 'light' or 'dark'
if theme == last_theme then
return
end
last_theme = theme
if theme == 'light' then
vis:command('set theme lupan-light') vis:command('set theme lupan-light')
else else
vis:command('set theme lupan-dark') vis:command('set theme lupan-dark')
@@ -242,9 +260,9 @@ vis.events.subscribe(vis.events.INIT, function()
vis:map(vis.modes.NORMAL, ' K', close_prev_win) vis:map(vis.modes.NORMAL, ' K', close_prev_win)
vis:map(vis.modes.NORMAL, ' J', close_next_win) vis:map(vis.modes.NORMAL, ' J', close_next_win)
vis:map(vis.modes.NORMAL, ' l[', ':lspc-prev-diagnostic<Enter>') vis:map(vis.modes.NORMAL, ' [', '<vis-prompt-show>lspc-prev-diagnostic<Enter>')
vis:map(vis.modes.NORMAL, ' l]', ':lspc-next-diagnostic<Enter>') vis:map(vis.modes.NORMAL, ' ]', '<vis-prompt-show>lspc-next-diagnostic<Enter>')
vis:map(vis.modes.NORMAL, ' l=', ':lspc-format<Enter>') vis:map(vis.modes.NORMAL, ' =', '<vis-prompt-show>lspc-format<Enter>')
for num = 1, 9 do for num = 1, 9 do
vis:map(vis.modes.NORMAL, ' r' .. num, function() set_file_slot(num) end, 'set file slot ' .. num) vis:map(vis.modes.NORMAL, ' r' .. num, function() set_file_slot(num) end, 'set file slot ' .. num)
@@ -254,13 +272,8 @@ vis.events.subscribe(vis.events.INIT, function()
'open file slot ' .. num) 'open file slot ' .. num)
end end
vis:map(vis.modes.NORMAL, ' s', function() vis:map(vis.modes.NORMAL, ' s', '<vis-prompt-show>fzf-files auto-search<Enter>', 'fzf: search')
fzf_sh('auto-search') vis:map(vis.modes.NORMAL, ' f', '<vis-prompt-show>fzf-files auto-files<Enter>', 'fzf: files')
end, 'fzf: search')
vis:map(vis.modes.NORMAL, ' f', function()
fzf_sh('auto-files')
end, 'fzf: files')
vis:map(vis.modes.NORMAL, ' /', function() vis:map(vis.modes.NORMAL, ' /', function()
search(fzf_reload(ripgrep .. ' --with-filename {q} ' .. escape_and_quoted(vis.win.file.path))) search(fzf_reload(ripgrep .. ' --with-filename {q} ' .. escape_and_quoted(vis.win.file.path)))
@@ -317,20 +330,16 @@ vis.events.subscribe(vis.events.INIT, function()
end) end)
end, 'fzf change directory') end, 'fzf change directory')
vis:map(vis.modes.NORMAL, ' yy', function() vis:map(vis.modes.NORMAL, ' l', '<vis-prompt-show>!lf<Enter>', 'lf file manager')
vis:command('!yazi')
end, 'yazi')
vis:map(vis.modes.NORMAL, ' y.', function() vis:map(vis.modes.NORMAL, ' L', function()
local path = vis.win.file.path local path = vis.win.file.path
if path then if path then
local dir = path:match('^.*/') vis:command('!lf ' .. escape_and_quoted(path:match('^.*/')))
local arg = escape_and_quoted(dir)
vis:command('!cd ' .. arg .. ' && yazi')
else else
vis:command('!yazi') vis:command('!lf')
end end
end, 'yazi in file directory') end, 'lf file manager in current file directory')
vis:map(vis.modes.NORMAL, ' ma', add_global_mark, 'global marks: add') vis:map(vis.modes.NORMAL, ' ma', add_global_mark, 'global marks: add')
@@ -349,7 +358,11 @@ vis.events.subscribe(vis.events.INIT, function()
vis:map(vis.modes.NORMAL, ' tl', function() vis:map(vis.modes.NORMAL, ' tl', function()
vis:command('set theme lupan-light') vis:command('set theme lupan-light')
end, 'change to light theme') end, 'change to light theme')
vis:map(vis.modes.NORMAL, ' tt', set_current_theme)
vis:map(vis.modes.NORMAL, '<C-l>', function()
vis:feedkeys('<vis-selections-remove-column-except>')
set_current_theme()
end, 'Remove all but the count selection column and update theme if needed')
set_current_theme() set_current_theme()
end) end)