rc.lua 42 KB

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