Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- v082 desktop changes
- -- Standard awesome library
- local gears = require("gears")
- local awful = require("awful")
- require("awful.autofocus")
- -- Widget and layout library
- local wibox = require("wibox")
- -- Theme handling library
- local beautiful = require("beautiful")
- -- Notification library
- local naughty = require("naughty")
- local vicious = require("vicious")
- local menubar = require("menubar")
- local hotkeys_popup = require("awful.hotkeys_popup").widget
- -- Freedesktop menu
- local freedesktop = require("freedesktop")
- -- Enable VIM help for hotkeys widget when client with matching name is opened:
- require("awful.hotkeys_popup.keys.vim")
- os.setlocale("ru_RU.UTF-8")
- -- {{{ Error handling
- --[[if awesome.startup_errors then
- naughty.notify({ preset = naughty.config.presets.critical, position = "bottom_left", timeout = 1,
- title = "Oops, there were errors during startup!",
- text = awesome.startup_errors })
- end
- -- Handle runtime errors after startup
- do
- local in_error = false
- awesome.connect_signal("debug::error", function (err)
- -- Make sure we don't go into an endless error loop
- if in_error then return end
- in_error = true
- naughty.notify({ preset = naughty.config.presets.critical, position = "bottom_left",
- title = "Oops, an error happened!",
- text = tostring(err) })
- in_error = false
- end)
- end
- --]]
- -- }}}
- -- {{{ Variable definitions
- -- Themes define colours, icons, font and wallpapers.
- config_dir = awful.util.getdir("config")
- user = string.match( awful.util.getdir("config"), '^/home/(%a+)')
- theme = "gtk3"
- beautiful.init( config_dir .. "themes/" .. theme .. "/theme.lua")
- local icons_size = beautiful.menu_height-2
- if beautiful.icon_theme == nil then beautiful.icon_theme = "Adwaita" end
- if beautiful.radius < 3 then beautiful.radius = 3 end
- if beautiful.radius > 9 then beautiful.radius = 9 end
- awesome.set_preferred_icon_size(beautiful.menu_height)
- -- This is used later as the default terminal and editor to run.
- browser = "firefox"
- --browser = "chromium"
- filemanager = "spacefm"
- gui_editor = "geany"
- terminal = os.getenv("TERMINAL") or "lxterminal"
- xterminal = "xterm"
- mocp_terminal = "sakura"
- vkboard = "onboard"
- smag = "xzoom"
- torrent_client = "qbittorrent"
- --torrent_client = "transmission-gtk"
- smixer_gui = "pavucontrol"
- geditor = "gimp"
- calc = "galculator"
- comixreader = "mcomix"
- mindmaps = "vym"
- rofi = "/usr/local/sbin/rofi-1.6.1"
- rofi_cmd_drun = rofi .. " -modi drun -show drun -config ~/.config/rofi/config-apps.rasi -theme ~/.config/rofi/theme-apps.rasi"
- rofi_cmd_run = rofi .. " -modi run -show run -config ~/.config/rofi/config.rasi -theme ~/.config/rofi/theme.rasi"
- rofi_cmd_combi = rofi .. " -show combi -combi-modi 'window,drun' -modi combi -config ~/.config/rofi/config.rasi -theme ~/.config/rofi/theme.rasi"
- rofi_cmd_window = rofi .. " -show window -modi window -config ~/.config/rofi/config.rasi -theme ~/.config/rofi/theme.rasi"
- rofi_file_browser = rofi .. " -modi drun,file-browser -show file-browser -config ~/.config/rofi/config-files.rasi -theme ~/.config/rofi/theme-files.rasi"
- -- scrot
- scrot_dir_command = "'mv $f /home/" .. user .. "/Pictures/PrintScreen/'"
- scr_full = "scrot -m -z -e " .. scrot_dir_command
- scr_area = "sleep 0.2; scrot -f -s -e " .. scrot_dir_command
- scr_area_delay = "sleep 0.2; scrot -d 5 -s -e " .. scrot_dir_command
- scr_active_window = "scrot -z -u -e " .. scrot_dir_command --]]
- --[[ Gnome-screenshot
- scr_full = "gnome-screenshot"
- scr_area = "sleep 0.2; gnome-screenshot -a"
- scr_area_delay = "sleep 0.2; gnome-screenshot -d 5"
- scr_active_window = "gnome-screenshot -w"--]]
- -- ~/.config/pulse/default.pa
- -- set-card-profile <card_name> output:<output_profile>+input:<input_profile>
- pa_sink_default = " alsa_output.pci-0000_00_1b.0.analog-stereo" --acer n/b, asus B75M-A
- --pa_sink_default = " alsa_output.pci-0000_00_14.2.analog-stereo" --ALC883 ASUS m2a-vm 5.1
- pa_sink = " "
- function dir_exists(dir)
- return os.rename(dir,dir)
- end
- local icons_path = "/usr/share/icons/" .. beautiful.icon_theme .. "/"
- if dir_exists(icons_path) == nil then icons_path = "/home/" .. user .. "/.icons/".. beautiful.icon_theme .. "/" end
- local theme_icons_size = "24x24"
- -- Icons
- beautiful.media_play = icons_path .. theme_icons_size .. "/actions/media-playback-start.png"
- beautiful.home = icons_path .. theme_icons_size .. "/actions/go-home.png"
- beautiful.media_next = icons_path .. theme_icons_size .. "/actions/media-skip-forward.png"
- beautiful.media_prev = icons_path .. theme_icons_size .. "/actions/media-skip-backward.png"
- beautiful.media_pause = icons_path .. theme_icons_size .. "/actions/media-playback-pause.png"
- beautiful.media_playlist = icons_path .. theme_icons_size .. "/actions/format-justify-fill.png"
- beautiful.media_shuffle = icons_path .. theme_icons_size .. "/status/media-playlist-shuffle.png"
- beautiful.media_repeat = icons_path .. theme_icons_size .. "/status/media-playlist-repeat.png"
- beautiful.close_key = icons_path .. theme_icons_size .. "/actions/window-close.png"
- -- Tags
- media_tag = "media"
- files_tag = "files"
- inet_tag = "web"
- misc_tag = "misc"
- modkey = "Mod4"
- -- Table of layouts to cover with awful.layout.inc, order matters.
- awful.layout.layouts = {
- awful.layout.suit.max,
- --awful.layout.suit.tile,
- --awful.layout.suit.floating,
- --awful.layout.suit.fair,
- --awful.layout.suit.spiral,
- --awful.layout.suit.spiral.dwindle,
- --awful.layout.suit.tile.left,
- awful.layout.suit.tile.bottom,
- --awful.layout.suit.tile.top,
- --awful.layout.suit.fair.horizontal,
- --awful.layout.suit.max.fullscreen,
- --awful.layout.suit.magnifier,
- --awful.layout.suit.corner.nw,
- --awful.layout.suit.corner.ne,
- --awful.layout.suit.corner.sw,
- --awful.layout.suit.corner.se,
- }
- -- }}}
- -- {{{ Helper functions
- function run_once(prg)
- if not prg then
- do return nil end
- end
- awful.spawn.with_shell("ps ux | grep -v grep | grep -q '" .. prg .. "' || (" .. prg .. ")")
- end
- function spawn_client_once(command,target_tag)
- run_once(command)
- local screen = awful.screen.focused() local tag = screen.tags[target_tag] if tag then tag:view_only() end
- end
- function client_menu_toggle_fn()
- local instance = nil
- return function ()
- if instance and instance.wibox.visible then
- instance:hide()
- instance = nil
- else
- instance = awful.menu.clients({ theme = { width = beautiful.menu_width*2 } })
- end
- end
- end
- screen_index_mark = function(n)
- if n.index == 1 then return "" else return n.index end
- end
- -- Net menu v2.1
- -- fsudo
- beautiful.net_wl = config_dir .. "/net_icons/network-wl.png"
- beautiful.net_wl_off = config_dir .. "/net_icons/network-cellular-offline.svg"
- beautiful.net_wl_none = config_dir .. "/net_icons/network-cellular-signal-none.svg"
- beautiful.net_wl_low = config_dir .. "/net_icons/network-cellular-signal-low.svg"
- beautiful.net_wl_ok = config_dir .. "/net_icons/network-cellular-signal-ok.svg"
- beautiful.net_wl_good = config_dir .. "/net_icons/network-cellular-signal-good.svg"
- beautiful.net_wl_full = config_dir .. "/net_icons/network-cellular-signal-excellent.svg"
- beautiful.net_en_off = config_dir .. "/net_icons/network-offline.svg"
- beautiful.net_en_on = config_dir .. "/net_icons/network-wired.svg"
- wifi_menu_exec = function ( iface, ap )
- awful.spawn.with_shell(xterminal .. " -geometry 30x10 -e 'wpa_connect2 " .. iface .. " " .. ap .. "'")
- end
- mywifimenu = awful.menu({ })
- function wifi_menu ( iface )
- local terms = {}
- awful.spawn.with_shell("fsudo -c | sudo -S ifconfig " .. iface .. " up")
- local aps = io.popen("fsudo -c | sudo -S iwlist ".. iface .. " scan 2>/dev/null | awk -F':' '/ESSID/{print $2}' | nl -w2 -n rz -s '=' ")
- for l in aps:lines() do
- local item = { l, function() wifi_menu_exec(iface,l) end }
- table.insert(terms, item)
- end
- aps:close()
- table.insert(terms, {"update", function() mywifimenu:hide() wifi_menu ( iface ) mywifimenu:update() mywifimenu:show() end })
- mywifimenu = awful.menu( {items = terms} )
- end
- net_menu_widget = wibox.widget.textbox(" ⇋") -- ⇵⇄ text widget
- --[[ icon widget
- net_menu_widget = wibox.widget {
- forced_height = 24,
- forced_width = 24,
- widget = wibox.widget.imagebox
- }
- net_menu_widget:set_resize(false)
- net_menu_widget:set_image(beautiful.net_en_off)
- net_menu_widget_timer = gears.timer { timeout = 5, autostart = true, call_now = true }
- net_menu_widget_timer:connect_signal("timeout", function()
- awful.spawn.easy_async({"bash", "-c", "ip -4 -br a"},
- function(out)
- local icon_chooser = ""
- --#https://stackoverflow.com/questions/68473020/lua-count-occurrences-of-a-character-into-a-string
- for l in string.gmatch( out, "(.-)\n" ) do
- local net_name = string.match(l, "^(%S+).*")
- local net_id = string.sub(net_name, 1, 2)
- if net_id ~= "lo" then
- if net_id == "wl" then
- local fd = io.popen("iwconfig " .. net_name)
- local wireless = fd:read("*all")
- fd:close()
- local unassociated = string.find(wireless, "Access Point: Not-Associated", 1, true)
- if not unassociated then
- local percent = tonumber(string.match(wireless, "Link Quality=(%d?%d?%d)"))
- if percent == 0 or nil then icon_chooser = beautiful.net_wl_off
- elseif percent > 0 and percent < 28 then icon_chooser = beautiful.net_wl_low
- elseif percent >= 28 and percent < 60 then icon_chooser = beautiful.net_wl_ok
- elseif percent >= 60 and percent < 95 then icon_chooser = beautiful.net_wl_good
- elseif percent >=95 then icon_chooser = beautiful.net_wl_full
- end
- --break
- end
- else
- icon_chooser = beautiful.net_en_on
- --break
- end
- end
- end
- if icon_chooser == "" then
- net_menu_widget:set_image(beautiful.net_en_off)
- else
- net_menu_widget:set_image(icon_chooser)
- end
- end)
- end
- )--]]
- net_menu_exec = function ( iface ) -- v2
- local cmd = xterminal .. " -geometry 30x10 -e "
- local onoff = ""
- local info = ""
- local onoff_cmd = ""
- local setup_title = ""
- local setup_title2 = ""
- local setup_cmd = ""
- local setup_cmd2 = ""
- local icon = beautiful.net_en_on
- local fd = io.popen("ip -4 l show " .. iface .. " && ip -4 a show " .. iface .. " && iwconfig " .. iface)
- local state = fd:read("*all")
- fd:close()
- local up_state = string.find(state, "inet ", 1, true)
- if up_state then
- onoff = "disconnect"
- onoff_cmd = cmd .. "\"fsudo -c | sudo -S -p ' ' netmenu_off " .. iface .. "\""
- local ip_local = string.match(state, "inet (%d*.%d*.%d*.%d*/%d*)")
- if ip_local == nil then info = " " else info = ip_local end
- else
- onoff = "connect"
- onoff_cmd = cmd .. "fsudo -c | sudo -S -p ' ' ifup " .. iface
- info = " "
- if string.find(state, "NO-CARRIER", 1, true) then info = " " end
- end
- if string.sub(iface, 1, 2) == "wl" then
- icon = beautiful.net_wl
- if not up_state then
- onoff = "last network"
- onoff_cmd = cmd .. " wpa_connect2 ".. iface .. " last &"
- end
- setup_title = "search Wi-Fi"
- setup_cmd = function() wifi_menu( iface ) mywifimenu:update() mywifimenu:show() end
- setup_title2 = "connect to hidden..."
- setup_cmd2 = cmd .. " wpa_connect2 ".. iface .. " hidden &"
- else
- setup_title = "Auto"
- setup_cmd = function() awful.spawn (cmd .. "\"fsudo -c | sudo -S -p ' ' dhclient " .. iface .. "\"") end
- setup_title2 = "Edit config"
- setup_cmd2 = cmd .. "sudo netmenu_new_conf " .. iface
- end
- return {
- { iface, _, icon },
- { " "..onoff, function() awful.spawn(onoff_cmd) end },
- { " setup", { { setup_title, setup_cmd }, --function() () end
- { "config",{ { "Static", function() awful.spawn(cmd .. "sudo netmenu_setup_iface " .. iface .. " s" ) end },
- { "Auto", function() awful.spawn(cmd .. "\"fsudo -c | sudo -S -p ' ' netmenu_setup_iface " .. iface .. " d\"") end },
- { "Manual", function() awful.spawn(cmd .. "\"fsudo -c | sudo -S -p ' ' netmenu_setup_iface " .. iface .. " m\"" ) end } } },
- { setup_title2, function() awful.spawn(setup_cmd2) end },
- } },
- { " "..info, _ }
- }
- end
- myifacemenu = awful.menu({ })
- function net_menu ()
- local terms = {}
- local nets = io.popen("ls /sys/class/net | tr ' ' '\n'")
- for l in nets:lines() do
- if l ~= "lo" then
- local item = net_menu_exec(l)
- for i=1,#item do
- terms[#terms+1] = item[i]
- end
- --table.insert(terms, item)
- --naughty.notify({ text = tostring(#item) })
- end
- end
- nets:close()
- myifacemenu = awful.menu( { items = terms, theme = {height = 24, width = 180, border_width = 1 } })
- end
- --net_menu()
- function net_menu_toggle_fn()
- instance = nil
- return function ()
- if instance and instance.wibox.visible then
- instance:hide()
- instance = nil
- else
- net_menu()
- instance = myifacemenu
- myifacemenu:update()
- myifacemenu:show()
- end
- end
- end
- net_menu_widget:buttons(gears.table.join(
- awful.button({ }, 1, net_menu_toggle_fn() )
- ))
- -- Display switch menu
- local function get_screen_id(s)
- local name = ""
- for i, e in pairs(s.outputs) do
- name = tostring(i)
- end
- return name
- end
- mydisplaymenu = awful.menu({ })
- local displayexec = config_dir .. "/displayexec.sh "
- function display_menu ()
- local current_display = get_screen_id(awful.screen.focused())
- local terms = {}
- local displays = io.popen("xrandr | grep ' connected' | awk {'print $1'}")
- for l in displays:lines() do
- if l ~= current_display then
- local item = l
- table.insert(terms, { current_display .. " <-> " .. item, {
- { "duplicate with " .. item, function() awful.spawn(displayexec .. current_display .. " duplicate " .. item) end },
- { "switch to " .. item, function() awful.spawn(displayexec .. current_display .. " switch " .. item) end },
- { "extend to " .. item, {
- {"left", function() awful.spawn(displayexec .. current_display .. " extend " .. item .. " left") end },
- {"above", function() awful.spawn(displayexec .. current_display .. " extend " .. item .. " above") end },
- {"right", function() awful.spawn(displayexec .. current_display .. " extend " .. item .. " right") end },
- {"below", function() awful.spawn(displayexec .. current_display .. " extend " .. item .. " below") end },
- }}}})
- end
- end
- displays:close()
- mydisplaymenu = awful.menu( { items = terms } )
- end
- function display_menu_toggle_fn()
- instance = nil
- return function ()
- if instance and instance.wibox.visible then
- instance:hide()
- instance = nil
- else
- display_menu()
- instance = mydisplaymenu
- mydisplaymenu:update()
- mydisplaymenu:show()
- end
- end
- end
- --display_widget = wibox.widget { widget = wibox.widget.textbox }
- --display_widget:set_text(" ▢ ")
- --display_widget:buttons(gears.table.join(
- -- awful.button({ }, 1, nil, display_menu_toggle_fn() )
- --))
- -- }}}
- -- {{{ Menu
- -- Create a launcher widget and a main menu
- myawesomemenu = {
- { "hotkeys", function() return false, hotkeys_popup.show_help end },
- { "manual", terminal .. " -e man awesome" },
- { "edit config", gui_editor .. " " .. awesome.conffile },
- { "restart", awesome.restart }
- }
- myaccessmenu = {
- { "keyboard", vkboard },
- { "magnifier", smag },
- { "screenshot", scr_full }
- }
- myappsmenu = {
- { "mocp", mocp_terminal .. " -e /usr/bin/mocp" },
- { "geany", gui_editor },
- { "terminal", terminal },
- { "xterm", xterminal },
- { "calculator", calc },
- { "mComix", comixreader },
- { "torrent client", torrent_client },
- { "gimp", geditor },
- { "mind map", mindmaps },
- { "accessibility", myaccessmenu },
- { "run command", rofi_cmd_run },
- { "all apps", rofi_cmd_drun },
- --{ "run command cmb", rofi_cmd_combi },
- --{ "run command wnd", rofi_cmd_window },
- }
- myexitmenu = {
- { "display", 'xset dpms force off' },
- { "log out", function() awesome.quit() end },
- { "suspend", "systemctl suspend" },
- { "hibernate", "systemctl hibernate" },
- { "reboot", "systemctl reboot -i" },
- { "shutdown", "systemctl poweroff" }
- }
- myexitmenu_now = awful.menu ( myexitmenu )
- mysetupmenu = {
- { "✿ theme", config_dir .. "/theme_switch.sh" },
- { "⇋ network", net_menu_toggle_fn()},
- { "▢ display", display_menu_toggle_fn()},
- { "♫ sound", smixer_gui },
- { "⎙ printer", browser .. " http://localhost:631" },
- { "awesomewm", myawesomemenu, beautiful.awesome_icon }
- }
- mymainmenu = awful.menu ({
- --mymainmenu = freedesktop.menu.build ({
- --before = {
- { "files", filemanager },
- { "browser", browser },
- -- other triads can be put here
- --},
- --after = {
- { "apps", myappsmenu },
- { "setup", mysetupmenu },
- { "exit", "rofi-shutdown-menu.sh" },
- -- other triads can be put here
- --}
- })
- --mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
- -- menu = mymainmenu,
- -- --command = rofi_cmd_combi,
- --})
- --mylauncher:set_forced_width(beautiful.menu_height)
- --mylauncher:set_forced_height(beautiful.menu_height)
- mylauncher = wibox.widget {
- forced_height = beautiful.menu_height,
- forced_width = beautiful.menu_height,
- widget = wibox.widget.imagebox
- }
- mylauncher:set_resize(true)
- mylauncher:set_image(beautiful.awesome_icon)
- mylauncher:buttons(gears.table.join(
- awful.button({ }, 1, nil, function () mymainmenu:toggle() end),
- awful.button({ }, 3, nil, function () mouse.screen.tray_popup_vert.visible = not mouse.screen.tray_popup_vert.visible end)
- ))
- mylauncher:connect_signal("mouse::enter", function() mylauncher:set_image(beautiful.awesome_icon_hover) end)
- mylauncher:connect_signal("mouse::leave", function() mylauncher:set_image(beautiful.awesome_icon) end)
- mykeyboardlayout = awful.widget.keyboardlayout()
- -- Menubar configuration
- menubar.utils.terminal = terminal -- Set the terminal for applications that require it
- -- }}}
- -- {{{ Wibar
- separator = wibox.widget.textbox('<span color="' .. beautiful.border_focus .. '">⋅</span>') -- ⋮∙
- separator:set_forced_width(beautiful.menu_height)
- separator:set_forced_height(beautiful.menu_height)
- volumebar = wibox.widget {
- widget = wibox.widget.progressbar,
- margins = 5,
- shape = gears.shape.rounded_bar,
- color = beautiful.border_focus,
- background_color = "#000000",
- max_value = 100,
- }
- sound_widget = wibox.widget {
- widget = wibox.widget.textbox,
- align = 'center',
- valign = 'center',
- forced_height = beautiful.menu_height,
- forced_width = beautiful.menu_height
- }
- sound_widget:set_markup("<span color='" .. beautiful.border_focus .. "'>♫</span>\n")
- function get_volume_level(vol_string, vol_format)
- local volume_level = string.match(vol_string, vol_format)
- if volume_level == nil then volume_level=0x0000 end
- volume_level = tonumber(string.format("%04x", volume_level),"16")
- return volume_level
- end
- -- Volume widget (pa) v2
- volumecfg = {}
- volumecfg = wibox.widget.textbox( )
- volumecfg.pa_init = false
- volumecfg.get_sink = function ()
- if not volumecfg.pa_init then
- local fd = io.popen("pacmd dump | grep -e set-sink-volume")
- local status = fd:read("*all")
- pa_sink = string.match(status, "^.*( [^%s]+) ")
- if pa_sink == nil then pa_sink = pa_sink_default end
- fd:close()
- volumecfg.pa_init = true
- else
- awful.spawn.easy_async({"bash", "-c","pacmd dump | grep -e set-sink-volume"},
- function(out)
- pa_sink = string.match(out, "^.*( [^%s]+) ")
- end)
- end
- end
- volumecfg.mixercommand = function (pa_command)
- awful.spawn.easy_async({"bash", "-c", pa_command .. " && pacmd dump | grep -e set-sink-volume -e set-sink-mute"},
- function(out)
- volume_f = get_volume_level(out, "(0x%x%x%x%x?%x)")
- local volume_p = math.ceil(volume_f/655)
- local volume = tostring(volume_p)
- local unmuted = string.find(out, " no", 1, true)
- volumebar:set_value(volume_p)
- if unmuted then volume = "♫" .. volume volumebar:set_color(beautiful.border_focus)
- else volume = "♩....." volumebar:set_color(beautiful.fg_minimize)
- end
- volumecfg:set_text(volume)
- end)
- end
- volumecfg.update = function ()
- volumecfg.get_sink()
- volumecfg.mixercommand("pactl set-sink-volume " .. pa_sink .. " +0")
- end
- volumecfg.update()
- volumecfg.up = function ()
- volumecfg.get_sink()
- local add_volume = " +1310"
- if (volume_f+1310)> 65500 then add_volume = " 65500" end
- volumecfg.mixercommand("pactl set-sink-volume " .. pa_sink .. add_volume)
- mouse.screen.popup_volume.visible = true mouse.screen.popup_volume_timer:again()
- end
- volumecfg.down = function ()
- volumecfg.get_sink()
- volumecfg.mixercommand("pactl set-sink-volume " .. pa_sink .. " -1310") mouse.screen.popup_volume.visible = true mouse.screen.popup_volume_timer:again()
- end
- volumecfg.toggle = function ()
- volumecfg.get_sink()
- volumecfg.mixercommand("pactl set-sink-mute " .. pa_sink .. " toggle") mouse.screen.popup_volume.visible = true mouse.screen.popup_volume_timer:again()
- end
- volumebar:buttons(gears.table.join(
- --awful.button({ }, 1, function () volumecfg.toggle() end),
- awful.button({ }, 4, function () volumecfg.up() end),
- awful.button({ }, 5, function () volumecfg.down() end)
- ))
- -- clickable volume bar
- volumebar:connect_signal("button::press", function(_,xpl,_,b,_,fwr)
- local volume = math.ceil(65500 * xpl/fwr.height)
- if b == 1 then volumecfg.get_sink() volumecfg.mixercommand("pactl set-sink-volume " .. pa_sink .. " " .. volume ) end
- end)
- volumebar:connect_signal("button::release", function(_,xpl,_,b,_,fwr)
- local volume = math.ceil(65500 * xpl/fwr.height)
- if b == 1 then volumecfg.get_sink() volumecfg.mixercommand("pactl set-sink-volume " .. pa_sink .. " " .. volume ) end
- end)
- volumecfg:buttons(gears.table.join(
- awful.button({ }, 4, function () volumecfg.up() end),
- awful.button({ }, 5, function () volumecfg.down() end),
- awful.button({ }, 3, function () awful.spawn(smixer_gui) end),
- awful.button({ }, 2, function () volumecfg.update() end),
- awful.button({ }, 1, function () volumecfg.toggle() end)
- ))
- -- Create a textclock widget and calendar
- mytextclock = wibox.widget.textclock(" %H:%M ")
- local calendar = wibox.widget {
- date = os.date('*t'),
- font = "Helvetica Neue " .. beautiful.base_size,
- --forced_width = 250,
- long_weekdays = true,
- widget = wibox.widget.calendar.month,
- }
- mytextdate = wibox.widget {
- widget = wibox.widget.textclock("%d"),
- font = "Helvetica Neue " .. beautiful.base_size,
- align = 'center',
- valign = 'center',
- forced_width = 250,
- }
- mytexthours = wibox.widget {
- widget = wibox.widget.textclock("%H"),
- font = "Helvetica Neue " .. beautiful.menu_height + 6,
- align = 'right',
- valign = 'bottom',
- }
- mytextminutes = wibox.widget {
- widget = wibox.widget.textclock("%M"),
- font = "Helvetica Neue " .. beautiful.base_size + 6,
- align = 'left',
- valign = 'top',
- }
- popup_date_dt = awful.popup {
- ontop = false,
- visible = true,
- bg = string.sub(beautiful.bg_normal, 1, 7) .. "00",
- fg = beautiful.fg_normal,
- placement = function (self) awful.placement.top_right(self, { margins = { top = 10, right = beautiful.menu_height + 40 } }) end,
- widget = {
- {
- { widget = mytexthours },
- { widget = mytextminutes },
- layout = wibox.layout.fixed.horizontal,
- },
- top = 1,
- bottom = 1,
- widget = wibox.container.margin,
- },
- }
- popup_date = awful.popup {
- ontop = true,
- visible = false,
- placement = function (self) awful.placement.top_right (self, { margins = { top = beautiful.menu_height + 40, right = 10 } }) end,
- bg = string.sub(beautiful.bg_normal, 1, 7),
- fg = beautiful.fg_normal,
- shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, beautiful.radius-1) end,
- widget = {
- {
- --{
- -- { widget = mytexthours },
- -- { widget = mytextminutes },
- -- layout = wibox.layout.flex.horizontal,
- --},
- {
- { widget = mytextdate },
- { widget = calendar },
- layout = wibox.layout.fixed.vertical,
- expand = 'none',
- },
- layout = wibox.layout.fixed.vertical,
- },
- margins = beautiful.menu_height,
- widget = wibox.container.margin,
- }
- }
- popup_date:buttons(gears.table.join(
- awful.button({}, 3, nil, function()
- local a = calendar:get_date()
- a.month = a.month + 1
- calendar:set_date(nil)
- calendar:set_date(a)
- end),
- awful.button({}, 2, nil, function()
- calendar:set_date(nil) -- the new date is not set without removing the old one
- calendar:set_date(os.date('*t'))
- end),
- awful.button({}, 1, nil, function()
- local a = calendar:get_date()
- a.month = a.month - 1
- calendar:set_date(nil)
- calendar:set_date(a)
- end)
- ))
- popup_date_dt:connect_signal("button::press",
- function(_, _, _, button)
- if button == 1 then
- if popup_date.visible then
- -- to faster render the calendar refresh it and just hide
- calendar:set_date(nil) -- the new date is not set without removing the old one
- calendar:set_date(os.date('*t'))
- --popup_date:set_widget(nil) -- just in case
- --popup_date:set_widget(calendar)
- popup_date.visible = not popup_date.visible
- else
- popup_date.visible = true
- end
- end
- end
- )
- -- MOC widget
- mocwidget = {}
- mocwidget.w_title = wibox.widget {
- widget = wibox.widget.textbox,
- forced_height = beautiful.menu_height,
- forced_width = beautiful.menu_width
- }
- mocwidget.w_artist = wibox.widget {
- widget = wibox.widget.textbox,
- forced_height = beautiful.menu_height,
- forced_width = beautiful.menu_width
- }
- mocwidget.w_album = wibox.widget {
- widget = wibox.widget.textbox,
- forced_height = beautiful.menu_height,
- forced_width = beautiful.menu_width
- }
- mocline = wibox.widget {
- widget = wibox.widget.progressbar,
- forced_height = beautiful.base_size - 3,
- forced_width = beautiful.menu_width,
- background_color = beautiful.notification_bg,
- shape = gears.shape.rounded_bar,
- color = beautiful.border_focus,
- max_value = 1,
- }
- function hook_moc()
- awful.spawn.easy_async({"bash", "-c", "mocp -i"},
- function(out)
- moc_info = out
- end
- )
- if moc_info == nil then moc_info = "State: STOP" end
- moc_state = string.gsub(string.match(moc_info, "State: %a*"),"State: ","")
- if moc_state == "STOP" or nil then
- moc_string = " ..."
- mocline.visible = false
- mocp_pause_button:set_image(beautiful.media_play)
- elseif moc_state == "PLAY" or moc_state == "PAUSE" then
- if moc_state == "PAUSE" then
- mocline.visible = false
- mocp_pause_button:set_image(beautiful.media_play)
- return
- end
- moc_artist = string.gsub(string.match(moc_info, "Artist: %C*"), "Artist: ","")
- moc_title = string.gsub(string.match(moc_info, "SongTitle: %C*"), "SongTitle: ","")
- moc_album = string.gsub(string.match(moc_info, "Album: %C*"), "Album: ","")
- moc_path = string.gsub(string.match(moc_info, "File: %C*"), "File: ", "")
- moc_file = string.gsub(moc_path, "^.*/","")
- moc_artist = string.gsub(moc_artist, "&", "&")
- if string.len(moc_title) >=75 then moc_title = " title" else if string.len(moc_artist) >= 85 then moc_artist = "VA " end end
- moc_title = string.gsub(moc_title, "&", "&")
- moc_album = string.gsub(moc_album, "&", "&")
- moc_file = string.gsub(moc_file, "&", "&")
- moc_cs = string.gsub(string.match(moc_info, "CurrentSec: %d+"),"CurrentSec: ","")
- ts = string.match(moc_info, "TotalSec: %d+")
- if ts ~= nil then moc_ts = string.gsub(ts,"TotalSec: ","") else moc_ts = 0 end
- if moc_artist == "" or nil then moc_artist = "unknown artist" end
- if moc_title == "" or nil then moc_title = moc_file end
- if moc_album == "" or nil then moc_album = "unknown album" end
- moc_play_lineval = moc_cs/moc_ts
- moc_play_percentage = math.floor(moc_play_lineval*100)
- if moc_state == "PLAY" then mocline.visible = true mocp_pause_button:set_image(beautiful.media_pause) end
- mocline:set_value(moc_play_lineval)
- end
- mocwidget.w_title:set_text(moc_title or " ")
- mocwidget.w_artist:set_text("@ " .. moc_artist or " ")
- mocwidget.w_album:set_text("⦾ " .. moc_album or " ")
- end
- mocwidget.t = gears.timer { timeout = 1 }
- mocwidget.t:connect_signal("timeout", function() hook_moc() end)
- -- clickable progressbar
- mocline:connect_signal("button::press", function(_,xpl,_,b,_,fwr)
- local percent = math.floor(100 * xpl/fwr.width)
- local cmd = "mocp -j " .. percent .. "%"
- if b == 1 then awful.spawn.with_shell(cmd) end
- end)
- -- mocp functions
- function mocp_pause()
- local fd = io.popen("mocp -i")
- local moc_info = fd:read("*all")
- fd:close()
- local moc_state = string.gsub(string.match(moc_info, "State: %a*"),"State: ","")
- if moc_state == "PLAY" then
- awful.spawn.with_shell("mocp -P")
- elseif moc_state == "PAUSE" then
- awful.spawn.with_shell("mocp -U")
- end
- return false
- end
- function mocp_func(f)
- -- -Ppause -fnext -rprev -pplaylist -cclear -k{ +|-N}seek -t{ shuffle|repeat}toggle
- awful.spawn.with_shell( "mocp -" .. f )
- return false
- end
- function mocp_enqueue()
- awful.spawn.with_shell("xte 'key a'")
- return false
- end
- mocline:buttons(gears.table.join(
- awful.button({ }, 5, function () mocp_func("k -10") end),
- awful.button({ }, 4, function () mocp_func("k +10") end)
- ))
- mocp_play_button = wibox.widget {
- widget = wibox.widget.textbox,
- --visible = false
- }
- mocp_play_button:set_markup("<span color='" .. beautiful.border_focus .. "'> ▷</span>")
- --mocp_play_button:set_text(" ▷ ")
- mocp_play_button:buttons(gears.table.join(
- awful.button({ }, 3, nil,function () spawn_client_once(mocp_terminal .. " -e /usr/bin/mocp",3) end)
- ))
- mocp_album_cover = wibox.widget {
- forced_height = beautiful.menu_height * 4,
- forced_width = beautiful.menu_height * 4,
- resize = true,
- widget = wibox.widget.imagebox,
- }
- mocp_album_cover:set_image("/home/" .. user .. "/.moc/default_album.png")
- mocp_album_cover:buttons(gears.table.join(
- awful.button({ }, 1, function () awful.spawn.with_shell("xte 'key Return'") end),
- awful.button({ }, 2, function () awful.spawn.with_shell("xte 'key Tab'") end),
- awful.button({ }, 3, function () awful.spawn.with_shell("xte 'key BackSpace'") end),
- awful.button({ }, 4, function () awful.spawn.with_shell("xte 'key Up'") end),
- awful.button({ }, 5, function () awful.spawn.with_shell("xte 'key Down'") end)
- ))
- mocp_pause_button = wibox.widget {
- forced_height = icons_size,
- forced_width = icons_size,
- widget = wibox.widget.imagebox
- }
- mocp_pause_button:set_resize(true)
- mocp_pause_button:set_image(beautiful.media_play)
- mocp_pause_button:buttons(gears.table.join(
- awful.button({ }, 1, nil, function() mocp_pause() end),
- awful.button({ }, 3, nil, function() local c = client.focus if c.class == "Sakura" then awful.spawn.with_shell("xte 'keydown Shift_L' 'key g' 'keyup Shift_L'") end end)
- ))
- mocp_pause_button.tip = awful.tooltip { delay_show = 2 }
- mocp_pause_button.tip:add_to_object(mocp_pause_button)
- mocp_pause_button.tip.text = "1 - play\n3 - go dir"
- mocp_next_button = wibox.widget {
- forced_height = icons_size,
- forced_width = icons_size,
- widget = wibox.widget.imagebox
- }
- mocp_next_button:set_resize(true)
- mocp_next_button:set_image(beautiful.media_next)
- mocp_next_button:buttons(gears.table.join(
- awful.button({ }, 1, nil, function() mocp_func("f") end)
- ))
- mocp_prev_button = wibox.widget {
- forced_height = icons_size,
- forced_width = icons_size,
- widget = wibox.widget.imagebox
- }
- mocp_prev_button:set_resize(true)
- mocp_prev_button:set_image(beautiful.media_prev)
- mocp_prev_button:buttons(gears.table.join(
- awful.button({ }, 1, nil, function() mocp_func("r") end)
- ))
- mocp_playlist_button = wibox.widget {
- forced_height = icons_size,
- forced_width = icons_size,
- widget = wibox.widget.imagebox
- }
- mocp_playlist_button:set_resize(true)
- mocp_playlist_button:set_image(beautiful.media_playlist)
- mocp_playlist_button:buttons(gears.table.join(
- awful.button({ }, 1, nil, function() mocp_func("p") end),
- awful.button({ }, 2, nil, function() mocp_func("c") end),
- awful.button({ }, 3, nil, function() local c = client.focus if c.class == "Sakura" then mocp_enqueue() end end)
- ))
- mocp_playlist_button.tip = awful.tooltip { delay_show = 2 }
- mocp_playlist_button.tip:add_to_object(mocp_playlist_button)
- mocp_playlist_button.tip.text = "1 - play\n2 - clear\n3 - add"
- mocp_shuffle_button = wibox.widget {
- forced_height = icons_size,
- forced_width = icons_size,
- widget = wibox.widget.imagebox
- }
- mocp_shuffle_button:set_resize(true)
- mocp_shuffle_button:set_image(beautiful.media_shuffle)
- mocp_shuffle_button:buttons(gears.table.join(
- awful.button({ }, 1, nil, function() mocp_func("t shuffle") end)
- ))
- mocp_repeat_button = wibox.widget {
- forced_height = icons_size,
- forced_width = icons_size,
- widget = wibox.widget.imagebox
- }
- mocp_repeat_button:set_resize(true)
- mocp_repeat_button:set_image(beautiful.media_repeat)
- mocp_repeat_button:buttons(gears.table.join(
- awful.button({ }, 1, nil, function() mocp_func("t repeat") end)
- ))
- -- Scrot
- scr_button = wibox.widget {
- widget = wibox.widget.textbox,
- --visible = false
- }
- scr_button:set_text(" ⬚")
- scr_button:buttons(gears.table.join(
- awful.button({ }, 1, function () awful.spawn.with_shell(scr_area) end),
- awful.button({ }, 2, function () awful.spawn.with_shell(scr_full) end),
- awful.button({ }, 3, function () awful.spawn.with_shell(scr_area_delay) end)
- ))
- mocp_play_button:connect_signal("button::press",
- function(_, _, _, button)
- if button == 1 then
- if mouse.screen.popup_mocp.visible then
- mouse.screen.popup_mocp.visible = not mouse.screen.popup_mocp.visible
- mocwidget.t:stop()
- else
- mouse.screen.popup_mocp.visible = true
- mocwidget.t:start()
- mocp_album_cover:set_image(gears.surface.load_uncached("/home/" .. user .. "/.moc/current_album.png"))
- end
- end
- end
- )
- -- unused
- --[[ Battery indicator (example)(v082r)
- mybatterybar = wibox.widget {
- {
- min_value = 0,
- max_value = 100,
- color = beautiful.border_focus,
- background_color = beautiful.bg_normal,
- border_width = 1,
- border_color = beautiful.border_focus,
- forced_width = beautiful.menu_height,
- forced_height = beautiful.menu_height - 4,
- shape = function(cr) -- custom scalable shape
- local h = beautiful.menu_height
- cr:move_to(0, h/2 )
- cr:line_to(0, h - 6 * h/23 )
- cr:line_to(h - h/8, h - 6 * h/23 )
- cr:line_to(h - h/8, h/2 - 3 * h/23)
- cr:line_to(h - 1, h/2 - 3* h/23 )
- cr:line_to(h - 1, h/2 + h/23 )
- cr:line_to(h - h/8, h/2 + h/23 )
- cr:line_to(h - h/8, 4 * h/23 )
- cr:line_to(0, 4 * h/23 )
- cr:close_path()
- end,
- id = "mypb",
- widget = wibox.widget.progressbar,
- value = 0,
- },
- {
- id = "mytb",
- text = "0",
- --valign = "top",
- widget = wibox.widget.textbox,
- font = beautiful.font_name .. " " .. math.ceil(beautiful.menu_height/2.45),
- },
- layout = wibox.layout.stack,
- set_battery = function(self, val)
- if beautiful.menu_height < 25 then self.mytb.text = " "
- else self.mytb.text = " " .. val end
- self.mypb.value = val
- end
- }
- local battery_tooltip = " "
- gears.timer {
- timeout = 5,
- call_now = true,
- autostart = true,
- callback = function()
- awful.spawn.easy_async({"bash", "-c", "acpi"},
- function(out)
- local percent = tonumber(string.match(out, "(%d?%d?%d)%%"))
- battery_state = string.match(out, ": (%a+),")
- battery_time = tostring(string.match(out, "(%d%d:%d%d):"))
- if battery_state == nil then battery_state = "n/a" end
- if percent == 100 then battery_time = " full" end
- if percent == nil then percent = 0 end
- if percent < 11 and battery_state == "Discharging" then awful.spawn("systemctl suspend") end
- mybatterybar.battery = percent
- battery_tooltip = "<span size='xx-large'>" .. percent .. "%</span>\n\n" .. battery_state .. ": " .. battery_time .. "\n"
- end
- )
- end
- }
- local mybattery_t = awful.tooltip { delay_show = 1.5 }
- mybattery_t:add_to_object(mybatterybar)
- mybatterybar:connect_signal('mouse::enter', function()
- mybattery_t.markup = battery_tooltip
- end)--]]
- -- Kanji show widget
- --[[kanji = {}
- kanji.w = wibox.widget {
- widget = wibox.widget.textbox,
- text = " 漢字 "
- }
- kanji.t = awful.tooltip { }
- kanji.t:add_to_object(kanji.w)
- kanji.timer = gears.timer {
- timeout = 120,
- call_now = true,
- autostart = true,
- callback = function()
- awful.spawn.easy_async({"bash", "-c", "cat ".. config_dir .. "/jlpt5_4_list.txt | head -n`shuf -i 1-320 -n 1` | tail -n1"},
- function(out)
- local kanji_current = string.match(out, "^(.*);.*;")
- local on_kun = string.match(out, ";(.*);")
- local rus = string.match(out, "^.*;(.*)$")
- kanji.w:set_text(kanji_current)
- kanji.t.text = on_kun .. "\n" .. rus
- end
- )
- end
- }--]]
- -- Create a wibox for each screen and add it
- local taglist_buttons = gears.table.join(
- awful.button({ }, 1, function(t) t:view_only() end),
- awful.button({ modkey }, 1, function(t)
- if client.focus then
- client.focus:move_to_tag(t)
- end
- end),
- --[[ awful.button({ }, 2, function(t)
- if client.focus then
- local c = client.focus
- if c.fullscreen then
- c.fullscreen = not c.fullscreen
- else c.fullscreen = true
- end
- end
- end),--]]
- --awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
- --awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end),
- awful.button({ }, 3, awful.tag.viewtoggle),
- awful.button({ modkey }, 3, function(t)
- if client.focus then
- client.focus:toggle_tag(t)
- end
- end)
- )
- local tasklist_buttons = gears.table.join(
- awful.button({ }, 1, function (c)
- if c == client.focus then
- c.minimized = true
- else
- -- Without this, the following
- -- :isvisible() makes no sense
- c.minimized = false
- if not c:isvisible() and c.first_tag then
- c.first_tag:view_only()
- end
- -- This will also un-minimize
- -- the client, if needed
- client.focus = c
- c:raise()
- end
- end),
- awful.button({ }, 2, function (c)
- if c:isvisible() then
- c.first_tag:view_only()
- end
- client.focus = c
- c:kill()
- end),
- --awful.button({ }, 4, function () awful.client.focus.byidx(1) end),
- --awful.button({ }, 5, function () awful.client.focus.byidx(-1) end)),
- awful.button({ }, 3, client_menu_toggle_fn() )
- )
- -- Wallpaper
- local function set_wallpaper(s)
- if beautiful.wallpaper then
- local wallpaper = beautiful.wallpaper
- -- If wallpaper is a function, call it with the screen
- if type(wallpaper) == "function" then
- wallpaper = wallpaper(s)
- else
- -- set (pattern) Set the current wallpaper.
- -- centered (surf, s, background, scale) Set a centered wallpaper.
- -- tiled (surf, s, offset) Set a tiled wallpaper.
- -- maximized (surf, s, ignore_aspect, offset) Set a maximized wallpaper.
- -- fit (surf, s, background) Set a fitting wallpaper.
- gears.wallpaper.maximized(wallpaper, s, false)
- end
- end
- end
- -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
- screen.connect_signal("property::geometry", set_wallpaper)
- empty_widget = wibox.widget {
- widget = wibox.widget.textbox,
- }
- empty_widget:set_text(" ")
- --empty_widget:set_forced_width(5)
- --empty_widget:set_forced_height(beautiful.menu_height)
- awful.screen.connect_for_each_screen(function(s)
- -- Wallpaper
- set_wallpaper(s)
- -- Tags
- if s.index == 1 then
- awful.tag.add(inet_tag, {
- --icon = "/path/to/icon1.png",
- --gap_single_client = true,
- --master_fill_policy = "master_width_factor",
- layout = awful.layout.suit.tile,
- master_width_factor = 0.71,
- master_count = 1,
- --gap = 5,
- screen = 1,
- selected = true,
- index = 1,
- })
- awful.tag.add(misc_tag, {
- layout = awful.layout.suit.fair,
- screen = 1,
- index = 2,
- })
- awful.tag.add(media_tag, {
- layout = awful.layout.suit.max,
- screen = 1,
- index = 3,
- })
- awful.tag.add(files_tag, {
- layout = awful.layout.suit.spiral.dwindle,
- screen = 1,
- index = 4,
- })
- else
- awful.tag.add("Screen " .. screen_index_mark(s), {
- layout = awful.layout.suit.spiral.dwindle,
- screen = s,
- index = 1,
- --gap = 0,
- selected = true,
- })
- end
- -- Create a promptbox for each screen
- s.mypromptbox = awful.widget.prompt()
- -- Create an imagebox widget which will contains an icon indicating which layout we're using.
- -- We need one layoutbox per screen.
- --s.mylayoutbox = awful.widget.layoutbox()
- s.mylayoutbox = wibox.widget {
- {
- awful.widget.layoutbox(s),
- top = math.ceil(beautiful.base_size/2.5),
- left = math.ceil(beautiful.base_size/2.5),
- right = math.ceil(beautiful.base_size/3.5),
- widget = wibox.container.margin,
- },
- bg = beautiful.bg_normal,
- widget = wibox.container.background,
- }
- s.mylayoutbox:buttons(gears.table.join(
- --awful.button({ }, 4, function () awful.layout.inc( 1) end),
- --awful.button({ }, 5, function () awful.layout.inc(-1) end),
- awful.button({ }, 1, function () awful.layout.inc( 1) end),
- awful.button({ }, 3, function () awful.layout.inc(-1) end)
- ))
- s.mylayoutbox:set_forced_width(beautiful.menu_height - 4)
- s.mylayoutbox:set_forced_height(beautiful.menu_height)
- -- Volume popup
- s.popup_volume = awful.popup {
- ontop = true,
- visible = false,
- screen = s,
- shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, beautiful.radius-1) end,
- placement = function(self,s) awful.placement.top_right( self, { margins = { top = beautiful.menu_height, right = beautiful.menu_height } }) end,
- widget = {
- {
- {
- { widget = volumebar },
- forced_height = beautiful.menu_height*5,
- forced_width = beautiful.menu_height,
- direction = 'east',
- layout = wibox.container.rotate,
- },
- { widget = sound_widget },
- layout = wibox.layout.fixed.vertical,
- },
- widget = wibox.container.margin,
- },
- }
- s.popup_volume_timer = gears.timer { timeout = 2.1 }
- s.popup_volume_timer:connect_signal("timeout", function() s.popup_volume.visible = false s.popup_volume_timer:stop() end)
- s.popup_volume:connect_signal("mouse::enter", function(w) s.popup_volume.visible = true s.popup_volume_timer:again() end)
- s.popup_volume:connect_signal("mouse::move", function(w) s.popup_volume.visible = true s.popup_volume_timer:again() end)
- -- Mocp popup
- s.popup_mocp = awful.popup {
- ontop = true,
- visible = false,
- screen = s,
- shape = function(cr, width, height) gears.shape.partially_rounded_rect(cr, width, height, true, true, false, true, beautiful.radius-1 ) end,
- placement = function(self) awful.placement.right( self, { margins = { right = beautiful.menu_height + 40 } }) end,
- border_width = 1,
- border_color = beautiful.border_focus,
- widget = {
- {
- {
- {
- {
- {
- { widget = mocp_album_cover, },
- bg = beautiful.bg_normal,
- shape_clip = true,
- shape = function(cr, width, height) gears.shape.partially_rounded_rect(cr, width, height, true, true, false, true, (beautiful.radius-1)*2) end,
- widget = wibox.container.background,
- },
- margins = 5,
- widget = wibox.container.margin,
- },
- {
- {
- { widget = mocp_playlist_button },
- { widget = mocp_shuffle_button },
- { widget = mocp_repeat_button },
- layout = wibox.layout.align.horizontal,
- expand = 'none',
- },
- { widget = mocwidget.w_artist },
- { widget = mocwidget.w_album },
- { widget = mocwidget.w_title },
- layout = wibox.layout.fixed.vertical,
- },
- layout = wibox.layout.fixed.horizontal,
- },
- layout = wibox.layout.fixed.horizontal,
- },
- { widget = mocline },
- {
- { widget = mocp_prev_button },
- { widget = mocp_pause_button },
- { widget = mocp_next_button },
- layout = wibox.layout.align.horizontal,
- expand = 'none',
- },
- layout = wibox.layout.fixed.vertical,
- },
- margins = 10,
- widget = wibox.container.margin,
- },
- }
- -- Create a taglist widget
- s.mytaglist = awful.widget.taglist { --(s, awful.widget.taglist.filter.all, taglist_buttons)
- screen = s,
- filter = awful.widget.taglist.filter.all,
- buttons = taglist_buttons,
- forced_height = beautiful.menu_height,
- --style = { shape = function(cr, width, height) gears.shape.rounded_rect (cr, width, height, beautiful.radius) end, },
- widget_template = {
- {
- {
- layout = wibox.layout.fixed.vertical,
- {
- {
- left = 1,
- right = 1,
- top = math.ceil(beautiful.menu_height/3), -- slider height
- widget = wibox.container.margin
- },
- id = 'slider',
- bg = '#ffffff',
- forced_width = math.ceil(beautiful.menu_height/2),
- shape = function(cr, width, height) gears.shape.rounded_bar (cr, math.ceil(beautiful.menu_height/4), math.ceil(beautiful.menu_height/4)) end,
- widget = wibox.container.background,
- },
- --{
- --{
- --id = 'text_role',
- --widget = wibox.widget.textbox,
- --},
- --left = 1,
- --top = -1,
- --right = 1,
- --widget = wibox.container.margin,
- --}
- },
- top = math.ceil(beautiful.menu_height/3),
- left = math.ceil(beautiful.menu_height/3),
- right = 0,
- widget = wibox.container.margin,
- },
- id = 'background_role',
- widget = wibox.container.background,
- create_callback = function(self, c3, index, objects)
- local focused = false
- for _, x in pairs(awful.screen.focused().selected_tags) do
- if x.index == index then
- focused = true
- break
- end
- end
- if awful.tag.getproperty(c3, "urgent") then
- self:get_children_by_id("slider")[1].bg = beautiful.bg_urgent
- else
- self:get_children_by_id("slider")[1].bg = beautiful.border_focus
- end
- if focused then
- self:get_children_by_id("slider")[1].shape = function(cr, width, height) gears.shape.rounded_bar (cr, math.ceil(beautiful.menu_height/2), math.ceil(beautiful.menu_height/4)) end
- else
- self:get_children_by_id("slider")[1].shape = function(cr, width, height) gears.shape.rounded_bar (cr, math.ceil(beautiful.menu_height/4), math.ceil(beautiful.menu_height/4)) end
- end
- end,
- update_callback = function(self, c3, index, objects)
- local focused = false
- for _, x in pairs(awful.screen.focused().selected_tags) do
- if x.index == index then
- focused = true
- break
- end
- end
- if awful.tag.getproperty(c3, "urgent") then
- self:get_children_by_id("slider")[1].bg = beautiful.bg_urgent
- else
- self:get_children_by_id("slider")[1].bg = beautiful.border_focus
- end
- if focused then
- self:get_children_by_id("slider")[1].shape = function(cr, width, height) gears.shape.rounded_bar (cr, math.ceil(beautiful.menu_height/2), math.ceil(beautiful.menu_height/4)) end
- else
- self:get_children_by_id("slider")[1].shape = function(cr, width, height) gears.shape.rounded_bar (cr, math.ceil(beautiful.menu_height/4), math.ceil(beautiful.menu_height/4)) end
- end
- end
- },
- layout = {
- spacing = 2,
- layout = wibox.layout.fixed.horizontal,
- },
- }
- -- Create a tasklist widget
- s.mytasklist = awful.widget.tasklist {
- screen = s,
- filter = awful.widget.tasklist.filter.alltags,
- buttons = tasklist_buttons,
- style = {
- shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, beautiful.radius-1) end,
- },
- layout = {
- spacing = 10,
- forced_num_rows = 1,
- layout = wibox.layout.grid.horizontal,
- },
- widget_template = {
- {
- {
- id = 'clienticon',
- widget = awful.widget.clienticon,
- },
- margins = 1,
- widget = wibox.container.margin,
- },
- id = 'background_role',
- forced_width = beautiful.menu_height,
- forced_height = beautiful.menu_height,
- widget = wibox.container.background,
- create_callback = function(self, c, index, objects) --luacheck: no unused
- self:get_children_by_id('clienticon')[1].client = c
- -- tooltip v1
- -- todo: destroy, reload, signals
- --local c_tip = awful.tooltip { delay_show = 1.5 }
- --c_tip:add_to_object(self)
- --c_tip.text = c.name
- end,
- },
- }
- s.task_popup_bar = awful.popup {
- ontop = false,
- visible = true,
- screen = s,
- border_width = 0,
- border_color = beautiful.border_focus,
- forced_height = beautiful.menu_height,
- shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, beautiful.radius-1) end,
- placement = function (self,s) awful.placement.top_left( self, { margins = { top = 10, left = 10 } }) end,
- widget = {
- {
- mylauncher,
- --mybatterybar,
- s.mytaglist,
- s.mytasklist,
- spacing = 10,
- layout = wibox.layout.fixed.horizontal,
- fill_space = false,
- },
- margins = 10,
- widget = wibox.container.margin,
- }
- }
- s.task_popup_bar:buttons(gears.table.join(
- awful.button({ }, 1, function () s.task_popup_bar:draw() end)
- ))
- -- Task popup (example)
- s.task_popup = awful.popup {
- screen = s,
- border_color = beautiful.border_normal,
- border_width = 2,
- ontop = true,
- placement = awful.placement.centered,
- shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 10) end,
- visible = false,
- widget = awful.widget.tasklist {
- screen = s,
- filter = awful.widget.tasklist.filter.allscreen,
- buttons = tasklist_buttons,
- style = {
- shape = function(cr, width, height) gears.shape.rounded_rect(cr, width, height, 6) end,
- },
- layout = {
- spacing = 5,
- forced_num_rows = 1,
- layout = wibox.layout.grid.horizontal
- },
- widget_template = {
- {
- {
- id = 'clienticon',
- widget = awful.widget.clienticon,
- },
- margins = 4,
- widget = wibox.container.margin,
- },
- id = 'background_role',
- forced_width = beautiful.menu_height*2,
- forced_height = beautiful.menu_height*2,
- widget = wibox.container.background,
- create_callback = function(self, c, index, objects) --luacheck: no unused
- self:get_children_by_id('clienticon')[1].client = c
- end,
- },
- },
- }
- s.task_popup_timer = gears.timer { timeout = 2 }
- s.task_popup_timer:connect_signal("timeout", function() s.task_popup.visible = false s.task_popup_timer:stop() end)
- s.task_popup:connect_signal("mouse::enter", function(w)
- w.visible = true s.task_popup_timer:again()
- end)
- s.task_popup:connect_signal("mouse::move", function(w)
- w.visible = true s.task_popup_timer:again()
- end)
- s.mysystray = wibox.widget.systray()
- s.mysystray:set_base_size(beautiful.menu_height)
- s.mysystray:set_horizontal(false)
- s.mysystray:set_screen(s)
- s.mysystray:set_reverse(true)
- s.tray_popup_vert = awful.popup {
- ontop = true,
- visible = false,
- shape = function(cr, width, height) gears.shape.rounded_rect (cr, width, height, beautiful.radius-1) end,
- screen = s,
- placement = function (self,s) awful.placement.top_left( self, { margins = { top = beautiful.menu_height + 40, left = 10 } }) end,
- widget = {
- {
- s.mysystray,
- layout = wibox.layout.fixed.vertical,
- forced_width = beautiful.menu_height,
- },
- margins = 10,
- widget = wibox.container.margin,
- },
- }
- s.tray_popup_vert:buttons(gears.table.join(
- awful.button({ }, 2, function () s.tray_popup_vert.visible = not s.tray_popup_vert.visible end)
- ))
- -- Side bar
- s.sidebar_min = awful.popup {
- ontop = true,
- screen = s,
- visible = true,
- shape = function(cr, width, height) gears.shape.partially_rounded_rect (cr, width, height, true, false, false, true, beautiful.radius-1) end,
- placement = function (self,s) awful.placement.right( self ) end,
- widget = {
- { widget = empty_widget },
- layout = wibox.layout.align.vertical,
- forced_height = beautiful.menu_height*8,
- forced_width = 2,
- expand = 'outside',
- },
- }
- s.sidebar_min:buttons(gears.table.join(
- awful.button({ }, 4, function () volumecfg.up() end),
- awful.button({ }, 5, function () volumecfg.down() end)
- ))
- s.sidebar = awful.popup {
- ontop = true,
- visible = false,
- shape = function(cr, width, height) gears.shape.partially_rounded_rect (cr, width, height, true, false, false, true, beautiful.radius-1) end,
- screen = s,
- placement = function (self,s) awful.placement.right( self ) end,
- widget = {
- {
- {
- {
- mytextclock,
- layout = wibox.layout.fixed.vertical,
- },
- volumecfg,
- {
- mykeyboardlayout,
- mocp_play_button,
- net_menu_widget,
- scr_button,
- s.mylayoutbox,
- layout = wibox.layout.grid.vertical,
- forced_num_rows = 3,
- forced_num_cols = 2,
- homogeneous = true,
- expand = false,
- },
- forced_height = beautiful.menu_height*8,
- layout = wibox.layout.align.vertical,
- expand = 'inside',
- },
- layout = wibox.layout.fixed.vertical
- },
- margins = 10,
- widget = wibox.container.margin,
- },
- }
- s.sidebar:buttons(gears.table.join(
- awful.button({ }, 4, function () volumecfg.up() end),
- awful.button({ }, 5, function () volumecfg.down() end)
- ))
- s.sidebar_timer = gears.timer { timeout = 3 }
- s.sidebar_timer:connect_signal("timeout", function(t) s.sidebar.visible = false s.sidebar_min.visible = true t:stop() end)
- s.sidebar_min:connect_signal("mouse::enter", function(w) s.sidebar.visible = true w.visible = false end)
- s.sidebar:connect_signal("mouse::leave", function(w) s.sidebar_timer:again() end)
- end)
- -- }}}
- -- {{{ Mouse bindings
- root.buttons(gears.table.join(
- --awful.button({ }, 4, awful.tag.viewnext),
- --awful.button({ }, 5, awful.tag.viewprev),
- --awful.button({ }, 3, client_menu_toggle_fn() ),
- awful.button({ }, 1, function () mymainmenu:hide() myifacemenu:hide() end)
- ))
- -- }}}
- -- Test window switcher
- local tiled_c = false
- local tiled = function()
- if tiled_c == false then awful.client.focus.byidx(-1) awful.layout.inc(1) tiled_c = true
- else awful.layout.inc(1) tiled_c = false
- end
- end
- -- Show task popup
- local function task_popup_play_tab()
- for s in screen do
- s.task_popup.visible = true s.task_popup_timer:again()
- end
- local all_clients = awful.client.iterate(function (x) return true end)
- for c in awful.client.iterate(function (x) return true end) do
- if client.focus ~= c then
- awful.tag.viewmore(c:tags(), c.screen)
- client.focus = c
- client.focus:raise()
- c:emit_signal("request::activate", "ewmh", {raise = true})
- return
- end
- end
- end
- local function task_popup_play()
- mouse.screen.task_popup.visible = true mouse.screen.task_popup_timer:again()
- end
- -- {{{ Key bindings
- globalkeys = gears.table.join(
- awful.key({ modkey }, "e", function () awful.spawn(rofi_file_browser) end,
- {description = "rofi file browser", group = "rofi"}),
- awful.key({ modkey }, "a", function () awful.spawn(rofi_cmd_drun) end,
- {description = "rofi drun", group = "rofi"}),
- awful.key({ modkey, }, "s", hotkeys_popup.show_help,
- {description="show help", group="awesome"}),
- awful.key({ modkey, }, "Right", function() awful.tag.viewidx(1) task_popup_play() end,
- {description = "view previous", group = "tag"}),
- awful.key({ modkey, }, "Left", function() awful.tag.viewidx(-1) task_popup_play() end,
- {description = "view next", group = "tag"}),
- awful.key({ modkey, }, "Escape", awful.tag.history.restore,
- {description = "go back", group = "tag"}),
- awful.key({ modkey, }, "Up",
- function ()
- awful.client.focus.byidx( 1) task_popup_play()
- end,
- {description = "focus next by index", group = "client"}
- ),
- awful.key({ modkey, }, "Down",
- function ()
- awful.client.focus.byidx(-1) task_popup_play()
- end,
- {description = "focus previous by index", group = "client"}
- ),
- awful.key({ modkey, }, "w", function () mymainmenu:show() end,
- --awful.key({ modkey, }, "w", function () awful.spawn(rofi_cmd_window) end,
- {description = "show main menu", group = "awesome"}),
- -- Layout manipulation
- awful.key({ modkey, "Shift" }, "Right", function () awful.client.swap.byidx( 1) end,
- {description = "swap with next client by index", group = "client"}),
- awful.key({ modkey, "Shift" }, "Left", function () awful.client.swap.byidx( -1) end,
- {description = "swap with previous client by index", group = "client"}),
- awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
- {description = "focus the next screen", group = "screen"}),
- awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
- {description = "focus the previous screen", group = "screen"}),
- awful.key({ modkey, }, "u", function() awful.client.urgent.jumpto() end,
- {description = "jump to urgent client", group = "client"}),
- awful.key({ modkey, "Shift" }, "Tab", client_menu_toggle_fn(),
- {description = "open client menu", group = "client"}),
- awful.key({ modkey, }, "Tab", function () task_popup_play_tab() end,
- {description = "switch windows via popup", group = "client"}),
- --[[awful.key({ modkey, }, "Tab",
- function ()
- task_popup.visible = true task_popup_timer:again()
- local all_clients = awful.client.iterate(function (x) return true end)
- for c in awful.client.iterate(function (x) return true end) do
- if client.focus ~= c then
- awful.tag.viewmore(c:tags(), c.screen)
- client.focus = c
- client.focus:raise()
- c:emit_signal("request::activate", "ewmh", {raise = true})
- return
- end
- end
- end,
- {description = "switch clients", group = "client"}),--]]
- -- Standard program
- awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
- {description = "open a terminal", group = "launcher"}),
- awful.key({ modkey, }, "z", function () awful.spawn("rofi-translate-run-enru") end,
- {description = "open a rofi translate", group = "launcher"}),
- awful.key({ modkey, "Shift" }, "z", function () awful.spawn("rofi-translate-run-ruen") end,
- {description = "open a rofi translate", group = "launcher"}),
- awful.key({ modkey, "Control" }, "r", awesome.restart,
- {description = "reload awesome", group = "awesome"}),
- awful.key({ modkey, "Shift" }, "q", awesome.quit,
- {description = "quit awesome", group = "awesome"}),
- awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
- {description = "increase master width factor", group = "layout"}),
- awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
- {description = "decrease master width factor", group = "layout"}),
- awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
- {description = "increase the number of master clients", group = "layout"}),
- awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
- {description = "decrease the number of master clients", group = "layout"}),
- awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
- {description = "increase the number of columns", group = "layout"}),
- awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
- {description = "decrease the number of columns", group = "layout"}),
- awful.key({ modkey, }, "space", function () awful.layout.inc(-1) end,
- {description = "select previous", group = "layout"}),
- awful.key({ modkey }, "b", function () awful.spawn(browser) end,
- {description = "launch Browser", group = "launcher"}),
- awful.key({ modkey, "Control" }, "d", display_menu_toggle_fn(),
- {description = "show display_switch menu", group = "menu"}),
- awful.key({ }, "Print", function () awful.spawn.with_shell(scr_full) end,
- {description = "capture a screenshot", group = "screenshot"}),
- awful.key({ modkey, }, "Print", function () awful.spawn.with_shell(scr_area) end,
- {description = "capture a screenshot of a selection", group = "screenshot"}),
- awful.key({ modkey, "Shift" }, "Print", function () awful.spawn.with_shell(scr_active_window) end,
- {description = "capture a screenshot of an active window", group = "screenshot"}),
- awful.key({ modkey, "Shift" }, "n", net_menu_toggle_fn(),
- {description = "net menu", group = "menu"}),
- awful.key({ modkey, "Control" }, "n",
- function ()
- local c = awful.client.restore()
- -- Focus restored client
- if c then
- client.focus = c
- c:raise()
- end
- end,
- {description = "restore minimized", group = "client"}),
- -- Prompt
- awful.key({ modkey }, "r", function () awful.spawn(rofi_cmd_run)
- --awful.screen.focused().mypromptbox:run()
- end,
- {description = "run prompt", group = "launcher"}),
- --[[awful.key({ modkey, "Shift" }, "r",
- function ()
- awful.prompt.run {
- prompt = "Run Lua code: ",
- textbox = awful.screen.focused().mypromptbox.widget,
- exe_callback = awful.util.eval,
- history_path = awful.util.get_cache_dir() .. "/history_eval"
- }
- end,
- {description = "lua execute prompt", group = "awesome"}),--]]
- -- Menubar
- awful.key({ modkey }, "p", function() menubar.show() end,
- {description = "show the menubar", group = "launcher"}),
- -- XF86
- --awful.key({ }, "XF86WakeUp", function () volumecfg.down() end),
- --awful.key({ }, "XF86Display", function() end ),
- awful.key({ }, "XF86Sleep", function () awful.spawn("rofi-shutdown-menu.sh") end,
- {description = "show poweroff screen", group = "mediakeys"}),
- awful.key({ }, "XF86PowerOff", function () awful.spawn("rofi-shutdown-menu.sh") end,
- {description = "show poweroff screen", group = "mediakeys"}),
- awful.key({ }, "XF86AudioMute", function () volumecfg.toggle() end,
- {description = "toggle mute", group = "mediakeys"}),
- awful.key({ }, "XF86AudioRaiseVolume", function () volumecfg.up() end,
- {description = "volume up", group = "mediakeys"}),
- awful.key({ }, "XF86AudioLowerVolume", function () volumecfg.down() end,
- {description = "volume down", group = "mediakeys"}),
- awful.key({ }, "XF86Calculator", function() awful.spawn(calc) end,
- {description = "run calculator", group = "mediakeys"}),
- awful.key({ }, "XF86AudioMedia", function() spawn_client_once(mocp_terminal .. " -e /usr/bin/mocp",3) end,
- {description = "run player", group = "mediakeys"})
- )
- clientkeys = gears.table.join(
- awful.key({ modkey, }, "f",
- function (c)
- c.fullscreen = not c.fullscreen
- c:raise()
- end,
- {description = "toggle fullscreen", group = "client"}),
- awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
- {description = "close", group = "client"}),
- awful.key({ modkey, "Control" }, "space", function (c) c.floating = not c.floating end,
- {description = "toggle floating", group = "client"}),
- awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
- {description = "move to master", group = "client"}),
- awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
- {description = "move to screen", group = "client"}),
- awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
- {description = "toggle tray popup", group = "popup"}),
- awful.key({ modkey, "Control" }, "t", function () mouse.screen.tray_popup_vert.visible = not mouse.screen.tray_popup_vert.visible end,
- {description = "toggle keep on top", group = "client"}),
- awful.key({ modkey, "Shift" }, "t",
- function (c)
- t = awful.tag.add(c.class or "N/A", {screen=c.screen, volatile=true})
- if not t then return end
- local tags = c:tags()
- table.insert(tags, t)
- c:tags(tags)
- c:move_to_tag(t)
- awful.tag.viewonly(t)
- end,
- {description = "move client to new tag", group = "client"}),
- awful.key({ modkey, }, "n",
- function (c)
- -- The client currently has the input focus, so it cannot be
- -- minimized, since minimized clients can't have the focus.
- c.minimized = true
- end ,
- {description = "minimize", group = "client"}),
- awful.key({ modkey, }, "m",
- function (c)
- c.maximized = not c.maximized
- c:raise()
- end ,
- {description = "ex((un)maximize) raise sakura terminal with mocp client", group = "client"}),
- awful.key({ modkey, "Control" }, "m",
- function (c)
- c.maximized_vertical = not c.maximized_vertical
- c:raise()
- end ,
- {description = "(un)maximize vertically", group = "client"}),
- awful.key({ modkey, "Shift" }, "m",
- function (c)
- c.maximized_horizontal = not c.maximized_horizontal
- c:raise()
- end ,
- {description = "(un)maximize horizontally", group = "client"})
- )
- -- Bind all key numbers to tags.
- -- 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.
- for i = 1, 9 do
- globalkeys = gears.table.join(globalkeys,
- -- View tag only.
- awful.key({ modkey }, "#" .. i + 9,
- function ()
- local screen = awful.screen.focused()
- local tag = screen.tags[i]
- if tag then
- tag:view_only()
- end
- end,
- {description = "view tag #"..i, group = "tag"}),
- -- Toggle tag display.
- awful.key({ modkey, "Control" }, "#" .. i + 9,
- function ()
- local screen = awful.screen.focused()
- local tag = screen.tags[i]
- if tag then
- awful.tag.viewtoggle(tag)
- end
- end,
- {description = "toggle tag #" .. i, group = "tag"}),
- -- Move client to tag.
- awful.key({ modkey, "Shift" }, "#" .. i + 9,
- function ()
- if client.focus then
- local tag = client.focus.screen.tags[i]
- if tag then
- client.focus:move_to_tag(tag)
- end
- end
- end,
- {description = "move focused client to tag #"..i, group = "tag"}),
- -- Toggle tag on focused client.
- awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
- function ()
- if client.focus then
- local tag = client.focus.screen.tags[i]
- if tag then
- client.focus:toggle_tag(tag)
- end
- end
- end,
- {description = "toggle focused client on tag #" .. i, group = "tag"})
- )
- end
- clientbuttons = gears.table.join(
- awful.button({ }, 1, function (c) if c.name ~= "Onboard" then -- unfocusable screen keyboard
- client.focus = c
- end
- c:raise()
- mymainmenu:hide()
- myexitmenu_now:hide()
- for s in screen do s.popup_mocp.visible = false end
- if mocwidget.t.started then mocwidget.t:stop() end
- end),
- awful.button({ modkey }, 1, awful.mouse.client.move),
- awful.button({ modkey }, 3, awful.mouse.client.resize)
- )
- -- Set keys
- root.keys(globalkeys)
- -- }}}
- -- {{{ Rules
- -- Rules to apply to new clients (through the "manage" signal).
- awful.rules.rules = {
- -- All clients will match this rule.
- { rule = { },
- properties = { border_width = beautiful.border_width,
- --border_color = beautiful.border_normal,
- titlebars_enabled = true,
- focus = awful.client.focus.filter,
- raise = true,
- keys = clientkeys,
- buttons = clientbuttons,
- size_hints_honor = false, -- Remove gaps between terminals
- screen = 1,--awful.screen.preferred,
- maximized = false,
- callback = awful.client.setslave,
- placement = awful.placement.no_overlap+awful.placement.no_offscreen
- }
- },
- -- Add titlebars to normal clients and dialogs
- { rule_any = {type = { "normal", "dialog" } },
- properties = { titlebars_enabled = true }
- },
- -- Floating clients
- { rule_any = {
- class = {
- "Pavucontrol",
- "Xarchiver",
- "Calcoo",
- "Galculator",
- "Wine",
- "Qemu-system-x86_64",
- "Gtk-theme-switch2",
- "Gtk-chtheme",
- "discord",
- "Discord",
- "libreoffice",
- "Geany",
- "Gnome-screenshot",
- "Xsane"
- },
- name = {
- "Event Tester", -- xev.
- },
- role = {
- "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
- }
- }, properties = { floating = true, titlebars_enabled = true, placement = awful.placement.centered, maximized = false } },
- { rule = { class = "Sakura" },
- properties = { tag = media_tag, switchtotag = true } },
- { rule_any = { class = { "qpdfview", "Viewnior", "MComix", "Gimp" } },
- properties = { titlebars_enabled = true } },
- { rule_any = { class = { "qBittorrent", "Transmission-gtk" } },
- properties = { tag = inet_tag, switchtotag = true, titlebars_enabled = true } },
- { rule = { role = "browser" },
- properties = { tag = inet_tag, switchtotag = true, floating = false } },
- { rule = { role = "GtkFileChooserDialog" },
- properties = { floating = true, placement = awful.placement.centered, titlebars_enabled = true } },
- { rule = { role = "file_manager" },
- properties = { tag = files_tag, switchtotag = true, switchtotag = true } },
- { rule = { name = "Поиск файлов" },
- properties = { titlebars_enabled = true } },
- { rule_any = { class = { "X-terminal-emulator", "Lxterminal" } },
- properties = { tag = misc_tag, switchtotag = true } },
- { rule_any = { role = { "PictureInPicture", "text_dialog", "task_dialog", "rename_dialog" } },
- properties = { titlebars_enabled = true, ontop = true, floating = true, maximized = false, sticky = true, placement = awful.placement.centered
- } },
- { rule = { class = "XTerm" },
- --callback = function(c)
- -- local w_area = screen[ awful.screen.focused().index ].workarea
- -- c:geometry( { y = math.ceil(w_area.height/2) } )
- -- end,
- --properties = { titlebars_enabled = true, focus = true, ontop = true, floating = true, maximized_horizontal = true, maximized_vertical = false, sticky = true
- properties = { placement = awful.placement.bottom_right, focus = true, ontop = false, floating = true, maximized_horizontal = false, maximized_vertical = false, sticky = true,
- } },
- { rule_any = { class = { "mpv", "vlc" } },
- callback = function(c)
- awful.spawn.with_shell("mocp -P")
- end,
- properties = { titlebars_enabled = true } },
- { rule = { class = "Onboard" },
- properties = { titlebars_enabled = false, floating = true, focusable = false, focus = false, ontop = true, --hidden = true,
- } },
- { rule = { icon_name = "xzoom" },
- properties = { titlebars_enabled = true, floating = true, focusable = false, focus = false, ontop = true, sticky = true, placement = awful.placement.centered
- } },
- }
- -- }}}
- -- {{{ Signals
- -- Signal function to execute when a new client appears.
- client.connect_signal("manage", function (c)
- c.border_color = beautiful.bg_normal
- -- Set the windows at the slave,
- -- i.e. put it at the end of others instead of setting it master.
- -- if not awesome.startup then awful.client.setslave(c) end
- --awful.client.setslave(c)
- if awesome.startup and
- not c.size_hints.user_position
- and not c.size_hints.program_position then
- -- Prevent clients from being unreachable after screen count changes.
- awful.placement.no_offscreen(c)
- end
- end)
- awful.titlebar.enable_tooltip = false
- -- https://r.nf/r/awesomewm/comments/oahc1a/quick_guide_how_to_create_a_double_border_effect/
- -- Add a titlebar if titlebars_enabled is set to true in the rules.
- client.connect_signal("request::titlebars", function(c)
- local titlebar_right = {
- awful.titlebar.widget.stickybutton (c),
- awful.titlebar.widget.ontopbutton (c),
- awful.titlebar.widget.floatingbutton (c),
- layout = wibox.layout.fixed.horizontal(),
- }
- local titlebar_left = {
- --mykeyboardlayout,
- awful.titlebar.widget.maximizedbutton(c),
- awful.titlebar.widget.minimizebutton (c),
- layout = wibox.layout.fixed.horizontal(),
- }
- -- buttons for the titlebar
- local buttons = gears.table.join(
- awful.button({ }, 1, function()
- c:emit_signal("request::activate", "titlebar", {raise = true})
- awful.mouse.client.move(c)
- end),
- awful.button({ }, 3, function()
- c:emit_signal("request::activate", "titlebar", {raise = true})
- awful.mouse.client.resize(c)
- end)
- )
- local top_titlebar = awful.titlebar(c, {
- size = 4,
- enable_tooltip = false,
- position = 'top',
- }) : setup {
- {
- {
- bg = c.border_color,
- widget = wibox.container.background,
- },
- top = 2,
- left = 2,
- right = 2,
- widget = wibox.container.margin
- },
- bg = c.border_color,
- widget = wibox.container.background,
- }
- local bottom_titlebar = awful.titlebar(c, {
- size = beautiful.menu_height+15,
- enable_tooltip = false,
- position = 'bottom',
- })
- bottom_titlebar:setup {
- { -- Right
- {
- {
- {
- awful.titlebar.widget.closebutton (c),
- top = 4, bottom = 4,
- widget = wibox.container.margin,
- },
- layout = wibox.layout.fixed.horizontal,
- },
- titlebar_left,
- layout = wibox.layout.fixed.horizontal,
- spacing = 5,
- },
- margins = 10,
- widget = wibox.container.margin,
- },
- { -- Middle
- { -- Title
- align = "center",
- font = beautiful.font_name .. " " .. tostring(math.ceil(0.85*beautiful.base_size)),
- widget = awful.titlebar.widget.titlewidget(c)
- },
- buttons = buttons,
- expand = "inside",
- layout = wibox.layout.flex.horizontal
- },
- { -- Right
- {
- titlebar_right,
- {
- awful.titlebar.widget.iconwidget(c),
- buttons = buttons,
- layout = wibox.layout.fixed.horizontal,
- },
- layout = wibox.layout.fixed.horizontal,
- spacing = 5,
- },
- margins = 10,
- widget = wibox.container.margin,
- },
- layout = wibox.layout.align.horizontal,
- }
- local left_titlebar = awful.titlebar(c, {
- size = 4,
- enable_tooltip = false,
- position = 'left',
- })
- left_titlebar:setup {
- {
- {
- bg = c.border_color,
- widget = wibox.container.background
- },
- left = 2,
- widget = wibox.container.margin
- },
- bg = c.border_color,
- widget = wibox.container.background,
- }
- local right_titlebar = awful.titlebar(c, {
- size = 4,
- enable_tooltip = false,
- position = 'right',
- })
- right_titlebar:setup {
- {
- {
- bg = c.border_color,
- widget = wibox.container.background
- },
- right = 2,
- widget = wibox.container.margin
- },
- bg = c.border_color,
- widget = wibox.container.background
- }
- end)
- -- OnSongChange.sh signal
- awesome.connect_signal("music::changed",
- function()
- mocp_album_cover:set_image(gears.surface.load_uncached("/home/" .. user .. "/.moc/current_album.png"))
- end
- )
- client.connect_signal("property::size", function(c)
- if c.fullscreen then
- c.shape = gears.shape.rectangle
- else c.shape = function(cr,w,h) gears.shape.rounded_rect(cr,w,h,beautiful.radius-1) end
- end
- end
- )
- -- unused
- --[[ Enable sloppy focus, so that focus follows mouse.
- client.connect_signal("mouse::enter", function(c)
- if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
- and awful.client.focus.filter(c) then
- client.focus = c
- end
- 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)
- --[[ hint: focus client under mouse
- tag.connect_signal("property::selected",
- function (t)
- local selected = tostring(t.selected) == "true"
- if selected then
- local mouseX = mouse.coords().x
- local mouseY = mouse.coords().y
- for k,v in pairs(t.screen.all_clients) do
- if v.first_tag.index==t.index and mouseX>=v.x and mouseX<=(v.x+v.width) and mouseY>=v.y and mouseY<=(v.y+v.height) then
- client.focus = v
- v:raise()
- end
- end
- end
- end
- )
- client.connect_signal("property::fullscreen", function(c)
- c.shape = gears.shape.rectangle
- end
- )
- client.connect_signal("property::floating", function (c)
- if c.floating then
- awful.titlebar.show(c)
- else
- awful.titlebar.hide(c)
- end
- end)
- --]]
- -- }}}
- -- Autorun
- run_once("/usr/bin/mocp --server")
- run_once(config_dir.."/theme_terminals.sh '" .. string.sub(beautiful.bg_normal,1,7) .. "' '" .. string.sub(beautiful.fg_normal,1,7) .. "'")
- run_once("lxpolkit &")
- --run_once("irexec -d")
Add Comment
Please, Sign In to add comment