Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MobSenpai committed Jun 29, 2023
1 parent 3c61228 commit a051305
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 113 deletions.
97 changes: 0 additions & 97 deletions home/yashraj/modules/desktop/wm/awesome/default/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -419,103 +419,6 @@ awesome.connect_signal("signal::volume", function(vol, muted)
end)
-- =============================================

-- Layout list osd
-- =============================================
screen.connect_signal("request::desktop_decoration", function(s)
local layout_list = awful.widget.layoutlist({
source = awful.widget.layoutlist.source.default_layouts, --- DOC_HIDE
spacing = dpi(24),
base_layout = wibox.widget({
spacing = dpi(24),
forced_num_cols = 4,
layout = wibox.layout.grid.vertical,
}),
widget_template = {
{
{
id = "icon_role",
forced_height = dpi(68),
forced_width = dpi(68),
widget = wibox.widget.imagebox,
},
margins = dpi(24),
widget = wibox.container.margin,
},
id = "background_role",
forced_width = dpi(68),
forced_height = dpi(68),
widget = wibox.container.background,
},
})

local layout_popup = awful.popup({
widget = wibox.widget({
{ layout_list, margins = dpi(24), widget = wibox.container.margin },
bg = beautiful.color4,
shape = helpers.rrect(beautiful.border_radius),
widget = wibox.container.background,
}),
placement = awful.placement.centered,
ontop = true,
visible = false,
bg = beautiful.color4 .. "00",
})

function gears.table.iterate_value(t, value, step_size, filter, start_at)
local k = gears.table.hasitem(t, value, true, start_at)
if not k then
return
end

step_size = step_size or 1
local new_key = gears.math.cycle(#t, k + step_size)

if filter and not filter(t[new_key]) then
for i = 1, #t do
local k2 = gears.math.cycle(#t, new_key + i)
if filter(t[k2]) then
return t[k2], k2
end
end
return
end

return t[new_key], new_key
end

awful.keygrabber({
start_callback = function()
layout_popup.visible = true
end,
stop_callback = function()
layout_popup.visible = false
end,
export_keybindings = true,
stop_event = "release",
stop_key = { "Escape", "Super_L", "Super_R", "Mod4" },
keybindings = {
{
{ "Mod4", "Shift" },
" ",
function()
awful.layout.set(
gears.table.iterate_value(layout_list.layouts, layout_list.current_layout, -1),
nil
)
end,
},
{
{ "Mod4" },
" ",
function()
awful.layout.set(gears.table.iterate_value(layout_list.layouts, layout_list.current_layout, 1), nil)
end,
},
},
})
end)
-- =============================================

-- ░█░█░▀█▀░█▀▄░█▀█░█▀▄
-- ░█▄█░░█░░█▀▄░█▀█░█▀▄
-- ░▀░▀░▀▀▀░▀▀░░▀░▀░▀░▀
Expand Down
12 changes: 12 additions & 0 deletions home/yashraj/modules/desktop/wm/awesome/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,16 @@ function helpers.scratchpad(match, spawn_cmd, spawn_args)
end
end

function helpers.volume_control(step)
local cmd
if step == 0 then
cmd = "pactl set-sink-mute @DEFAULT_SINK@ toggle"
else
sign = step > 0 and "+" or ""
cmd = "pactl set-sink-mute @DEFAULT_SINK@ 0 && pactl set-sink-volume @DEFAULT_SINK@ " .. sign .. tostring(step) ..
"%"
end
awful.spawn.with_shell(cmd)
end

return helpers
76 changes: 63 additions & 13 deletions home/yashraj/modules/desktop/wm/awesome/keys.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,25 @@ keys.globalkeys = gears.table.join(
end
end,
}),
awful.key({
modifiers = { mod },
key = "space",
description = "select next",
group = "layout",
on_press = function()
awful.layout.inc(1)
end,
}),
awful.key({
modifiers = { mod, shift },
key = "space",
description = "select previous",
group = "layout",
on_press = function()
awful.layout.inc(-1)
end,
}),

-- Tag switcher
awful.key({ mod }, "Tab", function()
awful.tag.viewnext()
Expand All @@ -153,6 +172,14 @@ keys.globalkeys = gears.table.join(
awful.client.focus.bydirection("right")
end, { description = "focus right", group = "client" }),

-- Focus client by index (cycle through clients)
awful.key({ mod }, "z", function()
awful.client.focus.byidx(1)
end, { description = "focus next by index", group = "client" }),
awful.key({ mod, shift }, "z", function()
awful.client.focus.byidx(-1)
end, { description = "focus next by index", group = "client" }),

-- Focus client by direction (arrow keys)
awful.key({ mod }, "Down", function()
awful.client.focus.bydirection("down")
Expand Down Expand Up @@ -267,23 +294,31 @@ keys.globalkeys = gears.table.join(
awful.key({ mod, shift }, "c", function()
awful.spawn("clipmenu")
end, { description = "clipboard", group = "app" }),
-- Volume control
awful.key({}, "XF86AudioRaiseVolume", function()
awful.spawn("pamixer -i 3", false)
end, { description = "increase volume", group = "awesome" }),
awful.key({}, "XF86AudioLowerVolume", function()
awful.spawn("pamixer -d 3", false)
end, { description = "decrease volume", group = "awesome" }),
awful.key({}, "XF86AudioMute", function()
awful.spawn("pamixer -t", false)
end, { description = "mute volume", group = "awesome" }),
-- Hotkeys list
awful.key({ mod }, "F1", function() hotkeys_popup.show_help() end,
{ description = "show help", group = "awesome" }),

-- Volume Control with volume keys
awful.key({}, "XF86AudioMute",
function()
helpers.volume_control(0)
end,
{ description = "(un)mute volume", group = "volume" }),
awful.key({}, "XF86AudioLowerVolume",
function()
helpers.volume_control(-5)
end,
{ description = "lower volume", group = "volume" }),
awful.key({}, "XF86AudioRaiseVolume",
function()
helpers.volume_control(5)
end,
{ description = "raise volume", group = "volume" }),

-- Lockscreen
awful.key({ mod, alt }, "l", function()
lock_screen_show()
end, { description = "lock screen", group = "hotkeys" }),
-- Hotkeys list
awful.key({ mod }, "F1", function() hotkeys_popup.show_help() end,
{ description = "show help", group = "awesome" }),

-- Apps
-- Spawn browser
Expand Down Expand Up @@ -356,6 +391,18 @@ keys.clientkeys = gears.table.join(
end
end, { description = "toggle floating", group = "client" }),

-- Set master
awful.key({ mod, ctrl }, "Return", function(c) c:swap(awful.client.getmaster()) end,
{ description = "move to master", group = "client" }),

-- P for pin: keep on top OR sticky
-- On top
awful.key({ mod, shift }, "p", function(c) c.ontop = not c.ontop end,
{ description = "toggle keep on top", group = "client" }),
-- Sticky
awful.key({ mod, ctrl }, "p", function(c) c.sticky = not c.sticky end,
{ description = "toggle sticky", group = "client" }),

-- Minimize
awful.key({ mod }, "n", function(c)
c.minimized = true
Expand Down Expand Up @@ -473,5 +520,8 @@ keys.taglist_buttons = gears.table.join(
end)
)

root.keys(keys.globalkeys)
root.buttons(keys.desktopbuttons)

return keys
-- EOF ------------------------------------------------------------------------
4 changes: 1 addition & 3 deletions home/yashraj/modules/desktop/wm/awesome/rc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ require("configuration")

-- Keybinds and mousebinds
local keys = require("keys")
root.keys(keys.globalkeys)
root.buttons(keys.desktopbuttons)

-- Lock screen
-- Make sure to install lua-pam as described in the README or configure your
Expand All @@ -108,7 +106,7 @@ awful.layout.layouts = {
awful.layout.suit.floating,
awful.layout.suit.max,
--awful.layout.suit.spiral,
awful.layout.suit.spiral.dwindle,
--awful.layout.suit.spiral.dwindle,
--awful.layout.suit.tile.top,
--awful.layout.suit.fair,
--awful.layout.suit.fair.horizontal,
Expand Down

0 comments on commit a051305

Please sign in to comment.