rc.lua 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  1. -- If LuaRocks is installed, make sure that packages installed through it are
  2. -- found (e.g. lgi). If LuaRocks is not installed, do nothing.
  3. pcall(require, "luarocks.loader")
  4. -- Standard awesome library
  5. local gears = require("gears") --Utilities such as color parsing and objects
  6. local awful = require("awful") --Everything related to window managment
  7. require("awful.autofocus")
  8. -- Widget and layout library
  9. local wibox = require("wibox")
  10. -- Theme handling library
  11. local beautiful = require("beautiful")
  12. -- Notification library
  13. local naughty = require("naughty")
  14. naughty.config.defaults["icon_size"] = 100
  15. naughty.config.defaults["timeout"] = 5
  16. naughty.config.defaults["font"] = "Sarasa Mono SC Nerd 13"
  17. naughty.config.defaults["border_width"] = 1
  18. local menubar = require("menubar")
  19. -- Enable hotkeys help widget for VIM and other apps
  20. -- when client with a matching name is opened:
  21. local hotkeys_popup = require("awful.hotkeys_popup").widget
  22. require("awful.hotkeys_popup.keys")
  23. -- {{{ Wibar
  24. -- My widgets
  25. -- local pacman_widget = require("awesome-wm-widgets/pacman-widget/pacman")
  26. local xbps_widget = require("awesome-wm-widgets/xbps-widget/xbps")
  27. local weather_widget = require("awesome-wm-widgets/weather-widget/weather-widget")
  28. local cpu_widget = require("awesome-wm-widgets/cpu-widget/cpu-widget")
  29. local ram_widget = require("awesome-wm-widgets/ram-widget/ram-widget")
  30. local calendar_widget = require("awesome-wm-widgets/calendar-widget/calendar-widget")
  31. local sep_widget = require("awesome-wm-widgets/sep-widget/sep-widget")
  32. -- {{{ Error handling
  33. -- Check if awesome encountered an error during startup and fell back to
  34. -- another config (This code will only ever execute for the fallback config)
  35. if awesome.startup_errors then
  36. naughty.notify({
  37. preset = naughty.config.presets.critical,
  38. title = "Oops, there were errors during startup!",
  39. text = awesome.startup_errors
  40. })
  41. end
  42. -- Handle runtime errors after startup
  43. do
  44. local in_error = false
  45. awesome.connect_signal("debug::error", function(err)
  46. -- Make sure we don't go into an endless error loop
  47. if in_error then return end
  48. in_error = true
  49. naughty.notify({
  50. preset = naughty.config.presets.critical,
  51. title = "Oops, an error happened!",
  52. text = tostring(err)
  53. })
  54. in_error = false
  55. end)
  56. end
  57. -- }}}
  58. -- {{{ Variable definitions
  59. local TERMINAL = "wezterm"
  60. local EXTRA_TERMINAL = "kitty"
  61. local EDITOR = os.getenv("EDITOR") or "vim"
  62. local EDITOR_CMD = TERMINAL .. " -e " .. EDITOR
  63. local SHELL = os.getenv("SHELL")
  64. local HOME = os.getenv("HOME")
  65. local AWESOME_CONFIG_DIR = HOME .. "/.config/awesome"
  66. -- Themes define colours, icons, font and wallpapers.
  67. local themes = {
  68. "default", -- 1
  69. "gtk", -- 2
  70. "mymaterial", -- 3
  71. "sky", -- 4
  72. "xresources", -- 5
  73. "zenburn", -- 6
  74. "gruvbox", -- 7
  75. "steamburn", -- 8
  76. "mira", -- 9
  77. "myotto", -- 10
  78. "myeverforest", -- 10
  79. }
  80. local theme_path = AWESOME_CONFIG_DIR .. "/themes/" .. themes[11] .. "/theme.lua"
  81. beautiful.init(theme_path)
  82. -- Default modkey and other keys.
  83. local super = "Mod4"
  84. local alt = "Mod1"
  85. local ctrl = "Control"
  86. local shft = "Shift"
  87. -- Table of layouts to cover with awful.layout.inc, order matters.
  88. awful.layout.layouts = {
  89. awful.layout.suit.tile,
  90. awful.layout.suit.max,
  91. awful.layout.suit.magnifier,
  92. -- awful.layout.suit.floating,
  93. -- awful.layout.suit.tile.bottom,
  94. -- awful.layout.suit.max.fullscreen,
  95. -- awful.layout.suit.tile.left,
  96. -- awful.layout.suit.tile.top,
  97. -- awful.layout.suit.fair,
  98. -- awful.layout.suit.fair.horizontal,
  99. -- awful.layout.suit.spiral,
  100. -- awful.layout.suit.spiral.dwindle,
  101. -- awful.layout.suit.corner.nw,
  102. -- awful.layout.suit.corner.ne,
  103. -- awful.layout.suit.corner.sw,
  104. -- awful.layout.suit.corner.se,
  105. }
  106. -- }}}
  107. -- {{{ Menu
  108. -- Create a launcher widget and a main menu
  109. local myawesomemenu = {
  110. { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
  111. { "manual", TERMINAL .. " -e man awesome" },
  112. { "edit config", EDITOR_CMD .. " " .. awesome.conffile },
  113. { "restart", awesome.restart },
  114. { "quit", function() awesome.quit() end },
  115. }
  116. local mymainmenu = awful.menu(
  117. {
  118. items = {
  119. { "awesome", myawesomemenu, beautiful.awesome_icon },
  120. { "open terminal", TERMINAL },
  121. }
  122. })
  123. -- On the bar
  124. local mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu })
  125. -- Menubar configuration
  126. menubar.utils.terminal = TERMINAL -- Set the terminal for applications that require it
  127. -- }}}
  128. -- Check if I am on my Laptop.
  129. local f = io.open(HOME .. "/.mylaptop", "r")
  130. if f ~= nil then
  131. io.close(f)
  132. mylaptop = true
  133. end
  134. -- Check if I am on my home computer.
  135. local f = io.open(HOME .. "/.mydesktop", "r")
  136. if f ~= nil then
  137. io.close(f)
  138. mydesktop = true
  139. end
  140. -- -- TODO Delete: I don't need battery-status!!!
  141. -- -- Add battery status if I am using my laptop.
  142. -- if mylaptop then
  143. -- battery_status = awful.widget.watch("battery-status", 60)
  144. -- end
  145. -- {{{ User functions
  146. -- There is no reason to navigate next or previous in my tag list and have to pass by empty tags in route to the next tag with a client. The following two functions bypass the empty tags when navigating to next or previous.
  147. function view_next_tag_with_client()
  148. local initial_tag_index = awful.screen.focused().selected_tag.index
  149. while (true) do
  150. awful.tag.viewnext()
  151. local current_tag = awful.screen.focused().selected_tag
  152. local current_tag_index = current_tag.index
  153. if #current_tag:clients() > 0 or current_tag_index == initial_tag_index then
  154. return
  155. end
  156. end
  157. end
  158. function view_prev_tag_with_client()
  159. local initial_tag_index = awful.screen.focused().selected_tag.index
  160. while (true) do
  161. awful.tag.viewprev()
  162. local current_tag = awful.screen.focused().selected_tag
  163. local current_tag_index = current_tag.index
  164. if #current_tag:clients() > 0 or current_tag_index == initial_tag_index then
  165. return
  166. end
  167. end
  168. end
  169. -- User functions }}}
  170. -- Create a wibox for each screen and add it
  171. -- Actions for when I click on my taglist buttons
  172. local taglist_buttons = gears.table.join(
  173. -- awful.button({ }, 1, function(t) t:view_only() end),
  174. awful.button({}, 1, function(t)
  175. -- Switch back like in Qtile
  176. if t ~= awful.screen.focused().selected_tag then
  177. t:view_only()
  178. else
  179. awful.tag.history.restore()
  180. end
  181. end),
  182. awful.button({ super }, 1, function(t)
  183. if client.focus then
  184. client.focus:move_to_tag(t)
  185. t:view_only() -- Follow to the client to the chosen tag
  186. end
  187. end),
  188. awful.button({}, 3, awful.tag.viewtoggle) -- (Un)Fold all clients (Show Desktop)
  189. )
  190. -- Actions for when I click on my tasklist buttons (started apps on the bar)
  191. local tasklist_buttons = gears.table.join(
  192. awful.button({}, 1, function(c)
  193. if c == client.focus then
  194. c.minimized = true
  195. else
  196. c:emit_signal(
  197. "request::activate",
  198. "tasklist",
  199. { raise = true }
  200. )
  201. end
  202. end),
  203. awful.button({}, 3, function() awful.menu.client_list({ theme = { width = 250 } }) end))
  204. local function set_wallpaper(s)
  205. if beautiful.wallpaper then
  206. -- local wallpaper = beautiful.wallpaper
  207. local wallpaper = HOME .. "/Pictures/Wallpapers/NewWallpapers/0314_1280x1024.jpg"
  208. if type(wallpaper) == "function" then
  209. wallpaper = wallpaper(s)
  210. end
  211. if mylaptop then
  212. gears.wallpaper.maximized(wallpaper)
  213. else
  214. gears.wallpaper.set(gears.surface(wallpaper))
  215. end
  216. end
  217. end
  218. -- -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
  219. -- screen.connect_signal("property::geometry", set_wallpaper)
  220. awful.screen.connect_for_each_screen(function(s)
  221. -- -- Wallpaper
  222. -- set_wallpaper(s)
  223. -- Each screen has its own tag table.
  224. awful.tag(
  225. { "1  ", "2  ", "3  ", "4  ", "5  ", "6  ", "7  ", "8  ", "9  " },
  226. s,
  227. { -- for every tag its own layout: { awful.layout.layouts[i], }
  228. awful.layout.layouts[1], -- tile -> 1
  229. awful.layout.layouts[1], -- tile -> 2
  230. awful.layout.layouts[2], -- max -> 3
  231. awful.layout.layouts[1], -- tile -> 4
  232. awful.layout.layouts[1], -- tile -> 5
  233. awful.layout.layouts[2], -- max -> 6
  234. awful.layout.layouts[1], -- tile -> 7
  235. awful.layout.layouts[2], -- max -> 8
  236. awful.layout.layouts[1], -- tile -> 9
  237. })
  238. -- Create a promptbox for each screen
  239. s.mypromptbox = awful.widget.prompt()
  240. -- Create an imagebox widget which will contain an icon indicating which layout we're using.
  241. -- We need one layoutbox per screen.
  242. s.mylayoutbox = awful.widget.layoutbox(s) -- To switch between layouts
  243. s.mylayoutbox:buttons(gears.table.join( -- by clicking on the layout's icon
  244. awful.button({}, 1, function() awful.layout.inc(1) end),
  245. awful.button({}, 3, function() awful.layout.inc(-1) end)))
  246. -- Create a taglist widget
  247. s.mytaglist = awful.widget.taglist {
  248. screen = s,
  249. filter = awful.widget.taglist.filter.all,
  250. buttons = taglist_buttons
  251. }
  252. -- Create a tasklist widget
  253. s.mytasklist = awful.widget.tasklist {
  254. screen = s,
  255. filter = awful.widget.tasklist.filter.currenttags,
  256. buttons = tasklist_buttons
  257. }
  258. -- Create the wibox (Bar)
  259. s.mywibox = awful.wibar({ position = "top", screen = s, height = 32 })
  260. s.systray = wibox.widget.systray()
  261. s.systray.set_base_size(25)
  262. -- Add widgets to the wibox
  263. s.mywibox:setup {
  264. layout = wibox.layout.align.horizontal,
  265. { -- Left widgets
  266. layout = wibox.layout.fixed.horizontal,
  267. s.mytaglist,
  268. s.mypromptbox,
  269. },
  270. s.mytasklist, -- Middle widget
  271. { -- Right widgets
  272. layout = wibox.layout.fixed.horizontal,
  273. -- spacing = 12,
  274. spacing = 8,
  275. -- pacman_widget({
  276. -- font_name = "Ubuntu Nerd Font 11",
  277. -- icon = "",
  278. -- icon_size = 12,
  279. -- fg_color = "#e2e0a5",
  280. -- }),
  281. xbps_widget({
  282. font_name = "Ubuntu Nerd Font 11",
  283. icon = "",
  284. icon_size = 12,
  285. -- fg_color = "#e2e0a5", -- materia
  286. fg_color = "#f7e6bb", -- everforest
  287. }),
  288. -- sep_widget({
  289. -- font_name = "Sarasa Mono SC Nerd 17",
  290. -- icon = "|",
  291. -- icon_size = 17,
  292. -- }),
  293. weather_widget({
  294. api_key = "7834197c2338888258f8cb94ae14ef49",
  295. coordinates = { 52.4345, 30.9754 },
  296. time_format_12h = false,
  297. units = "metric",
  298. both_units_widget = false,
  299. font_name = "Ubuntu Nerd Font",
  300. icons = "VitalyGorbachev",
  301. icons_extension = ".svg",
  302. show_hourly_forecast = true,
  303. show_daily_forecast = true,
  304. timeout = 1800,
  305. }),
  306. -- sep_widget({
  307. -- font_name = "Sarasa Mono SC Nerd 17",
  308. -- icon = "|",
  309. -- icon_size = 17,
  310. -- }),
  311. cpu_widget({
  312. font_name = "Ubuntu Nerd Font 10",
  313. icon = "",
  314. icon_size = 12,
  315. -- fg_color = "#89ddff", -- materia
  316. fg_color = "#7fbbb3", -- everforest
  317. }),
  318. -- sep_widget({
  319. -- font_name = "Sarasa Mono SC Nerd 17",
  320. -- icon = "|",
  321. -- icon_size = 17,
  322. -- }),
  323. ram_widget({
  324. font_name = "Ubuntu Nerd Font 10",
  325. icon = " ",
  326. icon_size = 12,
  327. -- fg_color = "#ffcb6b", -- materia
  328. fg_color = "#dbbc7f", -- everforest
  329. }),
  330. -- sep_widget({
  331. -- font_name = "Sarasa Mono SC Nerd 17",
  332. -- icon = "|",
  333. -- icon_size = 17,
  334. -- }),
  335. wibox.container.margin(s.systray, 0, 0, 3, 0), -- systray in the container
  336. s.mylayoutbox,
  337. -- sep_widget({
  338. -- font_name = "Sarasa Mono SC Nerd 17",
  339. -- icon = "|",
  340. -- icon_size = 17,
  341. -- }),
  342. calendar_widget({
  343. font_name = "Ubuntu Nerd Font 10",
  344. icon = " ",
  345. icon_size = 12,
  346. format = "%a, %d %b\n %H:%M:%S ",
  347. refresh = 1,
  348. -- fg_color = "#83eed9", -- materia
  349. fg_color = "#83c092", -- everforest
  350. popup_bg_color = "#ff0000", -- materia
  351. }),
  352. },
  353. }
  354. end)
  355. -- }}}
  356. -- TODO
  357. -- Without this setting, it defaults to 16px icons which stretch to my wibar height of 24px.
  358. -- awesome.set_preferred_icon_size(32)
  359. -- {{{ Mouse bindings
  360. root.buttons(gears.table.join( -- Clicks on the Desktop
  361. awful.button({}, 3, function() mymainmenu:toggle() end)
  362. ))
  363. -- }}}
  364. -- {{{ Keybindings
  365. globalkeys = gears.table.join(
  366. -- {{{ Personal keybindings
  367. -- My dmenu scripts <CTRL + ALT> + KEY
  368. awful.key({ ctrl, alt }, "c", function() awful.util.spawn(HOME .. "/.myScripts/dmscripts/dm-edit-configs.sh") end,
  369. { description = "edit config files", group = "dmenu scripts" }),
  370. awful.key({ ctrl, alt }, "r", function() awful.util.spawn(HOME .. "/.myScripts/dmscripts/dm-run-programs.sh") end,
  371. { description = "run programs", group = "dmenu scripts" }),
  372. awful.key({ ctrl, alt }, "s", function() awful.util.spawn(HOME .. "/.myScripts/dmscripts/dm-run-scripts.sh") end,
  373. { description = "run scripts", group = "dmenu scripts" }),
  374. awful.key({ ctrl, alt }, "x", function() awful.util.spawn(HOME .. "/.myScripts/dmscripts/dm-system-exit.sh") end,
  375. { description = "system exit", group = "dmenu scripts" }),
  376. -- My applications <SUPER + ALT> + KEY
  377. awful.key({ super, alt }, "Space", function() awful.util.spawn(HOME .. "/.myScripts/touchpadONOFF.sh") end,
  378. { description = "Touchpad On/Off", group = "launcher" }),
  379. awful.key({ super, alt }, "r", function() awful.util.spawn("rofi run -show drun -show-icons") end,
  380. { description = "Rofi", group = "launcher" }),
  381. -- awful.key({ super, alt }, "d", function() awful.util.spawn("dmenu_run -i -l 10 -nb '#263238' -nf '#24d2af' -sb '#009185' -p 'Run: ' -fn 'Iosevka-18:normal'") end,
  382. -- {description = "Dmenu", group = "launcher" }), -- Materia Manjaro
  383. awful.key({ super, alt }, "d",
  384. function()
  385. awful.util.spawn(
  386. "dmenu_run -i -l 10 -nb '#2d353b' -nf '#d3c6aa' -sb '#475258' -sf '#a7c080' -p 'Run: ' -fn 'Iosevka-18:normal'")
  387. end,
  388. { description = "Dmenu", group = "launcher" }), -- Everforest
  389. awful.key({ super, alt }, "Print", function() awful.util.spawn("flameshot gui") end,
  390. { description = "FlameshotGui", group = "applications" }),
  391. awful.key({ super, alt }, "w", function() awful.util.spawn("/usr/bin/firefox") end,
  392. { description = "Firefox", group = "applications" }),
  393. awful.key({ super, alt }, "u", function() awful.util.spawn("qutebrowser") end,
  394. { description = "Qutebrowser", group = "applications" }),
  395. awful.key({ super, alt }, "e", function() awful.util.spawn("dolphin") end,
  396. { description = "Dolphin", group = "applications" }),
  397. awful.key({ super, alt }, "n", function() awful.util.spawn("thunar") end,
  398. { description = "Thunar", group = "applications" }),
  399. awful.key({ super, alt }, "a", function() awful.util.spawn(TERMINAL .. " -e " .. SHELL .. " -c ranger") end,
  400. { description = "Ranger", group = "applications" }),
  401. awful.key({ super, alt }, "v", function()
  402. awful.util.spawn(TERMINAL .. " -e " .. HOME ..
  403. "/.config/vifm/scripts/vifmrun")
  404. end,
  405. { description = "Vifm", group = "applications" }),
  406. awful.key({ super, alt }, "y",
  407. function()
  408. awful.util.spawn(TERMINAL ..
  409. " -e " .. SHELL .. " -c 'yazi --cwd-file ~/.config/yazi/cwd (cat ~/.config/yazi/cwd)'")
  410. end,
  411. { description = "Yazi", group = "applications" }),
  412. awful.key({ super, alt }, "t",
  413. function()
  414. awful.util.spawn(HOME ..
  415. "/Programs/Telegram/Telegram -workdir " .. HOME .. "/.local/share/TelegramDesktop/ -- %u")
  416. end,
  417. { description = "Telegram", group = "applications" }),
  418. awful.key({ super, alt }, "p", function() awful.util.spawn(HOME .. "/Programs/PyCharm-Community/bin/pycharm.sh") end,
  419. { description = "PyCharm", group = "applications" }),
  420. awful.key({ super, alt }, "c", function() awful.util.spawn("code") end,
  421. { description = "VSCode", group = "applications" }),
  422. awful.key({ super, alt }, "g", function() awful.util.spawn("goldendict") end,
  423. { description = "Goldendict", group = "applications" }),
  424. awful.key({ super, alt }, "m", function() awful.util.spawn(TERMINAL .. " -e vim") end,
  425. { description = "Vim", group = "applications" }),
  426. awful.key({ super, ctrl }, "m", function() awful.util.spawn("gvim") end,
  427. { description = "GVim", group = "applications" }),
  428. awful.key({ super, alt }, "s", function() awful.util.spawn(HOME .. "/Programs/SublimeText/sublime_text") end,
  429. { description = "Sublime Text", group = "applications" }),
  430. awful.key({ super, alt }, "b", function() awful.util.spawn("brave") end,
  431. { description = "Brave", group = "applications" }),
  432. awful.key({ super, alt }, "Return", function() awful.util.spawn(EXTRA_TERMINAL) end,
  433. { description = "Extra Terminal", group = "applications" }),
  434. awful.key({ super, ctrl }, "Return", function() awful.util.spawn("xfce4-terminal") end,
  435. { description = "xfce4-terminal", group = "applications" }),
  436. awful.key({ super, shft }, "Return", function() awful.util.spawn("terminator") end,
  437. { description = "terminator", group = "applications" }),
  438. awful.key({ ctrl, alt }, "Return", function() awful.util.spawn("alacritty") end,
  439. { description = "alacritty", group = "applications" }),
  440. awful.key({ ctrl, shft }, "Escape", function() awful.util.spawn(TERMINAL .. " -e " .. SHELL .. " -c htop") end,
  441. { description = "htop", group = "applications" }),
  442. -- My applications as Root <SUPER + SHIFT + ALT> + KEY
  443. awful.key({ super, shft, alt }, "v", function() awful.util.spawn(HOME .. "/.myScripts/runVifmAsRoot.sh") end,
  444. { description = "Vifm as Root", group = "applications" }),
  445. awful.key({ super, shft, alt }, "a", function() awful.util.spawn(HOME .. "/.myScripts/runRangerAsRoot.sh") end,
  446. { description = "Ranger as Root", group = "applications" }),
  447. awful.key({ super, shft, alt }, "y", function() awful.util.spawn(HOME .. "/.myScripts/runYaziAsRoot.sh") end,
  448. { description = "Yazi as Root", group = "applications" }),
  449. awful.key({ super, shft, alt }, "n", function() awful.util.spawn(HOME .. "/.myScripts/runThunarAsRoot.sh") end,
  450. { description = "Thunar as Root", group = "applications" }),
  451. -- Personal keybindings }}}
  452. -- Hotkeys Awesome
  453. awful.key({ super }, "s", hotkeys_popup.show_help,
  454. { description = "show help", group = "awesome" }),
  455. -- Show MainMenu
  456. awful.key({ super }, "w", function() mymainmenu:show() end,
  457. { description = "show main menu", group = "awesome" }),
  458. -- Show/Hide Wibox
  459. awful.key({ super }, "b", function()
  460. for s in screen do
  461. s.mywibox.visible = not s.mywibox.visible
  462. if s.mybottomwibox then
  463. s.mybottomwibox.visible = not s.mybottomwibox.visible
  464. end
  465. end
  466. end,
  467. { description = "toggle wibox", group = "awesome" }),
  468. -- Tag browsing with <SUPER>
  469. awful.key({ super }, "Left", awful.tag.viewprev,
  470. { description = "view previous", group = "tag" }),
  471. awful.key({ super }, "Right", awful.tag.viewnext,
  472. { description = "view next", group = "tag" }),
  473. awful.key({ super }, "Escape", awful.tag.history.restore,
  474. { description = "go back", group = "tag" }),
  475. -- Non-empty tag browsing
  476. awful.key({ super, alt }, "Right", function() view_next_tag_with_client() end,
  477. { description = "view previous nonempty", group = "tag" }),
  478. awful.key({ super, alt }, "Left", function() view_prev_tag_with_client() end,
  479. { description = "view previous nonempty", group = "tag" }),
  480. -- Default client focus
  481. awful.key({ alt }, "j", function() awful.client.focus.byidx(1) end,
  482. { description = "focus next by index", group = "client" }),
  483. awful.key({ alt }, "k", function() awful.client.focus.byidx(-1) end,
  484. { description = "focus previous by index", group = "client" }),
  485. -- By direction client focus
  486. awful.key({ super }, "j", function()
  487. awful.client.focus.global_bydirection("down")
  488. if client.focus then client.focus:raise() end
  489. end,
  490. { description = "focus down", group = "client" }),
  491. awful.key({ super }, "k", function()
  492. awful.client.focus.global_bydirection("up")
  493. if client.focus then client.focus:raise() end
  494. end,
  495. { description = "focus up", group = "client" }),
  496. awful.key({ super }, "h", function()
  497. awful.client.focus.global_bydirection("left")
  498. if client.focus then client.focus:raise() end
  499. end,
  500. { description = "focus left", group = "client" }),
  501. awful.key({ super }, "l", function()
  502. awful.client.focus.global_bydirection("right")
  503. if client.focus then client.focus:raise() end
  504. end,
  505. { description = "focus right", group = "client" }),
  506. -- Layout manipulation
  507. awful.key({ super, shft }, "j", function() awful.client.swap.byidx(1) end,
  508. { description = "swap with next client by index", group = "client" }),
  509. awful.key({ super, shft }, "k", function() awful.client.swap.byidx(-1) end,
  510. { description = "swap with previous client by index", group = "client" }),
  511. awful.key({ super }, ".", function() awful.screen.focus_relative(1) end,
  512. { description = "focus the next screen", group = "screen" }),
  513. awful.key({ super }, ",", function() awful.screen.focus_relative(-1) end,
  514. { description = "focus the previous screen", group = "screen" }),
  515. awful.key({ super }, "u", awful.client.urgent.jumpto,
  516. { description = "jump to urgent client", group = "client" }),
  517. awful.key({ alt }, "Tab", function()
  518. awful.client.focus.history.previous()
  519. if client.focus then client.focus:raise() end
  520. end,
  521. { description = "go back", group = "client" }),
  522. -- Standard program
  523. awful.key({ super }, "Return", function() awful.spawn(TERMINAL) end,
  524. { description = "open a terminal", group = "applications" }),
  525. awful.key({ super, shft }, "r", awesome.restart,
  526. { description = "reload awesome", group = "awesome" }),
  527. awful.key({ super, shft }, "q", awesome.quit,
  528. { description = "quit awesome", group = "awesome" }),
  529. -- Increase/Decrease master
  530. awful.key({ super, ctrl }, "k", function() awful.client.incwfact(0.05) end,
  531. { description = "increase master height factor", group = "layout" }),
  532. awful.key({ super, ctrl }, "j", function() awful.client.incwfact(-0.05) end,
  533. { description = "decrease master height factor", group = "layout" }),
  534. awful.key({ super, ctrl }, "l", function() awful.tag.incmwfact(0.05) end,
  535. { description = "increase master width factor", group = "layout" }),
  536. awful.key({ super, ctrl }, "h", function() awful.tag.incmwfact(-0.05) end,
  537. { description = "decrease master width factor", group = "layout" }),
  538. awful.key({ alt, shft }, "h", function() awful.tag.incnmaster(1, nil, true) end,
  539. { description = "increase the number of master clients", group = "layout" }),
  540. awful.key({ alt, shft }, "l", function() awful.tag.incnmaster(-1, nil, true) end,
  541. { description = "decrease the number of master clients", group = "layout" }),
  542. awful.key({ ctrl, alt }, "h", function() awful.tag.incncol(1, nil, true) end,
  543. { description = "increase the number of columns", group = "layout" }),
  544. awful.key({ ctrl, alt }, "l", function() awful.tag.incncol(-1, nil, true) end,
  545. { description = "decrease the number of columns", group = "layout" }),
  546. -- Swap clients
  547. awful.key({ super, shft }, "h", function() awful.tag.incnmaster(1, nil, true) end,
  548. { description = "increase the number of master clients", group = "layout" }),
  549. awful.key({ super, shft }, "l", function() awful.tag.incnmaster(-1, nil, true) end,
  550. { description = "decrease the number of master clients", group = "layout" }),
  551. -- Switch between layouts
  552. awful.key({ super }, "Tab", function() awful.layout.inc(1) end,
  553. { description = "select next", group = "layout" }),
  554. awful.key({ super, shft }, "Tab", function() awful.layout.inc(-1) end,
  555. { description = "select previous", group = "layout" }),
  556. awful.key({ super, ctrl }, "n",
  557. function()
  558. local c = awful.client.restore()
  559. -- Focus restored client
  560. if c then
  561. c:emit_signal(
  562. "request::activate", "key.unminimize", { raise = true }
  563. )
  564. end
  565. end,
  566. { description = "restore minimized", group = "client" }),
  567. -- <SUPER> + <F1-F12>
  568. -- Brightness
  569. -- awful.key({ }, "XF86MonBrightnessUp", function() os.execute("xbacklight -inc 10") end,
  570. -- {description = "+10%", group = "hotkeys"}),
  571. -- awful.key({ }, "XF86MonBrightnessDown", function() os.execute("xbacklight -dec 10") end,
  572. -- {description = "-10%", group = "hotkeys"}),
  573. awful.key({ super }, "F2", function() awful.spawn(HOME .. "/.myScripts/brightness_down.sh") end,
  574. { description = "Brightness +5%", group = "hotkeys" }),
  575. awful.key({ super }, "F3", function() awful.spawn(HOME .. "/.myScripts/brightness_up.sh") end,
  576. { description = "Brightness -5%", group = "hotkeys" }),
  577. -- ALSA volume control
  578. awful.key({ super }, "F9", function() awful.spawn(HOME .. "/.myScripts/volume_up.sh") end,
  579. { description = "Volume Up", group = "hotkeys" }),
  580. awful.key({ super }, "F8", function() awful.spawn(HOME .. "/.myScripts/volume_down.sh") end,
  581. { description = "Volume Down", group = "hotkeys" }),
  582. awful.key({ super }, "F7", function() awful.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle") end,
  583. { description = "Volume Mute", group = "hotkeys" }),
  584. -- XF86AudioRaiseVolume
  585. -- XF86AudioLowerVolume
  586. -- XF86AudioMute
  587. -- <ALT> + <F1-F12>
  588. awful.key({ alt }, "F4", function() awful.spawn(HOME .. "/Programs/ByeBye/ByeBye") end,
  589. { description = "System Exit Menu", group = "applications" }),
  590. -- Default
  591. -- Menubar
  592. awful.key({ super }, "p", function() menubar.show() end,
  593. { description = "show the menubar", group = "awesome" }),
  594. -- Prompt
  595. -- awful.key({ super }, "r", function() awful.screen.focused().mypromptbox:run() end,
  596. -- {description = "Run prompt", group = "launcher"}),
  597. awful.key({ super }, "x",
  598. function()
  599. awful.prompt.run {
  600. prompt = "Run Lua code: ",
  601. textbox = awful.screen.focused().mypromptbox.widget,
  602. exe_callback = awful.util.eval,
  603. history_path = awful.util.get_cache_dir() .. "/history_eval"
  604. }
  605. end,
  606. { description = "Lua execute prompt", group = "launcher" })
  607. )
  608. clientkeys = gears.table.join(
  609. awful.key({ super, }, "f",
  610. function(c)
  611. c.fullscreen = not c.fullscreen
  612. c:raise()
  613. end,
  614. { description = "toggle fullscreen", group = "client" }),
  615. awful.key({ super, }, "t",
  616. function(c)
  617. for _, c in ipairs(client.get()) do
  618. awful.titlebar.toggle(c)
  619. end
  620. end,
  621. { description = "Show/Hide Titlebars for All clients", group = "client" }),
  622. awful.key({ super, shft }, "t", function(c) awful.titlebar.toggle(c) end,
  623. { description = "Show/Hide Titlebars for the current client", group = "client" }),
  624. awful.key({ super, shft }, "x", function(c) awful.spawn("xkill") end,
  625. { description = "kill", group = "client" }),
  626. awful.key({ super, shft }, "c", function(c) c:kill() end,
  627. { description = "close", group = "client" }),
  628. awful.key({ super, shft }, "f", awful.client.floating.toggle,
  629. { description = "toggle floating", group = "client" }),
  630. awful.key({ super, ctrl }, "Return", function(c) c:swap(awful.client.getmaster()) end,
  631. { description = "move to master", group = "client" }),
  632. -- awful.key({ super, }, "o", function(c) c:move_to_screen() end,
  633. -- {description = "move to screen", group = "client"}),
  634. awful.key({ alt }, "t", function(c) c.ontop = not c.ontop end,
  635. { description = "toggle keep on top", group = "client" }),
  636. awful.key({ alt }, "n",
  637. function(c)
  638. -- The client currently has the input focus, so it cannot be
  639. -- minimized, since minimized clients can't have the focus.
  640. c.minimized = true
  641. end,
  642. { description = "minimize", group = "client" }),
  643. awful.key({ super }, "m",
  644. function(c)
  645. c.maximized = not c.maximized
  646. c:raise()
  647. end,
  648. { description = "(un)maximize", group = "client" }),
  649. -- (Un)Maximize vertical and horizontal
  650. awful.key({ super, shft }, "m",
  651. function(c)
  652. c.maximized_vertical = not c.maximized_vertical
  653. c:raise()
  654. end,
  655. { description = "(un)maximize vertically", group = "client" }),
  656. awful.key({ super, ctrl }, "m",
  657. function(c)
  658. c.maximized_horizontal = not c.maximized_horizontal
  659. c:raise()
  660. end,
  661. { description = "(un)maximize horizontally", group = "client" }),
  662. -- Move floating client
  663. awful.key({ ctrl, super }, "Up",
  664. function(c)
  665. if c.floating then
  666. c:relative_move(0, -10, 0, 0)
  667. end
  668. end,
  669. { description = "move floating client up", group = "client" }),
  670. awful.key({ ctrl, super }, "Down",
  671. function(c)
  672. if c.floating then
  673. c:relative_move(0, 10, 0, 0)
  674. end
  675. end,
  676. { description = "move floating client down", group = "client" }),
  677. awful.key({ ctrl, super }, "Left",
  678. function(c)
  679. if c.floating then
  680. c:relative_move(-10, 0, 0, 0)
  681. end
  682. end,
  683. { description = "move floating client left", group = "client" }),
  684. awful.key({ ctrl, super }, "Right",
  685. function(c)
  686. if c.floating then
  687. c:relative_move(10, 0, 0, 0)
  688. end
  689. end,
  690. { description = "move floating client right", group = "client" }),
  691. -- Resize floating client
  692. awful.key({ shft, super }, "Up",
  693. function(c)
  694. if c.floating then
  695. c:relative_move(0, 0, 0, -10)
  696. end
  697. end,
  698. { description = "resize floating client up", group = "client" }),
  699. awful.key({ shft, super }, "Down",
  700. function(c)
  701. if c.floating then
  702. c:relative_move(0, 0, 0, 10)
  703. end
  704. end,
  705. { description = "resize floating client down", group = "client" }),
  706. awful.key({ shft, super }, "Left",
  707. function(c)
  708. if c.floating then
  709. c:relative_move(0, 0, -10, 0)
  710. end
  711. end,
  712. { description = "resize floating client left", group = "client" }),
  713. awful.key({ shft, super }, "Right",
  714. function(c)
  715. if c.floating then
  716. c:relative_move(0, 0, 10, 0)
  717. end
  718. end,
  719. { description = "resize floating client right", group = "client" })
  720. )
  721. -- Bind all key numbers to tags.
  722. -- Be careful: we use keycodes to make it work on any keyboard layout.
  723. -- This should map on the top row of your keyboard, usually 1 to 9.
  724. for i = 1, 9 do
  725. globalkeys = gears.table.join(globalkeys,
  726. -- View tag only.
  727. awful.key({ super }, "#" .. i + 9,
  728. function()
  729. local screen = awful.screen.focused()
  730. local tag = screen.tags[i]
  731. -- Switch back like in Qtile
  732. if tag and tag ~= awful.screen.focused().selected_tag then
  733. tag:view_only()
  734. elseif tag == awful.screen.focused().selected_tag then
  735. awful.tag.history.restore()
  736. end
  737. end,
  738. { description = "view tag #" .. i, group = "tag" }),
  739. -- Toggle tag display (Show Desktop).
  740. awful.key({ super, ctrl }, "#" .. i + 9,
  741. function()
  742. local screen = awful.screen.focused()
  743. local tag = screen.tags[i]
  744. if tag then
  745. awful.tag.viewtoggle(tag)
  746. end
  747. end,
  748. { description = "toggle tag #" .. i, group = "tag" }),
  749. -- Move client to tag.
  750. awful.key({ super, shft }, "#" .. i + 9,
  751. function()
  752. if client.focus then
  753. local tag = client.focus.screen.tags[i]
  754. if tag then
  755. client.focus:move_to_tag(tag)
  756. tag:view_only() -- Follow to the client to the chosen tag
  757. end
  758. end
  759. end,
  760. { description = "move focused client to tag #" .. i, group = "tag" })
  761. -- TODO: delete this toggle???
  762. -- -- Toggle tag on focused client.
  763. -- , awful.key({ super, ctrl, shft }, "#"..i + 9,
  764. -- function()
  765. -- if client.focus then
  766. -- local tag = client.focus.screen.tags[i]
  767. -- if tag then
  768. -- client.focus:toggle_tag(tag)
  769. -- end
  770. -- end
  771. -- end,
  772. -- {description = "toggle focused client on tag #"..i, group = "tag"})
  773. )
  774. end
  775. clientbuttons = gears.table.join( -- Button clicks on client
  776. awful.button({}, 1, function(c) -- Activate client
  777. c:emit_signal("request::activate", "mouse_click", { raise = true })
  778. end),
  779. awful.button({ super }, 1, function(c) -- Move client
  780. c:emit_signal("request::activate", "mouse_click", { raise = true })
  781. awful.mouse.client.move(c)
  782. end),
  783. awful.button({ super }, 3, function(c) -- Resize client
  784. c:emit_signal("request::activate", "mouse_click", { raise = true })
  785. awful.mouse.client.resize(c)
  786. end)
  787. )
  788. -- Set keys
  789. root.keys(globalkeys)
  790. -- }}}
  791. -- {{{ Rules
  792. -- Rules to apply to new clients (through the "manage" signal).
  793. awful.rules.rules = {
  794. -- All clients will match this rule.
  795. {
  796. rule = {},
  797. properties = {
  798. border_width = beautiful.border_width,
  799. border_color = beautiful.border_normal,
  800. focus = awful.client.focus.filter,
  801. raise = true,
  802. keys = clientkeys,
  803. buttons = clientbuttons,
  804. titlebars_enabled = false,
  805. screen = awful.screen.preferred,
  806. size_hints_honor = false,
  807. placement = awful.placement.no_overlap + awful.placement.no_offscreen + awful.placement.centered,
  808. maximized_vertical = false,
  809. maximized_horizontal = false,
  810. floating = false,
  811. maximized = false,
  812. }
  813. },
  814. -- Floating clients.
  815. {
  816. rule_any = {
  817. instance = {
  818. "DTA", -- Firefox addon DownThemAll.
  819. "copyq", -- Includes session name in class.
  820. "pinentry",
  821. },
  822. class = {
  823. "Arandr",
  824. "Blueman-manager",
  825. "BreakTimer",
  826. "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
  827. "Deadbeef",
  828. "Galculator",
  829. "kcalc",
  830. "gnome-font-viewer",
  831. "xfce4-power-manager-settings",
  832. "Pavucontrol",
  833. "gdebi-gtk",
  834. "Gcolor3",
  835. "Gcolor2",
  836. "qt6ct",
  837. "Volumeicon",
  838. "Xfce4-notifyd",
  839. "Pinentry",
  840. "Lxappearance" },
  841. -- Note that the name property shown in xprop might be set slightly after creation of the client
  842. -- and the name shown there might not match defined rules here.
  843. name = {
  844. "Event Tester", -- xev.
  845. "About Mozilla Firefox",
  846. "О Mozilla Firefox",
  847. "Terminator Preferences",
  848. "Терминатор Параметры",
  849. "Сетевые соединения",
  850. "splash",
  851. "Update",
  852. "Compress", -- Engrampa compress dialog
  853. },
  854. role = {
  855. "AlarmWindow", -- Thunderbird's calendar.
  856. "ConfigManager", -- Thunderbird's about:config.
  857. "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
  858. "Preferences",
  859. "setup",
  860. },
  861. type = { "dialog" },
  862. },
  863. properties = { floating = true, border_width = 1 }
  864. },
  865. -- Set applications to always map on the sertain tag
  866. {
  867. rule_any = { class = { "dolphin", "Thunar" } },
  868. properties = { screen = 1, tag = root.tags()[3] }
  869. },
  870. {
  871. rule = { class = "VirtualBox Manager" },
  872. properties = { screen = 1, tag = root.tags()[5] }
  873. },
  874. {
  875. rule_any = { class = { "TelegramDesktop", "ViberPC" } },
  876. properties = { screen = 1, tag = root.tags()[6] }
  877. },
  878. {
  879. rule = { class = "Gimp" },
  880. properties = { screen = 1, tag = root.tags()[7] }
  881. },
  882. {
  883. rule = { class = "Thunderbird" },
  884. except = { name = "Password Required - Mozilla Thunderbird" },
  885. properties = { screen = 1, tag = root.tags()[9], switch_to_tags = false }
  886. },
  887. -- -- Titlebars
  888. -- -- Add titlebars to normal clients and dialogs
  889. -- { rule_any = {type = { "normal", "dialog" }
  890. -- }, properties = { titlebars_enabled = false }
  891. -- },
  892. }
  893. -- }}}
  894. -- {{{ Signals
  895. -- Signal function to execute when a new client appears.
  896. client.connect_signal("manage", function(c)
  897. -- Set the windows at the slave,
  898. -- i.e. put it at the end of others instead of setting it master.
  899. -- if not awesome.startup then awful.client.setslave(c) end
  900. if awesome.startup
  901. and not c.size_hints.user_position
  902. and not c.size_hints.program_position then
  903. -- Prevent clients from being unreachable after screen count changes.
  904. awful.placement.no_offscreen(c)
  905. end
  906. end)
  907. -- Focus urgent clients automatically
  908. -- When I launch a client at a particular place, I want to go to that client.
  909. client.connect_signal("property::urgent", function(c)
  910. c.minimized = false
  911. c:jump_to()
  912. end)
  913. -- Makes all floating clients border_width = 1
  914. client.connect_signal("property::floating", function(c)
  915. -- if c.floating then
  916. -- c.border_width = 1
  917. -- else
  918. -- c.border_width = beautiful.border_width
  919. -- end
  920. -- The same as above but a little bit shorter!
  921. c.border_width = c.floating and 1 or beautiful.border_width
  922. end)
  923. -- Add a titlebar if titlebars_enabled is set to true in the rules.
  924. client.connect_signal("request::titlebars", function(c)
  925. -- buttons for the titlebar
  926. local buttons = gears.table.join(
  927. awful.button({}, 1, function()
  928. c:emit_signal("request::activate", "titlebar", { raise = true })
  929. awful.mouse.client.move(c)
  930. end),
  931. awful.button({}, 3, function()
  932. c:emit_signal("request::activate", "titlebar", { raise = true })
  933. awful.mouse.client.resize(c)
  934. end)
  935. )
  936. awful.titlebar(c):setup {
  937. { -- Left
  938. awful.titlebar.widget.iconwidget(c),
  939. buttons = buttons,
  940. layout = wibox.layout.fixed.horizontal
  941. },
  942. { -- Middle
  943. { -- Title
  944. align = "center",
  945. widget = awful.titlebar.widget.titlewidget(c)
  946. },
  947. buttons = buttons,
  948. layout = wibox.layout.flex.horizontal
  949. },
  950. { -- Right
  951. awful.titlebar.widget.floatingbutton(c),
  952. awful.titlebar.widget.maximizedbutton(c),
  953. awful.titlebar.widget.stickybutton(c),
  954. awful.titlebar.widget.ontopbutton(c),
  955. awful.titlebar.widget.closebutton(c),
  956. layout = wibox.layout.fixed.horizontal()
  957. },
  958. layout = wibox.layout.align.horizontal
  959. }
  960. end)
  961. -- Enable sloppy focus, so that focus follows mouse.
  962. client.connect_signal("mouse::enter", function(c)
  963. c:emit_signal("request::activate", "mouse_enter", { raise = false })
  964. end)
  965. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  966. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  967. -- }}}
  968. -- Autostart
  969. local function run_once(cmd_arr)
  970. for _, cmd in ipairs(cmd_arr) do
  971. os.execute(string.format("pgrep -u $USER -fx '%s' > /dev/null || (%s &)", cmd, cmd))
  972. -- awful.spawn.with_shell(string.format("pgrep -u $USER -fx '%s' > /dev/null || (%s &)", cmd, cmd))
  973. end
  974. end
  975. run_once({
  976. "xxkb",
  977. "setxkbmap -layout us,ru -option grp:caps_toggle",
  978. -- "/usr/lib/xfce4/notifyd/xfce4-notifyd", -- no need on AwesomeWM
  979. -- /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1, -- for Debian
  980. -- "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1", -- for Arch
  981. -- "/usr/libexec/polkit-gnome-authentication-agent-1", -- for Void
  982. "/usr/libexec/xfce-polkit", -- for Void
  983. "xrdb " .. HOME .. "/.Xresources",
  984. "nitrogen --restore",
  985. "volumeicon",
  986. "nm-applet",
  987. "xfce4-power-manager",
  988. -- "clipit",
  989. -- "diodon",
  990. "xfce4-clipman",
  991. -- "$HOME/.myScripts/restore_brightness.sh", -- for HP
  992. "picom --config " .. HOME .. "/.config/picom/picom.conf",
  993. "conky -c " .. HOME .. "/.myScripts/conky/conkyrc",
  994. "/usr/bin/python /usr/bin/udiskie",
  995. "xiccd",
  996. "python /usr/bin/redshift-gtk",
  997. -- "/usr/bin/python /usr/bin/fluxgui",
  998. HOME .. "/Programs/CheckInternetConnection/CheckInternetConnection",
  999. HOME .. "/Programs/AppImageApplications/BreakTimer.AppImage",
  1000. "birdtray",
  1001. "xmodmap -e \"keycode 135 = Super_R\"",
  1002. }) -- entries must be comma-separated