config.py_Debian 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import re
  4. import socket
  5. import subprocess
  6. from typing import List # noqa: F401
  7. from libqtile import bar, layout, widget, hook
  8. from libqtile.config import Click, Drag, Group, Key, Screen, KeyChord, Match
  9. from libqtile.lazy import lazy
  10. from libqtile import qtile
  11. # from modules import check_updates
  12. # from modules import arcobattery
  13. from modules import memory
  14. from modules import all_windows_count
  15. from modules import syncthing
  16. from modules import show_updates
  17. def get_all_netifaces(path_to_state="/sys/class/net/"):
  18. """
  19. Get all netifaces in the /sys/class/net/ and
  20. add all to the list except 'lo'.
  21. """
  22. netifaces_list = []
  23. for dir in os.listdir(path_to_state):
  24. if os.path.isdir("{}{}".format(path_to_state, dir)):
  25. if dir != "lo":
  26. netifaces_list.append(dir)
  27. return netifaces_list
  28. def get_upped_netiface(netifaces=[]):
  29. """
  30. Check which interface is upped for widget.Net.
  31. Returns the first upped netiface.
  32. """
  33. if netifaces:
  34. for netiface in netifaces:
  35. state = subprocess.check_output(["cat", "{}{}{}".format(path_to_state, netiface, "/operstate")]).decode("utf-8").rstrip()
  36. if state == "up":
  37. return netiface
  38. return None
  39. mod = "mod4"
  40. alt = "mod1"
  41. my_term = "alacritty"
  42. my_term_extra = "terminator"
  43. # my_term = "konsole"
  44. my_font = "Ubuntu"
  45. my_nerd_font = "Ubuntu Nerd Font"
  46. my_nerd_font_extra = "Sarasa Mono SC Nerd"
  47. my_mono_font = "Ubuntu Mono"
  48. my_mono_bold_font = "Ubuntu Mono Bold"
  49. home = os.path.expanduser("~")
  50. my_config = home + "/.config/qtile/config.py"
  51. # Check which network iface is upped.
  52. path_to_state = "/sys/class/net/" # enp2s0/operstate"
  53. # default_upped_netiface = "wlo1"
  54. netifaces = get_all_netifaces(path_to_state)
  55. upped_netiface = get_upped_netiface(netifaces)
  56. # Counter of opened windows
  57. # opened_windows_counter = 0
  58. keys = [
  59. # <SUPER> + FUNCTION KEYS
  60. Key([mod], "Return", lazy.spawn(my_term), desc="Launch terminal"),
  61. Key([mod, "shift"], "Return", lazy.spawn("terminator"), desc="Launch terminator"),
  62. Key([mod], "r", lazy.spawn("rofi run -show drun -show-icons"), desc="Run App Lancher"),
  63. Key([mod], "d", lazy.spawn("dmenu_run -nb #222B2E -nf #09DBC9 -sb #009185 -p 'Run: ' -fn 'Ubuntu-18:normal'"), desc="Run dmenu"), # Materia Manjaro
  64. # Key([mod], "d", lazy.spawn("dmenu_run -nb #282828 -nf #d79921 -sb #fea63c -p 'Run: ' -fn 'Ubuntu-18:normal'"), desc="Run dmenu"), # Gruvbox
  65. Key([mod], "Menu", lazy.spawn("xmodmap -e 'keycode 135 = Super_R'"), desc="Map the Menu button to right super (Super_R)"),
  66. Key([mod], "Print", lazy.spawn("flameshot gui"), desc="Run flameshot (take screenshot)"),
  67. Key([mod], "w", lazy.spawn("firefox"), desc="Launch Firefox"),
  68. Key([mod], "u", lazy.spawn("qutebrowser"), desc="Launch qutebrowser"),
  69. Key([mod], "e", lazy.spawn("dolphin"), desc="Launch File Manager"),
  70. Key([mod], "p", lazy.spawn("thunar"), desc="Launch File Manager"),
  71. Key([mod], "i", lazy.spawn("pamac-manager"), desc="Launch Pamac"),
  72. Key([mod], "g", lazy.spawn(home + "/.myScripts/runGimpDiscreteGr.sh"), desc="Run GIMP DiscreteGraphics"),
  73. Key([mod], "b", lazy.spawn(home + "/Programs/SublimeText/sublime_text"), desc="Run Sublime Text"),
  74. Key([mod], "t", lazy.spawn(home + "/Programs/Telegram/Telegram -workdir /home/alex/.local/share/TelegramDesktop/ -- %u"), desc="Run Telegram"),
  75. Key([mod], "x", lazy.spawn("xterm"), desc="Run XTerm"),
  76. Key([mod], "v", lazy.spawn(my_term + " -e " + home + "/.config/vifm/scripts/vifmrun"), desc="Run vifm"),
  77. # TOGGLE FULLSCREEN
  78. Key([mod], "f", lazy.window.toggle_fullscreen(), desc="Toggle fullscreen"),
  79. # SWITCH BETWEEN GROUPS
  80. Key([mod], "Right", lazy.screen.next_group(), desc="Switch to the right group"),
  81. Key([mod], "Left", lazy.screen.prev_group(), desc="Switch to the left group"),
  82. # SWITCH BETWEEN LAYOUTS
  83. Key([mod], "Tab", lazy.next_layout(), desc="Switch to the next layout"),
  84. Key([mod, "shift"], "Tab", lazy.prev_layout(), desc="Switch to the previous layout"),
  85. # CHANGE FOCUS
  86. Key([mod], "k", lazy.layout.up(), desc="Move focus up in stack pane"),
  87. Key([mod], "j", lazy.layout.down(), desc="Move focus down in stack pane"),
  88. Key([mod], "h", lazy.layout.left(), desc="Move focus left in stack pane"),
  89. Key([mod], "l", lazy.layout.right(), desc="Move focus right in stack pane"),
  90. # Key([mod], "Up", lazy.layout.up(), desc="Move focus up in stack pane"),
  91. # Key([mod], "Down", lazy.layout.down(), desc="Move focus down in stack pane"),
  92. # Key([mod], "Left", lazy.layout.left(), desc="Move focus left in stack pane"),
  93. # Key([mod], "Right", lazy.layout.right(), desc="Move focus right in stack pane"),
  94. Key([mod], "space", lazy.layout.next(), desc="Switch window focus to other pane(s) of stack"),
  95. # <SUPER> + <SHIFT> + KEYS (-nf #fea63c)
  96. Key([mod, "shift"], "y", lazy.spawn(home + "/.myScripts/start-stop_syncthing.sh"), desc="Start-Stop Syncthing (for Dropbox sync)"),
  97. Key([mod, "shift"], "c", lazy.window.kill(), desc="Kill focused window"),
  98. Key([mod, "shift"], "x", lazy.spawn("xkill"), desc="Kill not answered window"),
  99. Key([mod, "shift"], "r", lazy.restart(), desc="Restart qtile"),
  100. Key([mod, "shift"], "q", lazy.shutdown(), desc="Shutdown qtile"),
  101. # TOGGLE FLOATING LAYOUT
  102. Key([mod, "shift"], "f", lazy.window.toggle_floating(), desc="Toggle floating"),
  103. # MOVE WINDOWS UP OR DOWN IN CURRENT STACK
  104. Key([mod, "shift"], "k", lazy.layout.shuffle_up(), desc="Move window up in current stack "),
  105. Key([mod, "shift"], "j", lazy.layout.shuffle_down(), desc="Move window down in current stack "),
  106. # Key([mod, "shift"], "h", lazy.layout.swap_left(), desc="Move window left in current stack "),
  107. # Key([mod, "shift"], "l", lazy.layout.swap_right(), desc="Move window right in current stack "),
  108. Key([mod, "shift"], "h", lazy.layout.shuffle_left(), desc="Move window left in current stack "),
  109. Key([mod, "shift"], "l", lazy.layout.shuffle_right(), desc="Move window right in current stack "),
  110. Key([mod, "shift"], "Up", lazy.layout.shuffle_up(), desc="Move window up in current stack "),
  111. Key([mod, "shift"], "Down", lazy.layout.shuffle_down(), desc="Move window down in current stack "),
  112. Key([mod, "shift"], "Left", lazy.layout.shuffle_left(), desc="Move window left in current stack "),
  113. Key([mod, "shift"], "Right", lazy.layout.shuffle_right(), desc="Move window right in current stack "),
  114. # FLIP LAYOUT FOR MONADTALL/WIDE
  115. Key([mod, "shift"], "space", lazy.layout.flip(), desc="Flip main (left) panel with others"),
  116. # NORMALIZE, MINIMIZE, MAXIMIZE
  117. Key([mod, "shift"], "n", lazy.layout.normalize(), desc="Normalize window size ratios"),
  118. Key([mod, "shift"], "m", lazy.layout.maximize(), desc="Toggle window between minimum and maximum sizes"),
  119. Key([mod, "shift"], "d", lazy.window.toggle_minimize(), desc="Toggle window between minimumize and normal sizes"),
  120. # <SUPER> + <ALT> + KEYS
  121. Key([mod, alt], "space", lazy.spawn(home + "/.myScripts/touchpadONOFF.sh"), desc="Touchpad On/Off"),
  122. # FLIP LAYOUT FOR BSP LAYOUT
  123. Key([mod, alt], "k", lazy.layout.flip_up(), desc=""),
  124. Key([mod, alt], "j", lazy.layout.flip_down(), desc=""),
  125. Key([mod, alt], "h", lazy.layout.flip_left(), desc=""),
  126. Key([mod, alt], "l", lazy.layout.flip_right(), desc=""),
  127. # <SUPER> + <CTRL> + KEYS
  128. # RESIZE UP, DOWN, LEFT, RIGHT
  129. Key([mod, "control"], "l",
  130. lazy.layout.grow_right(),
  131. lazy.layout.grow(),
  132. lazy.layout.increase_ratio(),
  133. lazy.layout.delete()
  134. ),
  135. Key([mod, "control"], "Right",
  136. lazy.layout.grow_right(),
  137. lazy.layout.grow(),
  138. lazy.layout.increase_ratio(),
  139. lazy.layout.delete()
  140. ),
  141. Key([mod, "control"], "h",
  142. lazy.layout.grow_left(),
  143. lazy.layout.shrink(),
  144. lazy.layout.decrease_ratio(),
  145. lazy.layout.add()
  146. ),
  147. Key([mod, "control"], "Left",
  148. lazy.layout.grow_left(),
  149. lazy.layout.shrink(),
  150. lazy.layout.decrease_ratio(),
  151. lazy.layout.add()
  152. ),
  153. Key([mod, "control"], "k",
  154. lazy.layout.grow_up(),
  155. lazy.layout.grow(),
  156. lazy.layout.decrease_nmaster()
  157. ),
  158. Key([mod, "control"], "Up",
  159. lazy.layout.grow_up(),
  160. lazy.layout.grow(),
  161. lazy.layout.decrease_nmaster()
  162. ),
  163. Key([mod, "control"], "j",
  164. lazy.layout.grow_down(),
  165. lazy.layout.shrink(),
  166. lazy.layout.increase_nmaster()
  167. ),
  168. Key([mod, "control"], "Down",
  169. lazy.layout.grow_down(),
  170. lazy.layout.shrink(),
  171. lazy.layout.increase_nmaster()
  172. ),
  173. Key([mod, "control"], "r", lazy.layout.reset()),
  174. # <ALT> + KEYS
  175. KeyChord([alt], "m", [
  176. Key([], "c", lazy.spawn(home + "/.myScripts/dmenu/dmenu-edit-configs.sh"), desc="Run dmenu script for editing config files"),
  177. Key([], "p", lazy.spawn(home + "/.myScripts/dmenu/dmenu-passmenu.sh"), desc="Run dmenu script for editing config files"),
  178. Key([], "l", lazy.spawn(home + "/.myScripts/system_exit/lock.sh"), desc="Lock screen"),
  179. Key([], "k", lazy.spawn(home + "/.myScripts/dmenu/dmenu-kill.sh"), desc="Kill chosen process"),
  180. Key([], "s", lazy.spawn(home + "/.myScripts/dmenu/dmenu-search.sh"), desc="Run chosen search engine"),
  181. Key([], "e", lazy.spawn(home + "/.myScripts/dmenu/dmenu-unicode.sh"), desc="Choose an emoji"),
  182. Key([], "x", lazy.spawn(home + "/.myScripts/dmenu/dmenu-system-exit.sh"), desc="System exit menu")],
  183. mode="Dmenu"
  184. ),
  185. # Key([alt], "c", lazy.spawn(home + "/.myScripts/dmenu/dmenu-edit-configs.sh"), desc="Run dmenu script for editing config files"),
  186. # Key([alt], "p", lazy.spawn(home + "/.myScripts/dmenu/dmenu-passmenu.sh"), desc="Run dmenu script for editing config files"),
  187. # Key([alt], "s", lazy.spawn(home + "/.myScripts/dmenu/dmenu-system-exit.sh"), desc="System exit menu"),
  188. # Key([alt], "l", lazy.spawn(home + "/.myScripts/system_exit/lock.sh"), desc="Lock screen"),
  189. # Key([alt], "t", lazy.spawn(home + "/.myScripts/dmenu/dmenu-kill.sh"), desc="Kill chosen process"),
  190. # Key([alt], "e", lazy.spawn(home + "/.myScripts/dmenu/dmenu-search.sh"), desc="Run chosen search engine"),
  191. # Key([alt], "k", lazy.spawn(home + "/.myScripts/on-off_conky.sh"), desc="On-Off conky"),
  192. Key([alt], "w", lazy.spawn("rofi run -show window -show-icons"), desc="Switch between opened windows"),
  193. Key([alt], "Tab", lazy.group.next_window(), desc="Switch to the next window"),
  194. # <CONTROL> + <ALT> + KEYS
  195. # <CONTROL> + <SHIFT> + KEYS
  196. # <ALT> + <SHIFT> + KEYS
  197. Key([alt, "shift"], "Tab", lazy.group.prev_window(), desc="Switch to the previous window"),
  198. # MULTIMEDIA KEYS
  199. # <Fn> + <F1-F12>
  200. Key([], "XF86Display", lazy.spawn("lxrandr"), desc="Run lxrandr (choose monitor)"),
  201. Key([], "XF86ScreenSaver", lazy.spawn(home + "/.myScripts/system_exit/lock.sh"), desc="Lock screen"),
  202. Key([], "XF86Battery", lazy.spawn("xfce4-power-manager-settings"), desc="Power manager settings"),
  203. # <SUPER> + <F1-F12>
  204. # Brightness & Volume (extra step 5)
  205. Key([mod], "F2", lazy.spawn(home + "/.myScripts/brightness_down.sh"), desc="Brightness Down (5-)"),
  206. # lazy.spawn("brightnessctl set 5-"),
  207. Key([mod], "F3", lazy.spawn(home + "/.myScripts/brightness_up.sh"), desc="Brightness Up (+5)"),
  208. # lazy.spawn("brightnessctl set +5"),
  209. Key([mod], "F8", lazy.spawn(home + "/.myScripts/volume_down.sh"), desc="Volume Down"),
  210. Key([mod], "F9", lazy.spawn(home + "/.myScripts/volume_up.sh"), desc="Volume Up more than 100%"),
  211. ]
  212. # MOVE/RESIZE FLOATING WINDOW
  213. for key, x, y in [
  214. ("Left", -10, 0),
  215. ("Right", 10, 0),
  216. ("Up", 0, -10),
  217. ("Down", 0, 10)]:
  218. keys.append(Key([mod, "shift"], key, lazy.window.move_floating(x, y)))
  219. keys.append(Key([mod, "control"], key, lazy.window.resize_floating(x, y)))
  220. #       v                
  221. #     🌐♬ 🌡 🖬  ⟳ ₿  ⮋⮉🡇 🡅 ⇓⇑      
  222. group_names = [(" ", {"layout": "columns"}), # WWW
  223. (" ", {"layout": "columns"}), # DEV
  224. # (" ", {"layout": "monadtall"}), # DEV
  225. (" ", {"layout": "max"}), # FM
  226. (" ", {"layout": "columns"}), # SYS
  227. (" ", {"layout": "columns"}), # VIRT
  228. (" ", {"layout": "columns"}), # CHAT
  229. (" ", {"layout": "columns"}), # GFX
  230. (" ", {"layout": "max"}), # VID
  231. (" ", {"layout": "columns"})] # MULT
  232. groups = [Group(name, **kwargs, label="{}{}".format(name, i)) for i, (name, kwargs) in enumerate(group_names, 1)]
  233. for i, group_name in enumerate(group_names, 1):
  234. keys.extend([
  235. Key([mod], str(i),
  236. lazy.group[group_name[0]].toscreen(),
  237. desc="Switch to another group"),
  238. Key([mod, "shift"], str(i),
  239. lazy.window.togroup(group_name[0]),
  240. lazy.group[group_name[0]].toscreen(), # follow the window when it moves to another group
  241. desc="Send current window to another group")
  242. ])
  243. layout_theme = {"border_width": 3,
  244. "margin": 5,
  245. "border_focus": "2eb398", # Materia Manjaro
  246. "border_normal": "1d2330"
  247. # "border_focus": "d79922", # Gruvbox yellow
  248. # "border_focus": "fea63c", # Gruvbox yellow (lighter)
  249. }
  250. layouts = [
  251. # layout.Bsp(**layout_theme),
  252. layout.Columns(**layout_theme, border_on_single=True),
  253. layout.Max(**layout_theme),
  254. layout.MonadTall(**layout_theme),
  255. layout.MonadWide(**layout_theme),
  256. # layout.Tile(shift_windows=True, **layout_theme),
  257. # layout.Stack(stacks=2, **layout_theme),
  258. # layout.Stack(num_stacks=2),
  259. # layout.RatioTile(**layout_theme),
  260. # layout.VerticalTile(**layout_theme),
  261. # layout.Matrix(**layout_theme),
  262. # layout.Zoomy(**layout_theme),
  263. # layout.TreeTab(
  264. # font = my_font,
  265. # fontsize=12,
  266. # sections=["FIRST", "SECOND"],
  267. # section_fontsize=12,
  268. # bg_color="141414",
  269. # active_bg="90C435",
  270. # active_fg="000000",
  271. # inactive_bg="384323",
  272. # inactive_fg="a0a0a0",
  273. # padding_y=5,
  274. # section_top=10,
  275. # panel_width=320
  276. # ),
  277. # layout.Floating(**layout_theme)
  278. ]
  279. # DT's colors
  280. # colors = [["#282c34", "#282c34"], # panel background
  281. # ["#434758", "#434758"], # background for current screen tab
  282. # ["#ffffff", "#ffffff"], # font color for group names
  283. # ["#ff5555", "#ff5555"], # border line color for current tab
  284. # ["#8d62a9", "#8d62a9"], # border line color for other tab and odd widgets
  285. # ["#668bd7", "#668bd7"], # color for the even widgets
  286. # ["#e1acff", "#e1acff"]] # window name
  287. # My colors
  288. # colors = [["#222B2E", "#222B2E"], # 0 panel background
  289. # ["#585E72", "#585E72"], # 1 background for current screen tab
  290. # ["#DBDCD5", "#DBDCD5"], # 2 font color for group names
  291. # ["#009185", "#009185"], # 3 border line color for current tab
  292. # ["#8d62a9", "#8d62a9"], # 4 border line color for other tab and odd widgets
  293. # ["#668bd7", "#668bd7"], # 5 color for the even widgets
  294. # ["#24D2AF", "#24D2AF"], # 6 window name
  295. # ["#E2A0A5", "#E2A0A5"], # 7 CPU widget
  296. # ["#F2B06A", "#F2B06A"], # 8 Memory widget
  297. # ["#03DB25", "#03DB25"], # 9 NetSpeed widget
  298. # ["#ffffff", "#ffffff"], # 10 Layout widget
  299. # ["#55EBEA", "#55EBEA"], # 11 KeyboardLayout widget
  300. # ["#F3F008", "#F3F008"], # 12 Date widget
  301. # ["#404555", "#404555"], # 13 system tray
  302. # ["#F6F806", "#F6F806"]] # 14 updates
  303. # Materia Manjaro
  304. colors = [["#263238", "#263238"], # 0 panel background
  305. ["#585E72", "#585E72"], # 1 background for current screen tab
  306. ["#dbdcd5", "#dbdcd5"], # 2 font color for group names
  307. ["#009185", "#009185"], # 3 border line color for current tab
  308. ["#8d62a9", "#8d62a9"], # 4 border line color for other tab and odd widgets
  309. ["#6182b8", "#6182b8"], # 5 color for the even widgets
  310. ["#24d2af", "#24d2af"], # 6 window name
  311. ["#e2a0a5", "#e2a0a5"], # 7 CPU widget
  312. ["#ffb62c", "#ffb62c"], # 8 Memory widget
  313. ["#91b859", "#91b859"], # 9 NetSpeed widget
  314. ["#ffffff", "#ffffff"], # 10 Layout widget
  315. ["#39adb5", "#39adb5"], # 11 KeyboardLayout widget
  316. ["#39adb5", "#39adb5"], # 12 Date widget
  317. # ["#f2b06a", "#f2b06a"], # 12 Date widget
  318. ["#404555", "#404555"], # 13 system tray
  319. ["#e2e0a5", "#e2e0a5"], # 14 updates
  320. # ["#ffcb6b", "#ffcb6b"], # 14 updates
  321. ["#eb7bef", "#eb7bef"], # 15 weather
  322. ["#d79921", "#d79921"], # 16 Chord
  323. ["#ffbb00", "#ffbb00"], # 17 Dmenu (Chord) background
  324. ["#070800", "#070800"], # 18 Dmenu (Chord) foreground
  325. ["#00ff00", "#00ff00"], # 19 Syncthing active
  326. ["#ff5555", "#ff5555"], # 20 Syncthing inactive
  327. ["#E4C962", "#E4C962"]] # 21 Active group
  328. # ["#ec30f3", "#ec30f3"]] # 15 weather
  329. # ["#e2e0a5", "#e2e0a5"]] # 15 weather
  330. # Gruvbox colors
  331. # colors = [["#282828", "#282828"], # 0 panel background
  332. # ["#505050", "#505050"], # 1 background for current screen tab
  333. # ["#ebdbb2", "#ebdbb2"], # 2 font color for group names
  334. # ["#d79921", "#d79921"], # 3 border line color for current tab
  335. # ["#b16286", "#b16286"], # 4 border line color for other tab and odd widgets
  336. # ["#458588", "#458588"], # 5 color for the even widgets
  337. # ["#fea63c", "#fea63c"], # 6 window name
  338. # ["#b16286", "#b16286"], # 7 CPU widget
  339. # # ["#cc241d", "#cc241d"], # 7 CPU widget
  340. # ["#98971a", "#98971a"], # 8 Memory widget
  341. # ["#689d6a", "#689d6a"], # 9 NetSpeed widget
  342. # ["#ffffff", "#ffffff"], # 10 Layout widget
  343. # ["#458588", "#458588"], # 11 KeyboardLayout widget
  344. # ["#a89984", "#a89984"], # 12 Date widget
  345. # ["#282828", "#282828"], # 13 system tray
  346. # ["#d79921", "#d79921"]] # 14 updates
  347. ##### DEFAULT WIDGET SETTINGS #####
  348. widget_defaults = dict(
  349. font=my_font,
  350. fontsize=12,
  351. padding=2,
  352. background=colors[2]
  353. )
  354. extension_defaults = widget_defaults.copy()
  355. def init_widgets_list():
  356. prompt = "{0}@{1}: ".format(os.environ["USER"], socket.gethostname())
  357. widgets_list = [
  358. # widget.Sep(
  359. # linewidth=0,
  360. # padding=3,
  361. # foreground=colors[2],
  362. # background=colors[0]
  363. # ),
  364. # widget.Image(
  365. # filename="~/.config/qtile/icons/logos/debian_logo_green_brighter+.png",
  366. # mouse_callbacks={"Button1": lambda qtile: qtile.cmd_spawn("rofi run -show drun -show-icons")}
  367. # ),
  368. # widget.Sep(
  369. # linewidth=0,
  370. # padding=3,
  371. # foreground=colors[2],
  372. # background=colors[0]
  373. # ),
  374. widget.GroupBox(
  375. font=my_nerd_font,
  376. fontsize=14,
  377. margin_y=3,
  378. margin_x=0,
  379. # padding_y=5,
  380. # padding_x=3,
  381. padding_y=7,
  382. padding_x=3,
  383. borderwidth=3,
  384. active=colors[21],
  385. inactive=colors[2],
  386. rounded=False,
  387. highlight_color=colors[1],
  388. # highlight_method="line",
  389. highlight_method="block",
  390. urgent_alert_method="block",
  391. this_current_screen_border=colors[3],
  392. this_screen_border=colors[4],
  393. other_current_screen_border=colors[0],
  394. other_screen_border=colors[0],
  395. foreground=colors[2],
  396. background=colors[0]
  397. ),
  398. widget.Chord(
  399. padding = 10,
  400. background=colors[17],
  401. foreground=colors[18],
  402. fontsize=14
  403. ),
  404. widget.WindowName(
  405. # font=my_mono_bold_font,
  406. font=my_font,
  407. fontsize=14,
  408. # show_state="{name}", # show_state=False,
  409. show_state="{state}{name}", # show_state=True,
  410. foreground=colors[6],
  411. background=colors[0],
  412. padding=0
  413. ),
  414. # widget.Spacer(
  415. # length=bar.STRETCH,
  416. # background=colors[0]
  417. # ),
  418. # check_updates.CheckUpdates(
  419. widget.CheckUpdates(
  420. foreground=colors[14],
  421. background=colors[0],
  422. colour_have_updates=colors[14],
  423. # colour_no_updates="ffffff",
  424. font=my_nerd_font,
  425. fontsize=14,
  426. custom_command="apt-show-versions -u -b",
  427. # custom_command="apt-show-versions --upgradeable",
  428. # custom_command="apt-show-versions | grep upgradeable | wc -l",
  429. display_format=" {updates}", # ⟳ 
  430. distro="Debian",
  431. # no_update_string="No updates",
  432. mouse_callbacks={
  433. # "Button1": lambda: qtile.cmd_spawn(my_term_extra + " -e 'sudo apt update && sudo apt upgrade && $SHELL'"),
  434. "Button1": widget.CheckUpdates.poll,
  435. "Button3": lambda: show_updates.show_updates_debian(),
  436. # "Button3": lambda: qtile.cmd_spawn(home + "/.myScripts/show_updates_apt.sh"),
  437. "Button2": lambda: qtile.cmd_spawn(my_term_extra + " -e 'sudo apt update && sudo apt upgrade && $SHELL'")
  438. },
  439. # execute=my_term_extra + " -e 'sudo apt update && sudo apt upgrade && $SHELL'",
  440. # execute=my_term + " -e sudo apt update && sudo apt upgrade && $SHELL", # for alacritty
  441. # execute=my_term + ' -e "sudo aptitude update && sudo aptitude safe-upgrade && $SHELL"', # for terminator
  442. # update_interval=900 # 15min after cron's apt-update task
  443. update_interval=300 # 5min
  444. ),
  445. widget.Sep(
  446. linewidth=1,
  447. padding=10,
  448. foreground=colors[2],
  449. background=colors[0]
  450. ),
  451. widget.TextBox(
  452. # text="⇆ ",
  453. text="🗘 ",
  454. fontsize=16,
  455. foreground="#55ebea",
  456. background=colors[0],
  457. padding=0,
  458. ),
  459. syncthing.Syncthing(
  460. path_to_script=home + "/.myScripts/get_syncthing_status.sh",
  461. font=my_nerd_font,
  462. label="Syncthing\n ",
  463. update_interval=60,
  464. background=colors[0],
  465. active_color=colors[19],
  466. inactive_color=colors[20],
  467. padding=0
  468. ),
  469. widget.Sep(
  470. linewidth=1,
  471. padding=10,
  472. foreground=colors[2],
  473. background=colors[0]
  474. ),
  475. widget.TextBox(
  476. # text="⛅",
  477. text="🌡",
  478. fontsize=16,
  479. foreground=colors[15],
  480. background=colors[0],
  481. padding=0
  482. ),
  483. widget.OpenWeather(
  484. foreground=colors[15],
  485. background=colors[0],
  486. coordinates={"longitude": "30.9754", "latitude": "52.4345"},
  487. # format="{location_city}: {temp}°{units_temperature}\n{weather_0_icon} {weather_details}",
  488. format="{location_city}: {temp}°{units_temperature}\n{weather_details}",
  489. update_interval=1800,
  490. mouse_callbacks={
  491. "Button3": lambda: qtile.cmd_spawn("xdg-open https://openweathermap.org/city/627907"),
  492. }
  493. ),
  494. widget.Sep(
  495. linewidth=1,
  496. padding=10,
  497. foreground=colors[2],
  498. background=colors[0]
  499. ),
  500. widget.TextBox(
  501. text="",
  502. # text=" ",
  503. font=my_nerd_font,
  504. fontsize=16,
  505. foreground=colors[7],
  506. background=colors[0],
  507. padding=0,
  508. mouse_callbacks={
  509. "Button1": lambda: qtile.cmd_spawn(home + "/.myScripts/top5_cpu_usage.sh"),
  510. "Button3": lambda: qtile.cmd_spawn(my_term + " -e htop")
  511. }
  512. ),
  513. widget.CPU(
  514. foreground=colors[7],
  515. background=colors[0],
  516. padding=0,
  517. format="{freq_current}GHz\n{load_percent: .0f}%",
  518. mouse_callbacks={
  519. "Button1": lambda: qtile.cmd_spawn(home + "/.myScripts/top5_cpu_usage.sh"),
  520. "Button3": lambda: qtile.cmd_spawn(my_term + " -e htop")
  521. }
  522. ),
  523. widget.Sep(
  524. linewidth=1,
  525. padding=10,
  526. foreground=colors[2],
  527. background=colors[0]
  528. ),
  529. widget.TextBox(
  530. text="",
  531. font=my_nerd_font,
  532. fontsize=16,
  533. foreground=colors[8],
  534. background=colors[0],
  535. padding=0,
  536. mouse_callbacks={
  537. "Button1": lambda: qtile.cmd_spawn(home + "/.myScripts/top5_mem_usage.sh"),
  538. "Button3": lambda: qtile.cmd_spawn(my_term + " -e htop")
  539. }
  540. ),
  541. memory.Memory(
  542. foreground=colors[8],
  543. background=colors[0],
  544. padding=0,
  545. format="{MemUsed: .2f}{mm}\n{MemPercent: .0f}%",
  546. measure_mem="G",
  547. mouse_callbacks={
  548. "Button1": lambda: qtile.cmd_spawn(home + "/.myScripts/top5_mem_usage.sh"),
  549. "Button3": lambda: qtile.cmd_spawn(my_term + " -e htop")
  550. }
  551. ),
  552. widget.Sep(
  553. linewidth=1,
  554. padding=10,
  555. foreground=colors[2],
  556. background=colors[0]
  557. ),
  558. widget.Net(
  559. interface=upped_netiface,
  560. # format=upped_netiface + ":{down} ↓↑{up}",
  561. # format="{down} ⇓⇑{up}",
  562. # format="{down} ⤋⤊{up}",
  563. # format="{down} ⬇⬆{up}",
  564. # format="{down} 🡇🡅{up}",
  565. # format="{down}  {up}",
  566. font=my_nerd_font,
  567. format="{up} \n{down} ",
  568. foreground=colors[9],
  569. background=colors[0],
  570. padding=0
  571. ),
  572. widget.Sep(
  573. linewidth=1,
  574. padding=10,
  575. foreground=colors[2],
  576. background=colors[0]
  577. ),
  578. widget.KeyboardKbdd(
  579. configured_keyboards=["🇺🇸", "🇷🇺"],
  580. # configured_keyboards=["US", "RU"],
  581. foreground=colors[11],
  582. background=colors[0],
  583. fontsize=16,
  584. padding=1
  585. ),
  586. widget.Systray(
  587. background=colors[0],
  588. padding=5
  589. ),
  590. # widget.BatteryIcon(
  591. # theme_path=home + "/.config/qtile/icons/battery_icons_vert",
  592. # background=colors[0],
  593. # ),
  594. # widget.BatteryIcon(
  595. # background=colors[0],
  596. # ),
  597. # widget.Battery(
  598. # energy_now_file="charge_now",
  599. # energy_full_file="charge_full",
  600. # power_now_file="current_now",
  601. # format="{char} {percent:2.0%}\n{hour:d}:{min:02d} {watt:.2f}W",
  602. # foreground=colors[5],
  603. # background=colors[0],
  604. # update_interval=5
  605. # ),
  606. # widget.Sep(
  607. # linewidth=0,
  608. # padding=3,
  609. # foreground=colors[0],
  610. # background=colors[0]
  611. # ),
  612. widget.CurrentLayoutIcon(
  613. # custom_icon_paths=[home + "/.config/qtile/icons/layouts"],
  614. foreground=colors[10],
  615. background=colors[0],
  616. padding=0,
  617. scale=0.6,
  618. mouse_callbacks={
  619. "Button1": qtile.cmd_next_layout,
  620. "Button3": qtile.cmd_prev_layout,
  621. }
  622. ),
  623. widget.WindowCount(
  624. text_format="{num}/",
  625. fontsize=14,
  626. padding=0,
  627. foreground=colors[10],
  628. background=colors[0]
  629. ),
  630. all_windows_count.WindowCount(
  631. text_format="{num}",
  632. fontsize=14,
  633. padding=0,
  634. foreground=colors[10],
  635. background=colors[0]
  636. ),
  637. widget.Sep(
  638. linewidth=1,
  639. padding=10,
  640. foreground=colors[2],
  641. background=colors[0]
  642. ),
  643. widget.TextBox(
  644. text="",
  645. font=my_nerd_font,
  646. fontsize=16,
  647. foreground=colors[12],
  648. background=colors[0],
  649. # fontsize=14,
  650. padding=0,
  651. mouse_callbacks={"Button1": lambda: qtile.cmd_spawn("gsimplecal")}
  652. ),
  653. widget.Clock(
  654. foreground=colors[12],
  655. background=colors[0],
  656. padding=3,
  657. # mouse_callbacks={"Button1": lambda qtile: qtile.cmd_spawn("gsimplecal")},
  658. mouse_callbacks={"Button1": lambda: qtile.cmd_spawn("gsimplecal")},
  659. format="%a, %d %b\n%H:%M:%S"
  660. ),
  661. # widget.Sep(
  662. # linewidth=0,
  663. # padding=3,
  664. # foreground=colors[2],
  665. # background=colors[0]
  666. # )
  667. ]
  668. return widgets_list
  669. def init_widgets_screen1():
  670. widgets_screen1 = init_widgets_list()
  671. return widgets_screen1 # Slicing removes unwanted widgets on Monitors 1,3
  672. def init_widgets_screen2():
  673. widgets_screen2 = init_widgets_list()
  674. return widgets_screen2 # Monitor 2 will display all widgets in widgets_list
  675. def init_screens():
  676. return [Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=1.0, size=30)),
  677. Screen(top=bar.Bar(widgets=init_widgets_screen2(), opacity=1.0, size=30)),
  678. Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=1.0, size=30))]
  679. # size=23 (was)
  680. @lazy.function
  681. def window_to_prev_group(qtile):
  682. if qtile.currentWindow is not None:
  683. i = qtile.groups.index(qtile.currentGroup)
  684. qtile.currentWindow.togroup(qtile.groups[i - 1].name)
  685. @lazy.function
  686. def window_to_next_group(qtile):
  687. if qtile.currentWindow is not None:
  688. i = qtile.groups.index(qtile.currentGroup)
  689. qtile.currentWindow.togroup(qtile.groups[i + 1].name)
  690. # TODO lazy.function
  691. @lazy.function
  692. def window_to_previous_screen(qtile):
  693. i = qtile.screens.index(qtile.current_screen)
  694. if i != 0:
  695. group = qtile.screens[i - 1].group.name
  696. qtile.current_window.togroup(group)
  697. # TODO lazy.function
  698. @lazy.function
  699. def window_to_next_screen(qtile):
  700. i = qtile.screens.index(qtile.current_screen)
  701. if i + 1 != len(qtile.screens):
  702. group = qtile.screens[i + 1].group.name
  703. qtile.current_window.togroup(group)
  704. # TODO lazy.function
  705. @lazy.function
  706. def switch_screens(qtile):
  707. i = qtile.screens.index(qtile.current_screen)
  708. group = qtile.screens[i - 1].group
  709. qtile.current_screen.set_group(group)
  710. # Drag floating layouts.
  711. mouse = [
  712. Drag([mod], "Button1", lazy.window.set_position_floating(),
  713. start=lazy.window.get_position()),
  714. Drag([mod], "Button3", lazy.window.set_size_floating(),
  715. start=lazy.window.get_size()),
  716. # Click([mod], "Button2", lazy.window.bring_to_front())
  717. ]
  718. ###############################################################################
  719. # New EXAMPLE from qtile 0.17.0 for float_rules[]!!!
  720. #
  721. # rules specified in `layout.Floating`'s `float_rules` are now evaluated with
  722. # AND-semantics instead of OR-semantics, i.e. if you specify 2 different
  723. # property rules, both have to match
  724. #
  725. # from libqtile.config import Match
  726. # Match(title=WM_NAME, wm_class=WM_CLASS, role=WM_WINDOW_ROLE)
  727. ###############################################################################
  728. floating_layout = layout.Floating(float_rules=[
  729. # Run the utility of `xprop` to see the wm class and name of an X client.
  730. # from libqtile.layout.floating class Floating
  731. # add (unpack *) default_float_rules
  732. *layout.Floating.default_float_rules,
  733. # Match(wm_type="utility"),
  734. # Match(wm_type="notification"),
  735. # Match(wm_type="toolbar"),
  736. # Match(wm_type="splash"),
  737. # Match(wm_type="dialog"),
  738. # Match(wm_class="file_progress"),
  739. # Match(wm_class="confirm"),
  740. # Match(wm_class="dialog"),
  741. # Match(wm_class="download"),
  742. # Match(wm_class="error"),
  743. # Match(wm_class="notification"),
  744. # Match(wm_class="splash"),
  745. # Match(wm_class="toolbar"),
  746. # Match(func=lambda c: c.has_fixed_size()),
  747. ####### My float rules #######
  748. # Match(title="Summary", wm_class="synaptic"),
  749. # Match(title="Applying Changes", wm_class="synaptic"),
  750. # Match(wm_class="Polkit-gnome-authentication-agent-1"),
  751. # Match(title="Properties for *", wm_class="dolphin"),
  752. # Match(title="Delete Permanently", wm_class="dolphin"), # Dolphin (delete dialog)
  753. # Match(title="Preference"), # Haroopad (md editor)
  754. Match(title="Execute File", wm_class="pcmanfm"),
  755. Match(title="Close Button Action", wm_class="tixati"), # Tixati
  756. Match(title="Confirm File Replacing", wm_class="pcmanfm"),
  757. Match(title="Terminator Preferences", wm_class="terminator"),
  758. Match(title="win0", wm_class="jetbrains-pycharm-ce"), # PyCharm
  759. Match(title="Welcome to PyCharm", wm_class="jetbrains-pycharm-ce"),
  760. Match(title="Update", wm_class="com-intellij-updater-Runner"), # PyCharm's updates
  761. Match(title="License Activation", wm_class="jetbrains-pycharm-ce"), # PyCharm
  762. Match(wm_class="nm-connection-editor"),
  763. Match(wm_class="megasync"),
  764. Match(wm_class="minitube"),
  765. Match(wm_class="CheckEmail"),
  766. Match(wm_class="GParted"),
  767. Match(wm_class="keepass2"),
  768. Match(wm_class="pinentry-gtk-2"),
  769. Match(wm_class="vlc"),
  770. Match(wm_class="smplayer"),
  771. Match(wm_class="deadbeef"),
  772. Match(wm_class="galculator"),
  773. # {"wmclass": "VirtualBox Manager"},
  774. Match(title="branchdialog"), # gitk
  775. Match(title="Open File"),
  776. Match(title="pinentry"), # GPG key password entry
  777. Match(wm_class="gnome-font-viewer"),
  778. Match(wm_class="fluxgui"),
  779. Match(wm_class="xfce4-power-manager-settings"),
  780. Match(wm_class="pavucontrol"),
  781. Match(wm_class="gdebi-gtk"),
  782. Match(wm_class="volumeicon"),
  783. Match(wm_class="gcolor3"),
  784. Match(wm_class="gvim"),
  785. Match(wm_class="qt5ct"),
  786. Match(wm_class="lxappearance"),
  787. Match(wm_class="confirmreset"), # gitk
  788. Match(wm_class="makebranch"), # gitk
  789. Match(wm_class="maketag"), # gitk
  790. Match(wm_class="ssh-askpass") # ssh-askpass
  791. ], border_focus="#009185") # #689d6a #98971a #d79921 #fea63c #009185
  792. # float_rules for qtile version < 0.17.0
  793. # floating_layout = layout.Floating(float_rules=[
  794. # # Run the utility of `xprop` to see the wm class and name of an X client.
  795. # {"wname": "synaptic"}, # Synaptic (Preinstall dialog)
  796. # {"wname": "Summary"}, # Synaptic (Summary dialog)
  797. # {"wmclass": "Polkit-gnome-authentication-agent-1"}, # Polkit-gnome-authentication-agent-1
  798. # {"wname": "Properties for *"}, # Dolphin (properties dialog)
  799. # {"wname": "Delete Permanently"}, # Dolphin (delete dialog)
  800. # {"wname": "Preference"}, # Haroopad (md editor)
  801. # {"wname": "Terminator Preferences"},
  802. # {"wname": "Close Button Action"}, # Tixati
  803. # {"wmclass": "com-intellij-updater-Runner"},
  804. # {"wmclass": "minitube"},
  805. # {"wmclass": "CheckEmail"},
  806. # {"wmclass": "GParted"},
  807. # {"wmclass": "keepass2"},
  808. # {"wmclass": "vlc"},
  809. # {"wmclass": "smplayer"},
  810. # {"wmclass": "deadbeef"},
  811. # {"wmclass": "galculator"},
  812. # # {"wmclass": "VirtualBox Manager"},
  813. # {"wname": "win0"}, # PyCharm
  814. # {"wmclass": "gnome-font-viewer"},
  815. # {"wmclass": "fluxgui"},
  816. # {"wmclass": "xfce4-power-manager-settings"},
  817. # {"wmclass": "pavucontrol"},
  818. # {"wmclass": "gdebi-gtk"},
  819. # {"wmclass": "volumeicon"},
  820. # {"wmclass": "gcolor3"},
  821. # {"wmclass": "gvim"},
  822. # {"wmclass": "qt5ct"},
  823. # {"wmclass": "lxappearance"},
  824. # {"wmclass": "confirm"},
  825. # {"wmclass": "dialog"},
  826. # {"wmclass": "download"},
  827. # {"wmclass": "error"},
  828. # {"wmclass": "file_progress"},
  829. # {"wmclass": "notification"},
  830. # {"wmclass": "splash"},
  831. # {"wmclass": "toolbar"},
  832. # {"wmclass": "confirmreset"}, # gitk
  833. # {"wmclass": "makebranch"}, # gitk
  834. # {"wmclass": "maketag"}, # gitk
  835. # {"wname": "branchdialog"}, # gitk
  836. # {'wname': 'Open File'},
  837. # {"wname": "pinentry"}, # GPG key password entry
  838. # {"wmclass": "ssh-askpass"}, # ssh-askpass
  839. # ])
  840. dgroups_key_binder = None
  841. dgroups_app_rules = [] # type: List
  842. main = None # WARNING: this is deprecated and will be removed soon
  843. follow_mouse_focus = True
  844. cursor_warp = False
  845. bring_front_click = False
  846. # bring_front_click = "floating_only"
  847. auto_fullscreen = True
  848. focus_on_window_activation = "focus"
  849. # focus_on_window_activation = "urgent"
  850. # focus_on_window_activation = "smart"
  851. # focus_on_window_activation = "never"
  852. # Autostart!!!
  853. @hook.subscribe.startup_once
  854. def start_once():
  855. subprocess.call([home + "/.config/qtile/scripts/autostart.sh"])
  856. # Does what I wanted perfectly!!!
  857. # @hook.subscribe.client_mouse_enter
  858. @hook.subscribe.client_focus
  859. @hook.subscribe.client_new
  860. def focus_new_floating_window(window):
  861. """ Bring a new floating window to the front. """
  862. # subprocess.check_output(["notify-send", "-i", "dialog-information", "{}".format(window.name)])
  863. if window.floating:
  864. window.cmd_bring_to_front()
  865. # TODO: show amount of opened windows (DONE!!!)
  866. # @hook.subscribe.client_new
  867. # def increase_opened_windows_counter(window):
  868. # """ Increase counter of opened windows. """
  869. # global opened_windows_counter
  870. # opened_windows_counter += 1
  871. # subprocess.check_output(["notify-send", "-i", "dialog-information", "{}\nOpened windows: {}".format(window.name, opened_windows_counter)])
  872. #
  873. #
  874. # @hook.subscribe.client_killed
  875. # def decrease_opened_windows_counter(window):
  876. # """ Decrease counter of opened windows. """
  877. # global opened_windows_counter
  878. # opened_windows_counter -= 1
  879. # subprocess.check_output(["notify-send", "-i", "dialog-information", "{}\nOpened windows: {}".format(window.name, opened_windows_counter)])
  880. # TODO: delete later if these below two functions don't need any more!!!
  881. # @lazy.function
  882. # def float_to_front(qtile):
  883. # """
  884. # Bring all floating windows of the group to front
  885. # """
  886. # global floating_windows
  887. # floating_windows = []
  888. # for window in qtile.currentGroup.windows:
  889. # if window.floating:
  890. # window.cmd_bring_to_front()
  891. # floating_windows.append(window)
  892. # floating_windows[-1].cmd_focus()
  893. # @hook.subscribe.client_new
  894. # def floating_dialogs(window):
  895. # dialog = window.window.get_wm_type() == "dialog"
  896. # transient = window.window.get_wm_transient_for()
  897. # if dialog or transient:
  898. # window.floating = True
  899. # XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
  900. # string besides java UI toolkits; you can see several discussions on the
  901. # mailing lists, GitHub issues, and other WM documentation that suggest setting
  902. # this string if your java app doesn't work correctly. We may as well just lie
  903. # and say that we're a working one by default.
  904. #
  905. # We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
  906. # java that happens to be on java's whitelist.
  907. wmname = "LG3D"
  908. if __name__ in ["config", "__main__"]:
  909. screens = init_screens()
  910. widgets_list = init_widgets_list()
  911. widgets_screen1 = init_widgets_screen1()
  912. widgets_screen2 = init_widgets_screen2()