mirror of
https://github.com/pnx/dotfiles
synced 2026-10-23 00:16:48 +02:00
hyprland: convert bash script to lua function
This commit is contained in:
parent
1b92e31848
commit
3749809988
3 changed files with 19 additions and 18 deletions
11
hypr/helpers/focus-or-start.lua
Normal file
11
hypr/helpers/focus-or-start.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
function FocusOrStart(command, classPrefix)
|
||||
for _, window in ipairs(hl.get_windows()) do
|
||||
if window.class:sub(1, #classPrefix) == classPrefix then
|
||||
hl.dispatch(hl.dsp.focus({ window = window }))
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
hl.exec_cmd(command)
|
||||
end
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
-- Hyprland 0.56.2 Lua configuration, migrated from hyprland.conf.
|
||||
|
||||
require('helpers.focus-or-start')
|
||||
|
||||
-- Variables
|
||||
-- -----------------------------------------
|
||||
|
||||
|
|
@ -29,9 +31,6 @@ local autostart = {
|
|||
"telegram",
|
||||
}
|
||||
|
||||
-- Scripts
|
||||
local focusOrStart = ".config/hypr/scripts/focus-or-start.sh"
|
||||
|
||||
-- Environment
|
||||
-- -----------------------------------------
|
||||
|
||||
|
|
@ -179,8 +178,12 @@ hl.layer_rule({
|
|||
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 .. " + T", hl.dsp.exec_cmd(focusOrStart .. ' "telegram" "org.telegram"'))
|
||||
hl.bind(kb_super .. " + G", hl.dsp.exec_cmd(focusOrStart .. ' "vivaldi-stable" "vivaldi-stable"'))
|
||||
hl.bind(kb_super .. " + T", function()
|
||||
FocusOrStart("telegram", "org.telegram")
|
||||
end)
|
||||
hl.bind(kb_super .. " + G", function()
|
||||
FocusOrStart("vivaldi-stable", "vivaldi-stable")
|
||||
end)
|
||||
hl.bind(kb_super .. " + S", hl.dsp.exec_cmd(screenshot))
|
||||
|
||||
hl.bind(kb_super .. " + X", hl.dsp.window.close())
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
execCommand=$1
|
||||
className=$2
|
||||
|
||||
class=$(hyprctl -j clients | jq -r ".[] | select(.class | startswith(\"${className}\")) | .class")
|
||||
|
||||
if [[ $class != "" ]]
|
||||
then
|
||||
hyprctl dispatch focuswindow "class:${class}"
|
||||
else
|
||||
${execCommand} &
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue