rc.lua 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037
  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 = "terminator"
  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 }, "t", function() awful.util.spawn(HOME.."/Programs/Telegram/Telegram -workdir "..HOME.."/.local/share/TelegramDesktop/ -- %u") end,
  395. {description = "Telegram", group = "applications" }),
  396. -- awful.key({ super, alt }, "t", function() awful.util.spawn("telegram-desktop") end, {description = "Telegram", group = "applications" }),
  397. awful.key({ super, alt }, "p", function() awful.util.spawn(HOME.."/Programs/PyCharm-Community/bin/pycharm.sh") end,
  398. {description = "PyCharm", group = "applications" }),
  399. awful.key({ super, alt }, "c", function() awful.util.spawn("code") end,
  400. {description = "VSCode", group = "applications" }),
  401. awful.key({ super, alt }, "g", function() awful.util.spawn("goldendict") end,
  402. {description = "Goldendict", group = "applications" }),
  403. awful.key({ super, alt }, "m", function() awful.util.spawn("gvim") end,
  404. {description = "GVim", group = "applications" }),
  405. awful.key({ super, alt }, "s", function() awful.util.spawn(HOME.."/Programs/SublimeText/sublime_text") end,
  406. {description = "Sublime Text", group = "applications" }),
  407. awful.key({ super, alt }, "b", function() awful.util.spawn("brave") end,
  408. {description = "Brave", group = "applications" }),
  409. awful.key({ super, alt }, "Return", function() awful.util.spawn(EXTRA_TERMINAL) end,
  410. {description = "Extra Terminal", group = "applications" }),
  411. awful.key({ super, ctrl }, "Return", function() awful.util.spawn("xfce4-terminal") end,
  412. {description = "xfce4-terminal", group = "applications" }),
  413. awful.key({ ctrl, shft }, "Escape", function() awful.util.spawn(TERMINAL.." -e "..SHELL.." -c htop") end,
  414. {description = "htop", group = "applications" }),
  415. -- My applications as Root <SUPER + SHIFT + ALT> + KEY
  416. awful.key({ super, shft, alt }, "v", function() awful.util.spawn(HOME.."/.myScripts/runVifmAsRoot.sh") end,
  417. {description = "Vifm as Root", group = "applications" }),
  418. awful.key({ super, shft, alt }, "a", function() awful.util.spawn(HOME.."/.myScripts/runRangerAsRoot.sh") end,
  419. {description = "Ranger as Root", group = "applications" }),
  420. awful.key({ super, shft, alt }, "n", function() awful.util.spawn(HOME.."/.myScripts/runThunarAsRoot.sh") end,
  421. {description = "Thunar as Root", group = "applications" }),
  422. -- Personal keybindings }}}
  423. -- Hotkeys Awesome
  424. awful.key({ super }, "s", hotkeys_popup.show_help,
  425. {description="show help", group="awesome"}),
  426. -- Show MainMenu
  427. awful.key({ super }, "w", function() mymainmenu:show() end,
  428. {description = "show main menu", group = "awesome"}),
  429. -- Show/Hide Wibox
  430. awful.key({ super }, "b", function()
  431. for s in screen do
  432. s.mywibox.visible = not s.mywibox.visible
  433. if s.mybottomwibox then
  434. s.mybottomwibox.visible = not s.mybottomwibox.visible
  435. end
  436. end
  437. end,
  438. {description = "toggle wibox", group = "awesome"}),
  439. -- Tag browsing with <SUPER>
  440. awful.key({ super }, "Left", awful.tag.viewprev,
  441. {description = "view previous", group = "tag"}),
  442. awful.key({ super }, "Right", awful.tag.viewnext,
  443. {description = "view next", group = "tag"}),
  444. awful.key({ super }, "Escape", awful.tag.history.restore,
  445. {description = "go back", group = "tag"}),
  446. -- Non-empty tag browsing
  447. awful.key({ super, alt }, "Right", function() view_next_tag_with_client()end,
  448. {description = "view previous nonempty", group = "tag"}),
  449. awful.key({ super, alt }, "Left", function() view_prev_tag_with_client() end,
  450. {description = "view previous nonempty", group = "tag"}),
  451. -- Default client focus
  452. awful.key({ alt }, "j", function() awful.client.focus.byidx( 1) end,
  453. {description = "focus next by index", group = "client"}),
  454. awful.key({ alt }, "k", function() awful.client.focus.byidx(-1) end,
  455. {description = "focus previous by index", group = "client"}),
  456. -- By direction client focus
  457. awful.key({ super }, "j", function() awful.client.focus.global_bydirection("down")
  458. if client.focus then client.focus:raise() end
  459. end,
  460. {description = "focus down", group = "client"}),
  461. awful.key({ super }, "k", function() awful.client.focus.global_bydirection("up")
  462. if client.focus then client.focus:raise() end
  463. end,
  464. {description = "focus up", group = "client"}),
  465. awful.key({ super }, "h", function() awful.client.focus.global_bydirection("left")
  466. if client.focus then client.focus:raise() end
  467. end,
  468. {description = "focus left", group = "client"}),
  469. awful.key({ super }, "l", function() awful.client.focus.global_bydirection("right")
  470. if client.focus then client.focus:raise() end
  471. end,
  472. {description = "focus right", group = "client"}),
  473. -- Layout manipulation
  474. awful.key({ super, shft }, "j", function() awful.client.swap.byidx( 1) end,
  475. {description = "swap with next client by index", group = "client"}),
  476. awful.key({ super, shft }, "k", function() awful.client.swap.byidx( -1) end,
  477. {description = "swap with previous client by index", group = "client"}),
  478. awful.key({ super }, ".", function() awful.screen.focus_relative( 1) end,
  479. {description = "focus the next screen", group = "screen"}),
  480. awful.key({ super }, ",", function() awful.screen.focus_relative(-1) end,
  481. {description = "focus the previous screen", group = "screen"}),
  482. awful.key({ super }, "u", awful.client.urgent.jumpto,
  483. {description = "jump to urgent client", group = "client"}),
  484. awful.key({ alt }, "Tab", function() awful.client.focus.history.previous()
  485. if client.focus then client.focus:raise() end
  486. end,
  487. {description = "go back", group = "client"}),
  488. -- Standard program
  489. awful.key({ super }, "Return", function() awful.spawn(TERMINAL) end,
  490. {description = "open a terminal", group = "applications"}),
  491. awful.key({ super, shft }, "r", awesome.restart,
  492. {description = "reload awesome", group = "awesome"}),
  493. awful.key({ super, shft }, "q", awesome.quit,
  494. {description = "quit awesome", group = "awesome"}),
  495. -- Increase/Decrease master
  496. awful.key({ super, ctrl }, "k", function() awful.client.incwfact( 0.05) end,
  497. {description = "increase master height factor", group = "layout"}),
  498. awful.key({ super, ctrl }, "j", function() awful.client.incwfact(-0.05) end,
  499. {description = "decrease master height factor", group = "layout"}),
  500. awful.key({ super, ctrl }, "l", function() awful.tag.incmwfact( 0.05) end,
  501. {description = "increase master width factor", group = "layout"}),
  502. awful.key({ super, ctrl }, "h", function() awful.tag.incmwfact(-0.05) end,
  503. {description = "decrease master width factor", group = "layout"}),
  504. awful.key({ alt, shft }, "h", function() awful.tag.incnmaster( 1, nil, true) end,
  505. {description = "increase the number of master clients", group = "layout"}),
  506. awful.key({ alt, shft }, "l", function() awful.tag.incnmaster(-1, nil, true) end,
  507. {description = "decrease the number of master clients", group = "layout"}),
  508. awful.key({ ctrl, alt }, "h", function() awful.tag.incncol( 1, nil, true) end,
  509. {description = "increase the number of columns", group = "layout"}),
  510. awful.key({ ctrl, alt }, "l", function() awful.tag.incncol(-1, nil, true) end,
  511. {description = "decrease the number of columns", group = "layout"}),
  512. -- Swap clients
  513. awful.key({ super, shft }, "h", function() awful.tag.incnmaster( 1, nil, true) end,
  514. {description = "increase the number of master clients", group = "layout"}),
  515. awful.key({ super, shft }, "l", function() awful.tag.incnmaster(-1, nil, true) end,
  516. {description = "decrease the number of master clients", group = "layout"}),
  517. -- Switch between layouts
  518. awful.key({ super }, "Tab", function() awful.layout.inc( 1) end,
  519. {description = "select next", group = "layout"}),
  520. awful.key({ super, shft }, "Tab", function() awful.layout.inc(-1) end,
  521. {description = "select previous", group = "layout"}),
  522. awful.key({ super, ctrl }, "n",
  523. function()
  524. local c = awful.client.restore()
  525. -- Focus restored client
  526. if c then
  527. c:emit_signal(
  528. "request::activate", "key.unminimize", {raise = true}
  529. )
  530. end
  531. end,
  532. {description = "restore minimized", group = "client"}),
  533. -- <SUPER> + <F1-F12>
  534. -- Brightness
  535. -- awful.key({ }, "XF86MonBrightnessUp", function() os.execute("xbacklight -inc 10") end,
  536. -- {description = "+10%", group = "hotkeys"}),
  537. -- awful.key({ }, "XF86MonBrightnessDown", function() os.execute("xbacklight -dec 10") end,
  538. -- {description = "-10%", group = "hotkeys"}),
  539. awful.key({ super }, "F2", function() awful.spawn(HOME.."/.myScripts/brightness_down.sh") end,
  540. {description = "Brightness +5%", group = "hotkeys"}),
  541. awful.key({ super }, "F3", function() awful.spawn(HOME.."/.myScripts/brightness_up.sh") end,
  542. {description = "Brightness -5%", group = "hotkeys"}),
  543. -- ALSA volume control
  544. awful.key({ super }, "F9", function() awful.spawn(HOME.."/.myScripts/volume_up.sh") end,
  545. {description = "Volume Up", group = "hotkeys"}),
  546. awful.key({ super }, "F8", function() awful.spawn(HOME.."/.myScripts/volume_down.sh") end,
  547. {description = "Volume Down", group = "hotkeys"}),
  548. awful.key({ super }, "F7", function() awful.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle") end,
  549. {description = "Volume Mute", group = "hotkeys"}),
  550. -- XF86AudioRaiseVolume
  551. -- XF86AudioLowerVolume
  552. -- XF86AudioMute
  553. -- <ALT> + <F1-F12>
  554. awful.key({ alt }, "F4", function() awful.spawn(HOME.."/Programs/ByeBye/ByeBye") end,
  555. {description = "System Exit Menu", group = "applications"}),
  556. -- Default
  557. -- Menubar
  558. awful.key({ super }, "p", function() menubar.show() end,
  559. {description = "show the menubar", group = "awesome"}),
  560. -- Prompt
  561. -- awful.key({ super }, "r", function() awful.screen.focused().mypromptbox:run() end,
  562. -- {description = "Run prompt", group = "launcher"}),
  563. awful.key({ super }, "x",
  564. function()
  565. awful.prompt.run {
  566. prompt = "Run Lua code: ",
  567. textbox = awful.screen.focused().mypromptbox.widget,
  568. exe_callback = awful.util.eval,
  569. history_path = awful.util.get_cache_dir().."/history_eval"
  570. }
  571. end,
  572. {description = "Lua execute prompt", group = "launcher"})
  573. )
  574. clientkeys = gears.table.join(
  575. awful.key({ super, }, "f",
  576. function(c)
  577. c.fullscreen = not c.fullscreen
  578. c:raise()
  579. end,
  580. {description = "toggle fullscreen", group = "client"}),
  581. awful.key({ super, }, "t",
  582. function(c)
  583. for _, c in ipairs(client.get()) do
  584. awful.titlebar.toggle(c)
  585. end
  586. end,
  587. {description = "Show/Hide Titlebars for All clients", group="client"}),
  588. awful.key({ super, shft }, "t", function (c) awful.titlebar.toggle(c) end,
  589. {description = "Show/Hide Titlebars for the current client", group="client"}),
  590. awful.key({ super, shft }, "x", function(c) awful.spawn("xkill") end,
  591. {description = "kill", group = "client"}),
  592. awful.key({ super, shft }, "c", function(c) c:kill() end,
  593. {description = "close", group = "client"}),
  594. awful.key({ super, shft }, "f", awful.client.floating.toggle,
  595. {description = "toggle floating", group = "client"}),
  596. awful.key({ super, ctrl }, "Return", function(c) c:swap(awful.client.getmaster()) end,
  597. {description = "move to master", group = "client"}),
  598. -- awful.key({ super, }, "o", function(c) c:move_to_screen() end,
  599. -- {description = "move to screen", group = "client"}),
  600. awful.key({ alt }, "t", function(c) c.ontop = not c.ontop end,
  601. {description = "toggle keep on top", group = "client"}),
  602. awful.key({ alt }, "n",
  603. function(c)
  604. -- The client currently has the input focus, so it cannot be
  605. -- minimized, since minimized clients can't have the focus.
  606. c.minimized = true
  607. end,
  608. {description = "minimize", group = "client"}),
  609. awful.key({ super }, "m",
  610. function(c)
  611. c.maximized = not c.maximized
  612. c:raise()
  613. end,
  614. {description = "(un)maximize", group = "client"}),
  615. -- (Un)Maximize vertical and horizontal
  616. awful.key({ super, shft }, "m",
  617. function(c)
  618. c.maximized_vertical = not c.maximized_vertical
  619. c:raise()
  620. end,
  621. {description = "(un)maximize vertically", group = "client"}),
  622. awful.key({ super, ctrl }, "m",
  623. function(c)
  624. c.maximized_horizontal = not c.maximized_horizontal
  625. c:raise()
  626. end,
  627. {description = "(un)maximize horizontally", group = "client"}),
  628. -- Move floating client
  629. awful.key({ ctrl, super }, "Up",
  630. function (c)
  631. if c.floating then
  632. c:relative_move(0, -10, 0, 0)
  633. end
  634. end,
  635. {description = "move floating client up", group = "client"}),
  636. awful.key({ ctrl, super }, "Down",
  637. function (c)
  638. if c.floating then
  639. c:relative_move(0, 10, 0, 0)
  640. end
  641. end,
  642. {description = "move floating client down", group = "client"}),
  643. awful.key({ ctrl, super }, "Left",
  644. function (c)
  645. if c.floating then
  646. c:relative_move(-10, 0, 0, 0)
  647. end
  648. end,
  649. {description = "move floating client left", group = "client"}),
  650. awful.key({ ctrl, super }, "Right",
  651. function (c)
  652. if c.floating then
  653. c:relative_move(10, 0, 0, 0)
  654. end
  655. end,
  656. {description = "move floating client right", group = "client"}),
  657. -- Resize floating client
  658. awful.key({ shft, super }, "Up",
  659. function (c)
  660. if c.floating then
  661. c:relative_move(0, 0, 0, -10)
  662. end
  663. end,
  664. {description = "resize floating client up", group = "client"}),
  665. awful.key({ shft, super }, "Down",
  666. function (c)
  667. if c.floating then
  668. c:relative_move(0, 0, 0, 10)
  669. end
  670. end,
  671. {description = "resize floating client down", group = "client"}),
  672. awful.key({ shft, super }, "Left",
  673. function (c)
  674. if c.floating then
  675. c:relative_move(0, 0, -10, 0)
  676. end
  677. end,
  678. {description = "resize floating client left", group = "client"}),
  679. awful.key({ shft, super }, "Right",
  680. function (c)
  681. if c.floating then
  682. c:relative_move(0, 0, 10, 0)
  683. end
  684. end,
  685. {description = "resize floating client right", group = "client"})
  686. )
  687. -- Bind all key numbers to tags.
  688. -- Be careful: we use keycodes to make it work on any keyboard layout.
  689. -- This should map on the top row of your keyboard, usually 1 to 9.
  690. for i = 1, 9 do
  691. globalkeys = gears.table.join(globalkeys,
  692. -- View tag only.
  693. awful.key({ super }, "#"..i + 9,
  694. function()
  695. local screen = awful.screen.focused()
  696. local tag = screen.tags[i]
  697. -- Switch back like in Qtile
  698. if tag and tag ~= awful.screen.focused().selected_tag then
  699. tag:view_only()
  700. elseif tag == awful.screen.focused().selected_tag then
  701. awful.tag.history.restore()
  702. end
  703. end,
  704. {description = "view tag #"..i, group = "tag"}),
  705. -- Toggle tag display (Show Desktop).
  706. awful.key({ super, ctrl }, "#"..i + 9,
  707. function()
  708. local screen = awful.screen.focused()
  709. local tag = screen.tags[i]
  710. if tag then
  711. awful.tag.viewtoggle(tag)
  712. end
  713. end,
  714. {description = "toggle tag #"..i, group = "tag"}),
  715. -- Move client to tag.
  716. awful.key({ super, shft }, "#"..i + 9,
  717. function()
  718. if client.focus then
  719. local tag = client.focus.screen.tags[i]
  720. if tag then
  721. client.focus:move_to_tag(tag)
  722. tag:view_only() -- Follow to the client to the chosen tag
  723. end
  724. end
  725. end,
  726. {description = "move focused client to tag #"..i, group = "tag"})
  727. -- TODO: delete this toggle???
  728. -- -- Toggle tag on focused client.
  729. -- , awful.key({ super, ctrl, shft }, "#"..i + 9,
  730. -- function()
  731. -- if client.focus then
  732. -- local tag = client.focus.screen.tags[i]
  733. -- if tag then
  734. -- client.focus:toggle_tag(tag)
  735. -- end
  736. -- end
  737. -- end,
  738. -- {description = "toggle focused client on tag #"..i, group = "tag"})
  739. )
  740. end
  741. clientbuttons = gears.table.join(-- Button clicks on client
  742. awful.button({ }, 1, function(c) -- Activate client
  743. c:emit_signal("request::activate", "mouse_click", {raise = true})
  744. end),
  745. awful.button({ super }, 1, function(c) -- Move client
  746. c:emit_signal("request::activate", "mouse_click", {raise = true})
  747. awful.mouse.client.move(c)
  748. end),
  749. awful.button({ super }, 3, function(c) -- Resize client
  750. c:emit_signal("request::activate", "mouse_click", {raise = true})
  751. awful.mouse.client.resize(c)
  752. end)
  753. )
  754. -- Set keys
  755. root.keys(globalkeys)
  756. -- }}}
  757. -- {{{ Rules
  758. -- Rules to apply to new clients (through the "manage" signal).
  759. awful.rules.rules = {
  760. -- All clients will match this rule.
  761. { rule = { },
  762. properties = {
  763. border_width = beautiful.border_width,
  764. border_color = beautiful.border_normal,
  765. focus = awful.client.focus.filter,
  766. raise = true,
  767. keys = clientkeys,
  768. buttons = clientbuttons,
  769. titlebars_enabled = false,
  770. screen = awful.screen.preferred,
  771. size_hints_honor = false,
  772. -- placement = awful.placement.no_overlap+awful.placement.no_offscreen,
  773. placement = awful.placement.no_overlap+awful.placement.no_offscreen+awful.placement.centered,
  774. maximized_vertical = false,
  775. maximized_horizontal = false,
  776. floating = false,
  777. maximized = false,
  778. }
  779. },
  780. -- Floating clients.
  781. { rule_any = {
  782. instance = {
  783. "DTA", -- Firefox addon DownThemAll.
  784. "copyq", -- Includes session name in class.
  785. "pinentry",
  786. },
  787. class = {
  788. "Arandr",
  789. "Blueman-manager",
  790. "BreakTimer",
  791. "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
  792. "Deadbeef",
  793. "Galculator",
  794. "kcalc",
  795. "gnome-font-viewer",
  796. "xfce4-power-manager-settings",
  797. "Pavucontrol",
  798. "gdebi-gtk",
  799. "Gcolor3",
  800. "Gcolor2",
  801. "qt6ct",
  802. "Volumeicon",
  803. "Xfce4-notifyd",
  804. "Pinentry",
  805. "Lxappearance"},
  806. -- Note that the name property shown in xprop might be set slightly after creation of the client
  807. -- and the name shown there might not match defined rules here.
  808. name = {
  809. "Event Tester", -- xev.
  810. "About Mozilla Firefox",
  811. "О Mozilla Firefox",
  812. "Terminator Preferences",
  813. "Терминатор Параметры",
  814. "Сетевые соединения",
  815. "splash",
  816. "Update",
  817. },
  818. role = {
  819. "AlarmWindow", -- Thunderbird's calendar.
  820. "ConfigManager", -- Thunderbird's about:config.
  821. "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
  822. "Preferences",
  823. "setup",
  824. },
  825. type = { "dialog" },
  826. }, properties = { floating = true, border_width = 1 } },
  827. -- Set applications to always map on the sertain tag
  828. { rule_any = { class = {"dolphin", "Thunar"} },
  829. properties = { screen = 1, tag = root.tags()[3] } },
  830. { rule = { class = "VirtualBox Manager" },
  831. properties = { screen = 1, tag = root.tags()[5] } },
  832. { rule_any = { class = {"TelegramDesktop", "ViberPC"} },
  833. properties = { screen = 1, tag = root.tags()[6] } },
  834. { rule = { class = "Gimp" },
  835. properties = { screen = 1, tag = root.tags()[7] } },
  836. { rule = { class = "Thunderbird" },
  837. except = { name = "Password Required - Mozilla Thunderbird" },
  838. properties = { screen = 1, tag = root.tags()[9], switch_to_tags = false } },
  839. -- -- Titlebars
  840. -- -- Add titlebars to normal clients and dialogs
  841. -- { rule_any = {type = { "normal", "dialog" }
  842. -- }, properties = { titlebars_enabled = false }
  843. -- },
  844. }
  845. -- }}}
  846. -- {{{ Signals
  847. -- Signal function to execute when a new client appears.
  848. client.connect_signal("manage", function(c)
  849. -- Set the windows at the slave,
  850. -- i.e. put it at the end of others instead of setting it master.
  851. -- if not awesome.startup then awful.client.setslave(c) end
  852. if awesome.startup
  853. and not c.size_hints.user_position
  854. and not c.size_hints.program_position then
  855. -- Prevent clients from being unreachable after screen count changes.
  856. awful.placement.no_offscreen(c)
  857. end
  858. end)
  859. -- Focus urgent clients automatically
  860. -- When I launch a client at a particular place, I want to go to that client.
  861. client.connect_signal("property::urgent", function(c)
  862. c.minimized = false
  863. c:jump_to()
  864. end)
  865. -- Makes all floating clients border_width = 1
  866. client.connect_signal("property::floating", function(c)
  867. -- if c.floating then
  868. -- c.border_width = 1
  869. -- else
  870. -- c.border_width = beautiful.border_width
  871. -- end
  872. -- The same as above but a little bit shorter!
  873. c.border_width = c.floating and 1 or beautiful.border_width
  874. end)
  875. -- Add a titlebar if titlebars_enabled is set to true in the rules.
  876. client.connect_signal("request::titlebars", function(c)
  877. -- buttons for the titlebar
  878. local buttons = gears.table.join(
  879. awful.button({ }, 1, function()
  880. c:emit_signal("request::activate", "titlebar", {raise = true})
  881. awful.mouse.client.move(c)
  882. end),
  883. awful.button({ }, 3, function()
  884. c:emit_signal("request::activate", "titlebar", {raise = true})
  885. awful.mouse.client.resize(c)
  886. end)
  887. )
  888. awful.titlebar(c) : setup {
  889. { -- Left
  890. awful.titlebar.widget.iconwidget(c),
  891. buttons = buttons,
  892. layout = wibox.layout.fixed.horizontal
  893. },
  894. { -- Middle
  895. { -- Title
  896. align = "center",
  897. widget = awful.titlebar.widget.titlewidget(c)
  898. },
  899. buttons = buttons,
  900. layout = wibox.layout.flex.horizontal
  901. },
  902. { -- Right
  903. awful.titlebar.widget.floatingbutton (c),
  904. awful.titlebar.widget.maximizedbutton(c),
  905. awful.titlebar.widget.stickybutton (c),
  906. awful.titlebar.widget.ontopbutton (c),
  907. awful.titlebar.widget.closebutton (c),
  908. layout = wibox.layout.fixed.horizontal()
  909. },
  910. layout = wibox.layout.align.horizontal
  911. }
  912. end)
  913. -- Enable sloppy focus, so that focus follows mouse.
  914. client.connect_signal("mouse::enter", function(c)
  915. c:emit_signal("request::activate", "mouse_enter", {raise = false})
  916. end)
  917. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  918. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  919. -- }}}
  920. -- Autostart
  921. local function run_once(cmd_arr)
  922. for _, cmd in ipairs(cmd_arr) do
  923. os.execute(string.format("pgrep -u $USER -fx '%s' > /dev/null || (%s &)", cmd, cmd))
  924. -- awful.spawn.with_shell(string.format("pgrep -u $USER -fx '%s' > /dev/null || (%s &)", cmd, cmd))
  925. end
  926. end
  927. run_once({
  928. "xxkb",
  929. "setxkbmap -layout us,ru -option grp:caps_toggle",
  930. -- "/usr/lib/xfce4/notifyd/xfce4-notifyd", -- no need on AwesomeWM
  931. -- /usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1, -- for Debian
  932. -- "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1", -- for Arch
  933. -- "/usr/libexec/polkit-gnome-authentication-agent-1", -- for Void
  934. "/usr/libexec/xfce-polkit", -- for Void
  935. "xrdb "..HOME.."/.Xresources",
  936. "nitrogen --restore",
  937. "volumeicon",
  938. "nm-applet",
  939. "xfce4-power-manager",
  940. -- "clipit",
  941. -- "diodon",
  942. "xfce4-clipman",
  943. -- "$HOME/.myScripts/restore_brightness.sh", -- for HP
  944. "picom --config "..HOME.."/.config/picom/picom.conf",
  945. "conky -c "..HOME.."/.myScripts/conky/conkyrc",
  946. "/usr/bin/python /usr/bin/udiskie",
  947. "xiccd",
  948. "python /usr/bin/redshift-gtk",
  949. -- "/usr/bin/python /usr/bin/fluxgui",
  950. HOME.."/Programs/CheckInternetConnection/CheckInternetConnection",
  951. HOME.."/Programs/AppImageApplications/BreakTimer.AppImage",
  952. "birdtray",
  953. "xmodmap -e \"keycode 135 = Super_R\"",
  954. }) -- entries must be comma-separated