add move client to tag by name

This commit is contained in:
Roland Schneider 2021-07-29 12:03:35 +02:00
parent 656e158e80
commit 29b0263dfa
2 changed files with 63 additions and 21 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
function run { function run {
if ! pgrep -f $1 ; if ! pgrep $1 ;
then then
$@& $@&
fi fi
@ -10,7 +10,7 @@ function run {
# tag 1 # tag 1
run /usr/local/bin/idea run /usr/local/bin/idea
# tag 2 # tag 2
run /usr/bin/google-chrome run /opt/google/chrome/chrome
# tag 3 # tag 3
run /usr/bin/terminator run /usr/bin/terminator
# tag 4 # tag 4
@ -20,5 +20,7 @@ run /usr/bin/zoom
run /usr/bin/teams run /usr/bin/teams
# tag 6 # tag 6
run /usr/bin/rocketchat-desktop run /usr/bin/rocketchat-desktop
run /usr/bin/thunderbird
# tag 7 # tag 7
run /usr/local/bin/bitwarden run /usr/local/bin/bitwarden
run /usr/bin/keepass2

78
rc.lua
View File

@ -288,7 +288,7 @@ globalkeys = gears.table.join(
-- mod + Esc -> tag history resotre -- mod + Esc -> tag history resotre
awful.key({ modkey, }, "Escape", awful.tag.history.restore, awful.key({ modkey, }, "Escape", awful.tag.history.restore,
{description = "go back", group = "tag"}), {description = "go back", group = "tag"}),
-- mod + j|k -> focuse next|prev client -- mod + j|k -> focus next|prev client
awful.key({ modkey, }, "j", awful.key({ modkey, }, "j",
function () function ()
awful.client.focus.byidx( 1) awful.client.focus.byidx( 1)
@ -460,6 +460,15 @@ local function move_tag_to_focused_screen(tagName)
end end
end end
local function move_client_to_tag(tagName)
if client.focus then
local tag = awful.tag.find_by_name(nil, tagName)
if tag then
client.focus:move_to_tag(tag)
end
end
end
-- Bind all key numbers to tags. -- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it work on any keyboard layout. -- Be careful: we use keycodes to make it work on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9. -- This should map on the top row of your keyboard, usually 1 to 9.
@ -469,11 +478,12 @@ for i = 1, 9 do
-- mod + i -> show tag -- mod + i -> show tag
awful.key({ modkey }, "#" .. i + 9, awful.key({ modkey }, "#" .. i + 9,
function () function ()
local screen = awful.screen.focused() -- local screen = awful.screen.focused()
local tag = screen.tags[i] -- local tag = screen.tags[i]
if tag then -- if tag then
tag:view_only() -- tag:view_only()
end -- end
move_tag_to_focused_screen(tags[i])
end, end,
{description = "view tag #"..i, group = "tag"}), {description = "view tag #"..i, group = "tag"}),
@ -499,12 +509,13 @@ for i = 1, 9 do
-- mod + shift + i -> move client to tag -- mod + shift + i -> move client to tag
awful.key({ modkey, "Shift" }, "#" .. i + 9, awful.key({ modkey, "Shift" }, "#" .. i + 9,
function () function ()
if client.focus then -- if client.focus then
local tag = client.focus.screen.tags[i] -- local tag = client.focus.screen.tags[i]
if tag then -- if tag then
client.focus:move_to_tag(tag) -- client.focus:move_to_tag(tag)
end -- end
end -- end
move_client_to_tag(tags[i])
end, end,
{description = "move focused client to tag #"..i, group = "tag"}), {description = "move focused client to tag #"..i, group = "tag"}),
-- Toggle tag on focused client. -- Toggle tag on focused client.
@ -577,7 +588,36 @@ awful.rules.rules = {
{ rule_any = {type = { "normal", "dialog" } { rule_any = {type = { "normal", "dialog" }
}, properties = { titlebars_enabled = true } }, properties = { titlebars_enabled = true }
}, },
-- jetbrains-idea -> tag 1
{ rule = { class = "jetbrains-idea" },
properties = { tag = tag1 } },
-- chrome -> tag 2
{ rule = { class = "google-chrome" },
properties = { tag = tag2 } },
-- terminator-> tag 3
{ rule = { class = "terminator" },
properties = { tag = tag3 } },
-- vscode -> tag 4
{ rule = { class = "code" },
properties = { tag = tag4 } },
-- zoom -> tag5
{ rule = { class = "zoom" },
properties = { tag = tag5 } },
-- microsoft teams - preview -> tag5
{ rule = { class = "microsoft teams - preview" },
properties = { tag = tag5 } },
-- rocket.chat-> tag6
{ rule = { class = "rocket.chat" },
properties = { tag = tag6 } },
-- Thunderbird -> tag6
{ rule = { class = "Thunderbird" },
properties = { tag = tag6 } },
-- Bitwarden -> tag7
{ rule = { class = "bitwarden" },
properties = { tag = tag7 } },
-- keepass2 -> tag7
{ rule = { class = "keepass2" },
properties = { tag = tag7 } },
-- Set Firefox to always map on the tag named "2" on screen 1. -- Set Firefox to always map on the tag named "2" on screen 1.
-- { rule = { class = "Firefox" }, -- { rule = { class = "Firefox" },
-- properties = { screen = 1, tag = "2" } }, -- properties = { screen = 1, tag = "2" } },
@ -642,12 +682,12 @@ client.connect_signal("request::titlebars", function(c)
end) end)
-- Enable sloppy focus, so that focus follows mouse. -- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", function(c) -- client.connect_signal("mouse::enter", function(c)
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier -- if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
and awful.client.focus.filter(c) then -- and awful.client.focus.filter(c) then
client.focus = c -- client.focus = c
end -- end
end) -- end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)