qutewal.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. import json
  2. import os
  3. qutewal_dynamic_loading = False
  4. home = os.getenv('HOME')
  5. colors_relative = '.cache/wal/colors.json'
  6. daemon_relative = '.config/qutebrowser/qutewald.py'
  7. colors_absolute = os.path.join(home, colors_relative)
  8. daemon_absolute = os.path.join(home, daemon_relative)
  9. if os.path.isfile(colors_absolute):
  10. with open(colors_absolute) as colorfile:
  11. colors = json.load(colorfile)
  12. cursor = colors['special']['cursor']
  13. background = colors['special']['background']
  14. foreground = colors['special']['foreground']
  15. black = colors['colors']['color0']
  16. white = colors['colors']['color7']
  17. gray = colors['colors']['color8']
  18. red = colors['colors']['color1']
  19. green = colors['colors']['color2']
  20. yellow = colors['colors']['color3']
  21. blue = colors['colors']['color4']
  22. magenta = colors['colors']['color5']
  23. cyan = colors['colors']['color6']
  24. # Background color of the completion widget category headers.
  25. # Type: QssColor
  26. c.colors.completion.category.bg = background
  27. # Bottom border color of the completion widget category headers.
  28. # Type: QssColor
  29. c.colors.completion.category.border.bottom = background
  30. # Top border color of the completion widget category headers.
  31. # Type: QssColor
  32. c.colors.completion.category.border.top = background
  33. # Foreground color of completion widget category headers.
  34. # Type: QtColor
  35. c.colors.completion.category.fg = foreground
  36. # Background color of the completion widget for even rows.
  37. # Type: QssColor
  38. c.colors.completion.even.bg = background
  39. # Background color of the completion widget for odd rows.
  40. # Type: QssColor
  41. c.colors.completion.odd.bg = background
  42. # Text color of the completion widget.
  43. # Type: QtColor
  44. c.colors.completion.fg = foreground
  45. # Background color of the selected completion item.
  46. # Type: QssColor
  47. c.colors.completion.item.selected.bg = gray
  48. # Bottom border color of the selected completion item.
  49. # Type: QssColor
  50. c.colors.completion.item.selected.border.bottom = background
  51. # Top border color of the completion widget category headers.
  52. # Type: QssColor
  53. c.colors.completion.item.selected.border.top = background
  54. # Foreground color of the selected completion item.
  55. # Type: QtColor
  56. c.colors.completion.item.selected.fg = foreground
  57. # Foreground color of the matched text in the completion.
  58. # Type: QssColor
  59. c.colors.completion.match.fg = yellow
  60. # Color of the scrollbar in completion view
  61. # Type: QssColor
  62. c.colors.completion.scrollbar.bg = background
  63. # Color of the scrollbar handle in completion view.
  64. # Type: QssColor
  65. c.colors.completion.scrollbar.fg = gray
  66. # Background color for the download bar.
  67. # Type: QssColor
  68. c.colors.downloads.bar.bg = background
  69. # Background color for downloads with errors.
  70. # Type: QtColor
  71. c.colors.downloads.error.bg = red
  72. # Foreground color for downloads with errors.
  73. # Type: QtColor
  74. c.colors.downloads.error.fg = foreground
  75. # Color gradient stop for download backgrounds.
  76. # Type: QtColor
  77. c.colors.downloads.stop.bg = cyan
  78. # Color gradient interpolation system for download backgrounds.
  79. # Type: ColorSystem
  80. # Valid values:
  81. # - rgb: Interpolate in the RGB color system.
  82. # - hsv: Interpolate in the HSV color system.
  83. # - hsl: Interpolate in the HSL color system.
  84. # - none: Don't show a gradient.
  85. c.colors.downloads.system.bg = 'none'
  86. # Background color for hints. Note that you can use a `rgba(...)` value
  87. # for transparency.
  88. # Type: QssColor
  89. c.colors.hints.bg = yellow
  90. # Font color for hints.
  91. # Type: QssColor
  92. c.colors.hints.fg = background
  93. # Font color for the matched part of hints.
  94. # Type: QssColor
  95. c.colors.hints.match.fg = blue
  96. # Background color of the keyhint widget.
  97. # Type: QssColor
  98. c.colors.keyhint.bg = background
  99. # Text color for the keyhint widget.
  100. # Type: QssColor
  101. c.colors.keyhint.fg = foreground
  102. # Highlight color for keys to complete the current keychain.
  103. # Type: QssColor
  104. c.colors.keyhint.suffix.fg = yellow
  105. # Background color of an error message.
  106. # Type: QssColor
  107. c.colors.messages.error.bg = red
  108. # Border color of an error message.
  109. # Type: QssColor
  110. c.colors.messages.error.border = red
  111. # Foreground color of an error message.
  112. # Type: QssColor
  113. c.colors.messages.error.fg = foreground
  114. # Background color of an info message.
  115. # Type: QssColor
  116. c.colors.messages.info.bg = blue
  117. # Border color of an info message.
  118. # Type: QssColor
  119. c.colors.messages.info.border = blue
  120. # Foreground color an info message.
  121. # Type: QssColor
  122. c.colors.messages.info.fg = foreground
  123. # Background color of a warning message.
  124. # Type: QssColor
  125. c.colors.messages.warning.bg = red
  126. # Border color of a warning message.
  127. # Type: QssColor
  128. c.colors.messages.warning.border = red
  129. # Foreground color a warning message.
  130. # Type: QssColor
  131. c.colors.messages.warning.fg = foreground
  132. # Background color for prompts.
  133. # Type: QssColor
  134. c.colors.prompts.bg = background
  135. # # Border used around UI elements in prompts.
  136. # # Type: String
  137. c.colors.prompts.border = '1px solid ' + background
  138. # Foreground color for prompts.
  139. # Type: QssColor
  140. c.colors.prompts.fg = foreground
  141. # Background color for the selected item in filename prompts.
  142. # Type: QssColor
  143. c.colors.prompts.selected.bg = magenta
  144. # Background color of the statusbar in caret mode.
  145. # Type: QssColor
  146. c.colors.statusbar.caret.bg = cyan
  147. # Foreground color of the statusbar in caret mode.
  148. # Type: QssColor
  149. c.colors.statusbar.caret.fg = cursor
  150. # Background color of the statusbar in caret mode with a selection.
  151. # Type: QssColor
  152. c.colors.statusbar.caret.selection.bg = cyan
  153. # Foreground color of the statusbar in caret mode with a selection.
  154. # Type: QssColor
  155. c.colors.statusbar.caret.selection.fg = foreground
  156. # Background color of the statusbar in command mode.
  157. # Type: QssColor
  158. c.colors.statusbar.command.bg = background
  159. # Foreground color of the statusbar in command mode.
  160. # Type: QssColor
  161. c.colors.statusbar.command.fg = foreground
  162. # Background color of the statusbar in private browsing + command mode.
  163. # Type: QssColor
  164. c.colors.statusbar.command.private.bg = background
  165. # Foreground color of the statusbar in private browsing + command mode.
  166. # Type: QssColor
  167. c.colors.statusbar.command.private.fg = foreground
  168. # Background color of the statusbar in insert mode.
  169. # Type: QssColor
  170. c.colors.statusbar.insert.bg = green
  171. # Foreground color of the statusbar in insert mode.
  172. # Type: QssColor
  173. c.colors.statusbar.insert.fg = background
  174. # Background color of the statusbar.
  175. # Type: QssColor
  176. c.colors.statusbar.normal.bg = background
  177. # Foreground color of the statusbar.
  178. # Type: QssColor
  179. c.colors.statusbar.normal.fg = foreground
  180. # Background color of the statusbar in passthrough mode.
  181. # Type: QssColor
  182. c.colors.statusbar.passthrough.bg = blue
  183. # Foreground color of the statusbar in passthrough mode.
  184. # Type: QssColor
  185. c.colors.statusbar.passthrough.fg = foreground
  186. # Background color of the statusbar in private browsing mode.
  187. # Type: QssColor
  188. c.colors.statusbar.private.bg = background
  189. # Foreground color of the statusbar in private browsing mode.
  190. # Type: QssColor
  191. c.colors.statusbar.private.fg = foreground
  192. # Background color of the progress bar.
  193. # Type: QssColor
  194. c.colors.statusbar.progress.bg = foreground
  195. # Foreground color of the URL in the statusbar on error.
  196. # Type: QssColor
  197. c.colors.statusbar.url.error.fg = red
  198. # Default foreground color of the URL in the statusbar.
  199. # Type: QssColor
  200. c.colors.statusbar.url.fg = foreground
  201. # Foreground color of the URL in the statusbar for hovered links.
  202. # Type: QssColor
  203. c.colors.statusbar.url.hover.fg = blue
  204. # Foreground color of the URL in the statusbar on successful load
  205. # (http).
  206. # Type: QssColor
  207. c.colors.statusbar.url.success.http.fg = foreground
  208. # Foreground color of the URL in the statusbar on successful load
  209. # (https).
  210. # Type: QssColor
  211. c.colors.statusbar.url.success.https.fg = gray
  212. # Foreground color of the URL in the statusbar when there's a warning.
  213. # Type: QssColor
  214. c.colors.statusbar.url.warn.fg = red
  215. # Background color of the tab bar.
  216. # Type: QtColor
  217. c.colors.tabs.bar.bg = background
  218. # Background color of unselected even tabs.
  219. # Type: QtColor
  220. c.colors.tabs.even.bg = background
  221. # Foreground color of unselected even tabs.
  222. # Type: QtColor
  223. c.colors.tabs.even.fg = foreground
  224. # Color for the tab indicator on errors.
  225. # Type: QtColor
  226. c.colors.tabs.indicator.error = red
  227. # Color gradient start for the tab indicator.
  228. # Type: QtColor
  229. # c.colors.tabs.indicator.start = magenta
  230. # Color gradient end for the tab indicator.
  231. # Type: QtColor
  232. # c.colors.tabs.indicator.stop = red
  233. # Color gradient interpolation system for the tab indicator.
  234. # Type: ColorSystem
  235. # Valid values:
  236. # - rgb: Interpolate in the RGB color system.
  237. # - hsv: Interpolate in the HSV color system.
  238. # - hsl: Interpolate in the HSL color system.
  239. # - none: Don't show a gradient.
  240. c.colors.tabs.indicator.system = 'none'
  241. # Background color of unselected odd tabs.
  242. # Type: QtColor
  243. c.colors.tabs.odd.bg = background
  244. # Foreground color of unselected odd tabs.
  245. # Type: QtColor
  246. c.colors.tabs.odd.fg = foreground
  247. # Background color of selected even tabs.
  248. # Type: QtColor
  249. c.colors.tabs.selected.even.bg = blue
  250. # Foreground color of selected even tabs.
  251. # Type: QtColor
  252. c.colors.tabs.selected.even.fg = foreground
  253. # Background color of selected odd tabs.
  254. # Type: QtColor
  255. c.colors.tabs.selected.odd.bg = blue
  256. # Foreground color of selected odd tabs.
  257. # Type: QtColor
  258. c.colors.tabs.selected.odd.fg = foreground
  259. # Background color for webpages if unset (or empty to use the theme's
  260. # color)
  261. # Type: QtColor
  262. c.colors.webpage.bg = foreground
  263. if qutewal_dynamic_loading or bool(os.getenv('QUTEWAL_DYNAMIC_LOADING')):
  264. import signal
  265. import subprocess
  266. import prctl
  267. # start iqutefy to refresh colors on the fly
  268. qutewald = subprocess.Popen(
  269. [daemon_absolute, colors_absolute],
  270. preexec_fn=lambda: prctl.set_pdeathsig(signal.SIGTERM))