mirror of
https://github.com/pnx/dotfiles
synced 2026-11-03 12:46:45 +01:00
hyprland
This commit is contained in:
parent
5366d66a23
commit
83c14bfb24
3 changed files with 85 additions and 5 deletions
18
hypr/helpers/exec.lua
Normal file
18
hypr/helpers/exec.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
local uwsm = os.execute("uwsm check is-active >/dev/null 2>&1")
|
||||
|
||||
local function normalize_cmd(cmd)
|
||||
if uwsm == true or uwsm == 0 then
|
||||
cmd = "uwsm-app " .. cmd
|
||||
end
|
||||
return cmd
|
||||
end
|
||||
|
||||
function dispatch(cmd)
|
||||
return hl.dsp.exec_cmd(normalize_cmd(cmd))
|
||||
end
|
||||
|
||||
function exec(cmd)
|
||||
return hl.exec_cmd(normalize_cmd(cmd))
|
||||
end
|
||||
|
||||
60
hypr/helpers/terminal.lua
Normal file
60
hypr/helpers/terminal.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
local definitions = {
|
||||
["uwsm"] = {
|
||||
command = "uwsm-terminal",
|
||||
test = "command -v uwsm-terminal && uwsm check is-active",
|
||||
},
|
||||
["ghostty"] = {
|
||||
command = "ghostty",
|
||||
args = "-e",
|
||||
},
|
||||
["kitty"] = {
|
||||
command = "kitty",
|
||||
args = "-e",
|
||||
},
|
||||
["xterm"] = {
|
||||
command = "xterm",
|
||||
args = "-e",
|
||||
},
|
||||
["urxvt"] = {
|
||||
command = "urxvt",
|
||||
args = "-e",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
local M = {
|
||||
terminals = { "uwsm", "ghostty", "kitty", "xterm", "urxvt" }
|
||||
}
|
||||
|
||||
function M.configure(list)
|
||||
M.terminals = list
|
||||
end
|
||||
|
||||
function M.exec(command)
|
||||
local script = {}
|
||||
|
||||
for _, name in ipairs(M.terminals) do
|
||||
local term = assert(definitions[name], "Unknown terminal: " .. name)
|
||||
local test = term.test or ("command -v " .. term.command)
|
||||
|
||||
local cmd = term.command
|
||||
|
||||
if command then
|
||||
if term.args then
|
||||
cmd = cmd .. " " .. term.args
|
||||
end
|
||||
|
||||
cmd = cmd .. " " .. command
|
||||
end
|
||||
|
||||
table.insert(script, string.format(
|
||||
"if %s >/dev/null 2>&1; then exec %s; fi",
|
||||
test,
|
||||
cmd
|
||||
))
|
||||
end
|
||||
|
||||
return hl.dsp.exec_cmd(table.concat(script, "; "))
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
-- Hyprland 0.56.2 Lua configuration, migrated from hyprland.conf.
|
||||
|
||||
require('helpers.focus-or-start')
|
||||
require('helpers.exec')
|
||||
local terminal = require('helpers.terminal')
|
||||
|
||||
-- Variables
|
||||
-- -----------------------------------------
|
||||
|
|
@ -10,7 +12,7 @@ local mainMonitor = "DP-2"
|
|||
local secondMonitor = "HDMI-A-1"
|
||||
|
||||
-- Programs
|
||||
local terminal = "ghostty"
|
||||
-- local terminal = "ghostty"
|
||||
local menu = "rofi -show drun"
|
||||
local runProgram = "rofi -show run"
|
||||
local screenshot = 'grim -g "$(slurp)" - | wl-copy'
|
||||
|
|
@ -174,9 +176,9 @@ hl.layer_rule({
|
|||
-- Keybindings
|
||||
-- -----------------------------------------
|
||||
|
||||
hl.bind(kb_super .. " + D", hl.dsp.exec_cmd(menu))
|
||||
hl.bind(kb_super .. " + P", hl.dsp.exec_cmd(runProgram))
|
||||
hl.bind(kb_super .. " + Return", hl.dsp.exec_cmd(terminal))
|
||||
hl.bind(kb_super .. " + D", dispatch(menu))
|
||||
hl.bind(kb_super .. " + P", dispatch(runProgram))
|
||||
hl.bind(kb_super .. " + Return", terminal.exec())
|
||||
hl.bind(kb_super .. " + T", function()
|
||||
FocusOrStart("telegram", "org.telegram")
|
||||
end)
|
||||
|
|
@ -217,6 +219,6 @@ hl.bind(kb_super .. " + mouse:273", hl.dsp.window.resize())
|
|||
|
||||
hl.on("hyprland.start", function()
|
||||
for _, command in ipairs(autostart) do
|
||||
hl.exec_cmd(command)
|
||||
exec(command)
|
||||
end
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue