forked from ashpie/simple-awesome
Update keyboard layout widget and small improvements
This commit is contained in:
parent
3aa412a73f
commit
12668472f8
@ -23,6 +23,7 @@ By default, Simple Awesome uses
|
|||||||
- Improve "leave menu"'s design
|
- Improve "leave menu"'s design
|
||||||
- Modify "start menu", make everything work
|
- Modify "start menu", make everything work
|
||||||
- Make "start menu" and "leave menu" not sticky (they currently stay open and focus even when clicking outside)
|
- Make "start menu" and "leave menu" not sticky (they currently stay open and focus even when clicking outside)
|
||||||
|
- Replace the os menu with a custom widget
|
||||||
|
|
||||||
## Arisu personal todo
|
## Arisu personal todo
|
||||||
|
|
||||||
|
@ -73,10 +73,7 @@ config.keys = {
|
|||||||
-- Hotkeys globally available (through the entire OS, regardless of what's focused)
|
-- Hotkeys globally available (through the entire OS, regardless of what's focused)
|
||||||
config.keys.global_keys = {
|
config.keys.global_keys = {
|
||||||
-- Application launcher
|
-- Application launcher
|
||||||
launcher = {
|
launcher = { { config.keys.modkey }, "space", },
|
||||||
{ config.keys.modkey },
|
|
||||||
"space",
|
|
||||||
},
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Media and volume controls
|
-- Media and volume controls
|
||||||
@ -84,23 +81,32 @@ config.keys.global_keys = {
|
|||||||
--
|
--
|
||||||
media_control = {
|
media_control = {
|
||||||
-- Raise volume
|
-- Raise volume
|
||||||
raiseVolume = "XF86AudioRaiseVolume",
|
raiseVolume = { {}, "XF86AudioRaiseVolume" },
|
||||||
|
|
||||||
-- Lower volume
|
-- Lower volume
|
||||||
lowerVolume = "XF86AudioLowerVolume",
|
lowerVolume = { {}, "XF86AudioLowerVolume" },
|
||||||
|
|
||||||
-- Toggle mute
|
-- Toggle mute
|
||||||
toggleMute = "XF86AudioMute",
|
toggleMute = { {}, "XF86AudioMute" },
|
||||||
|
|
||||||
-- Toggle Play / Pause
|
-- Toggle Play / Pause
|
||||||
playPause = "XF86AudioPlay",
|
playPause = { {}, "XF86AudioPlay" },
|
||||||
|
|
||||||
-- Next track
|
-- Next track
|
||||||
nextTrack = "XF86AudioNext",
|
nextTrack = { {}, "XF86AudioNext" },
|
||||||
|
|
||||||
-- Previous track
|
-- Previous track
|
||||||
previousTrack = "XF86AudioPrev",
|
previousTrack = { {}, "XF86AudioPrev" },
|
||||||
},
|
},
|
||||||
|
|
||||||
|
-- Keyboard layout
|
||||||
|
keyboard_layout = {
|
||||||
|
-- Switch between layouts
|
||||||
|
switch = { { "Mod1" }, "Shift_L" },
|
||||||
|
|
||||||
|
-- Switch between layouts (alternative)
|
||||||
|
switch_alt = { { "Shift" }, "Alt_L" },
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -108,8 +114,17 @@ config.keys.global_keys = {
|
|||||||
-- Widgets
|
-- Widgets
|
||||||
--
|
--
|
||||||
config.widgets = {
|
config.widgets = {
|
||||||
|
-- Keyboard layout widget
|
||||||
|
keyboard_layout = {
|
||||||
|
enabled = true,
|
||||||
|
layouts = { "fr", "us" },
|
||||||
|
layout_switch_command = "setxkbmap",
|
||||||
|
},
|
||||||
|
|
||||||
-- Enable/disable the system resources monitoring widget
|
-- Enable/disable the system resources monitoring widget
|
||||||
system_resources = true,
|
system_resources = {
|
||||||
|
enabled = true,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -135,10 +150,6 @@ config.theme = awful.util.getdir("config") .. "/theme.lua"
|
|||||||
-- Screenshot utility
|
-- Screenshot utility
|
||||||
config.screenshot_utility_command = "flameshot gui"
|
config.screenshot_utility_command = "flameshot gui"
|
||||||
|
|
||||||
-- Keyboard layout
|
|
||||||
config.kbSwitchCmd = "setxkbmap"
|
|
||||||
config.kbLayouts = { "fr", "us" }
|
|
||||||
|
|
||||||
-- Run menu
|
-- Run menu
|
||||||
config.windowSwitcher = "rofi -show window -config " .. awful.util.getdir("config") .. "/assets/rofi/themes/paper-float.rasi"
|
config.windowSwitcher = "rofi -show window -config " .. awful.util.getdir("config") .. "/assets/rofi/themes/paper-float.rasi"
|
||||||
|
|
||||||
|
@ -4,6 +4,10 @@ local gears = require("gears")
|
|||||||
local global_keys = {}
|
local global_keys = {}
|
||||||
|
|
||||||
function make(hotkey, action, identity)
|
function make(hotkey, action, identity)
|
||||||
|
if hotkey == nil then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
local modifiers = hotkey[1]
|
local modifiers = hotkey[1]
|
||||||
local key = hotkey[2]
|
local key = hotkey[2]
|
||||||
return awful.key(modifiers, key, action, identity)
|
return awful.key(modifiers, key, action, identity)
|
||||||
|
@ -111,10 +111,18 @@ hotkey.registerKeys(media_control.getKeys(config.keys.global_keys.media_control)
|
|||||||
|
|
||||||
-- System resources
|
-- System resources
|
||||||
local system_resources_widget
|
local system_resources_widget
|
||||||
if config.widgets.system_resources then
|
if config.widgets.system_resources.enabled then
|
||||||
system_resources_widget = require("simple/widgets/system_resources")
|
system_resources_widget = require("simple/widgets/system_resources")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Keyboard map indicator and switcher
|
||||||
|
local keyboard_layout = require("simple/widgets/keyboard_layout")
|
||||||
|
local keyboard_layout_widget
|
||||||
|
if config.widgets.keyboard_layout.enabled then
|
||||||
|
keyboard_layout_widget = keyboard_layout.widget
|
||||||
|
end
|
||||||
|
hotkey.registerKeys(keyboard_layout.getKeys(config.keys.global_keys.keyboard_layout))
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Auto start
|
-- Auto start
|
||||||
@ -133,68 +141,31 @@ end
|
|||||||
--
|
--
|
||||||
-- Launcher (start menu)
|
-- Launcher (start menu)
|
||||||
--
|
--
|
||||||
local launcher = awful.widget.launcher({
|
local launcher = awful.widget.button({
|
||||||
image = beautiful.awesome_icon,
|
image = beautiful.awesome_icon,
|
||||||
menu = awful.menu({
|
|
||||||
items = {
|
|
||||||
{ "Hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
|
|
||||||
{ "Manual", config.awesome.terminal .. " -e man awesome" },
|
|
||||||
{ "Edit config", config.awesome.editor_cmd .. " " .. awesome.conffile },
|
|
||||||
{ "Open terminal", config.awesome.terminal }
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
|
launcher:buttons(gears.table.join(launcher:buttons(),
|
||||||
|
awful.button({}, 1, nil, showAppLauncher)))
|
||||||
-- Keyboard map indicator and switcher
|
|
||||||
mykeyboardlayout = awful.widget.keyboardlayout()
|
|
||||||
|
|
||||||
kbdlayout = {}
|
|
||||||
kbdlayout.cur = 1
|
|
||||||
kbdlayout.switch = function()
|
|
||||||
kbdlayout.cur = (kbdlayout.cur % #(config.kbLayouts)) + 1
|
|
||||||
local t = config.kbLayouts[kbdlayout.cur]
|
|
||||||
os.execute(config.kbSwitchCmd .. " " .. t)
|
|
||||||
end
|
|
||||||
|
|
||||||
shutdown_icon = awesome.load_image(awful.util.getdir("config") .. "/assets/icons/power.svg")
|
shutdown_icon = awesome.load_image(awful.util.getdir("config") .. "/assets/icons/power.svg")
|
||||||
restart_icon = awesome.load_image(awful.util.getdir("config") .. "/assets/icons/refresh-cw.svg")
|
restart_icon = awesome.load_image(awful.util.getdir("config") .. "/assets/icons/refresh-cw.svg")
|
||||||
logout_icon = awesome.load_image(awful.util.getdir("config") .. "/assets/icons/log-out.svg")
|
logout_icon = awesome.load_image(awful.util.getdir("config") .. "/assets/icons/log-out.svg")
|
||||||
lock_icon = awesome.load_image(awful.util.getdir("config") .. "/assets/icons/lock.svg")
|
lock_icon = awesome.load_image(awful.util.getdir("config") .. "/assets/icons/lock.svg")
|
||||||
|
|
||||||
shutdownMenu_items = {
|
os_menu = awful.widget.launcher({
|
||||||
{
|
|
||||||
"Shutdown",
|
|
||||||
function()
|
|
||||||
os.execute('shutdown now')
|
|
||||||
end,
|
|
||||||
shutdown_icon
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Restart",
|
|
||||||
function()
|
|
||||||
os.execute('shutdown -r now')
|
|
||||||
end,
|
|
||||||
restart_icon
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Logout",
|
|
||||||
function()
|
|
||||||
awesome.quit()
|
|
||||||
end,
|
|
||||||
logout_icon
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Lock",
|
|
||||||
function()
|
|
||||||
awful.spawn("xscreensaver-command -lock")
|
|
||||||
end,
|
|
||||||
lock_icon
|
|
||||||
}
|
|
||||||
}
|
|
||||||
shutdownMenu_launcher = awful.widget.launcher({
|
|
||||||
image = beautiful.awesome_icon,
|
image = beautiful.awesome_icon,
|
||||||
menu = awful.menu({ items = shutdownMenu_items })
|
menu = awful.menu({
|
||||||
|
items = {
|
||||||
|
{ "Hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
|
||||||
|
{ "Manual", config.awesome.terminal .. " -e man awesome" },
|
||||||
|
{ "Edit config", config.awesome.editor_cmd .. " " .. awesome.conffile },
|
||||||
|
{ "Open terminal", config.awesome.terminal },
|
||||||
|
{ "Lock", function() awful.spawn("xscreensaver-command -lock") end, lock_icon },
|
||||||
|
{ "Logout", function() awesome.quit() end, logout_icon },
|
||||||
|
{ "Restart", function() os.execute('shutdown -r now') end, restart_icon },
|
||||||
|
{ "Shutdown", function() os.execute('shutdown now') end, shutdown_icon },
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -332,20 +303,20 @@ awful.screen.connect_for_each_screen(function(s)
|
|||||||
{
|
{
|
||||||
-- Left widgets
|
-- Left widgets
|
||||||
layout = wibox.layout.fixed.horizontal,
|
layout = wibox.layout.fixed.horizontal,
|
||||||
mylauncher,
|
launcher,
|
||||||
s.mytaglist,
|
s.mytaglist,
|
||||||
s.mypromptbox,
|
s.mypromptbox,
|
||||||
},
|
},
|
||||||
s.mytasklist, -- Middle widget
|
s.mytasklist, -- Middle widget
|
||||||
{
|
{
|
||||||
-- Right widgets
|
-- Right widgets
|
||||||
matchesScreen(config.system_resources_widget_screens) and system_resources_widget.widget or nil,
|
|
||||||
layout = wibox.layout.fixed.horizontal,
|
layout = wibox.layout.fixed.horizontal,
|
||||||
mykeyboardlayout,
|
matchesScreen(config.system_resources_widget_screens) and system_resources_widget.widget or nil,
|
||||||
|
keyboard_layout_widget,
|
||||||
wibox.widget.systray(),
|
wibox.widget.systray(),
|
||||||
mytextclock,
|
mytextclock,
|
||||||
s.mylayoutbox,
|
s.mylayoutbox,
|
||||||
shutdownMenu_launcher,
|
os_menu,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
@ -453,11 +424,6 @@ hotkey.registerKeys(awful.key({ config.keys.modkey, }, "s", hotkeys_popup.show_h
|
|||||||
-- Menubar
|
-- Menubar
|
||||||
awful.key({ config.keys.modkey }, "space", function() os.execute(config.runMenu) end,
|
awful.key({ config.keys.modkey }, "space", function() os.execute(config.runMenu) end,
|
||||||
{ description = "show the run menu", group = "launcher" }),
|
{ description = "show the run menu", group = "launcher" }),
|
||||||
-- Keyboard layout switch
|
|
||||||
awful.key({ "Mod1" }, "Shift_L", function() kbdlayout.switch() end,
|
|
||||||
{ description = "switch keyboard layout" }),
|
|
||||||
awful.key({ "Shift" }, "Alt_L", function() kbdlayout.switch() end,
|
|
||||||
{ description = "switch keyboard layout" }),
|
|
||||||
-- Flameshot
|
-- Flameshot
|
||||||
awful.key({}, "Print", function() os.execute(config.screenshot_utility_command) end,
|
awful.key({}, "Print", function() os.execute(config.screenshot_utility_command) end,
|
||||||
{ description = "Take a screenshot using the screenshot utility", group = "utilities" }))
|
{ description = "Take a screenshot using the screenshot utility", group = "utilities" }))
|
||||||
|
@ -16,6 +16,8 @@ local gears = require("gears")
|
|||||||
local naughty = require("naughty")
|
local naughty = require("naughty")
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
|
|
||||||
|
local hotkey = require("simple/core/hotkey")
|
||||||
|
|
||||||
local config = require("config")
|
local config = require("config")
|
||||||
|
|
||||||
local hasPlayerctl = os.execute("playerctl -v") == true
|
local hasPlayerctl = os.execute("playerctl -v") == true
|
||||||
@ -183,20 +185,20 @@ end
|
|||||||
function getKeys(config)
|
function getKeys(config)
|
||||||
return
|
return
|
||||||
-- Volume control
|
-- Volume control
|
||||||
config.raiseVolume ~= nil and awful.key({}, config.raiseVolume, raiseVolume,
|
hotkey.make(config.raiseVolume, raiseVolume,
|
||||||
{ description = "Raise volume", group = "media control" }) or nil,
|
{ description = "Raise volume", group = "media control" }),
|
||||||
config.lowerVolume ~= nil and awful.key({}, config.lowerVolume, lowerVolume,
|
hotkey.make(config.lowerVolume, lowerVolume,
|
||||||
{ description = "Lower volume", group = "media control" }) or nil,
|
{ description = "Lower volume", group = "media control" }),
|
||||||
config.toggleMute ~= nil and awful.key({}, config.toggleMute, toggleMute,
|
hotkey.make(config.toggleMute, toggleMute,
|
||||||
{ description = "Toggle mute audio", group = "media control" }) or nil,
|
{ description = "Toggle mute audio", group = "media control" }),
|
||||||
|
|
||||||
-- Media control
|
-- Media control
|
||||||
config.playPause ~= nil and awful.key({}, config.playPause, playPause,
|
hotkey.make(config.playPause, playPause,
|
||||||
{ description = "Toggle Play / Pause", group = "media control" }) or nil,
|
{ description = "Toggle Play / Pause", group = "media control" }),
|
||||||
config.nextTrack ~= nil and awful.key({}, config.nextTrack, nextTrack,
|
hotkey.make(config.nextTrack, nextTrack,
|
||||||
{ description = "Next track", group = "media control" }) or nil,
|
{ description = "Next track", group = "media control" }),
|
||||||
config.previousTrack ~= nil and awful.key({}, config.previousTrack, previousTrack,
|
hotkey.make(config.previousTrack, previousTrack,
|
||||||
{ description = "Previous track", group = "media control" }) or nil
|
{ description = "Previous track", group = "media control" })
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
26
simple/widgets/keyboard_layout.lua
Normal file
26
simple/widgets/keyboard_layout.lua
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
local awful = require("awful")
|
||||||
|
|
||||||
|
local hotkey = require("simple/core/hotkey")
|
||||||
|
|
||||||
|
local config = require("config")
|
||||||
|
|
||||||
|
|
||||||
|
local widget = awful.widget.keyboardlayout()
|
||||||
|
local layouts = config.widgets.keyboard_layout.layouts
|
||||||
|
|
||||||
|
local current_layout_index = 1
|
||||||
|
function switchLayout()
|
||||||
|
current_layout_index = (current_layout_index % #(layouts)) + 1
|
||||||
|
os.execute(config.widgets.keyboard_layout.layout_switch_command .. " " .. layouts[current_layout_index])
|
||||||
|
end
|
||||||
|
|
||||||
|
return {
|
||||||
|
widget = widget,
|
||||||
|
switch = switchLayout,
|
||||||
|
getKeys = function(config)
|
||||||
|
return hotkey.make(config.switch, switchLayout,
|
||||||
|
{ description = "switch keyboard layout" }),
|
||||||
|
hotkey.make(config.switch_alt, switchLayout,
|
||||||
|
{ description = "switch keyboard layout (alternative)" })
|
||||||
|
end
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user