sfwbar.config 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. scanner {
  2. # Extract memory usage information
  3. file("/proc/meminfo") {
  4. MemTotal = RegEx("^MemTotal:[\t ]*([0-9]+)[\t ]")
  5. MemAvailable = RegEx("^MemAvailable:[\t ]*([0-9]+)[\t ]")
  6. MemCache = RegEx( "^Cached:[\t ]*([0-9]+)[\t ]")
  7. MemBuff = Regex("^Buffers:[\t ]*([0-9]+)[\t ]")
  8. }
  9. # Add up total and used swap capacity across all partitions
  10. file("/proc/swaps") {
  11. SwapTotal = RegEx("[\t ]([0-9]+)",Sum)
  12. SwapUsed = RegEx("[\t ][0-9]+[\t ]([0-9]+)",Sum)
  13. }
  14. # Add up CPU utilization stats across all CPUs
  15. file("/proc/stat") {
  16. CpuUser = RegEx("^cpu [\t ]*([0-9]+)",Sum)
  17. CpuNice = RegEx("^cpu [\t ]*[0-9]+ ([0-9]+)",Sum)
  18. CpuSystem = RegEx("^cpu [\t ]*[0-9]+ [0-9]+ ([0-9]+)",Sum)
  19. CpuIdle = RegEx("^cpu [\t ]*[0-9]+ [0-9]+ [0-9]+ ([0-9]+)",Sum)
  20. }
  21. file("/sys/class/hwmon/hwmon7/temp1_input") {
  22. CPUTemp = Grab()
  23. }
  24. file("/sys/class/power_supply/BAT0/charge_full") {
  25. BatteryTotal = Grab(Sum)
  26. }
  27. file("/sys/class/power_supply/BAT0/charge_now") {
  28. BatteryLeft = Grab(Sum)
  29. }
  30. file("/sys/class/backlight/*/actual_brightness") {
  31. BacklightActual = Grab(Sum)
  32. }
  33. file("/sys/class/backlight/*/max_brightness") {
  34. BacklightMax = Grab(Sum)
  35. }
  36. file("/sys/class/bluetooth/*/rfkill*/state") {
  37. BluetoothState = Grab(Sum)
  38. }
  39. file("/proc/net/dev") {
  40. NetDev = RegEx("^[\t ]*(.*(?<!lo)):",First)
  41. }
  42. file("/proc/net/wireless") {
  43. WifiInterface = RegEx("^(.*):",First)
  44. WifiSignal = RegEx(":[\t ]*-?[0-9]+\.?[\t ]*-?[0-9]+\.?[\t ]*(-?[-0-9]+)",First)
  45. }
  46. file("/sys/class/net/*/carrier_*_count") {
  47. NetCount = Grab(Sum)
  48. }
  49. exec("iw dev;ip addr") {
  50. WifiSsid = RegEx("ssid (.*)$")
  51. NetIp = RegEx("inet ([0-9\./]*(?<!127.0.0.1/8)) ",First)
  52. }
  53. }
  54. define CpuUsage = (CpuUser-CpuUser.pval)/(CpuUser+CpuNice+CpuSystem+CpuIdle-
  55. CpuUser.pval-CpuNice.pval-CpuSystem.pval-CpuIdle.pval)*100
  56. define Volume = Val(If(PaCtlSink.count=0 & Cached(PaVolume.count)>0,
  57. Cached(PaVolume),PaVolume))
  58. define Mute = If(PaCtlSink.count=0 & Cached(PaMute.count)>0,
  59. Cached($PaMute),$PaMute)
  60. define WifiQuality = (100 - (-20 - WifiSignal) * 77/65)
  61. # Window Placer
  62. placer {
  63. xorigin = 5 # place the first window at X% from the left
  64. yorigin = 5 # place the first window at X% from the top
  65. xstep = 5 # step by X% of desktop horizontally
  66. ystep = 5 # step by X% of desktop vertically
  67. children = true
  68. }
  69. # Task Switcher
  70. switcher {
  71. interval = 700
  72. icons = true
  73. labels = false
  74. cols = 5
  75. }
  76. menu("winops") {
  77. item("focus", Focus );
  78. item("close", Close );
  79. item("minimize", [!Maximized] Minimize );
  80. item("unminimize", UnMinimize );
  81. item("maximize", Maximize );
  82. item("unmaximize", UnMaximize );
  83. }
  84. function("ToggleNet") {
  85. [UserState] UserState "off"
  86. [UserState] SetValue If($WifiInterface="",If($NetDev="","Disconnected",
  87. $NetDev + ": " + If(Cached(NetCount) = NetCount,Cached($NetIp), $NetIp)),
  88. $NetDev + ": " + If(Cached(NetCount) = NetCount,Cached($NetIp), $NetIp))
  89. [!UserState] UserState "on"
  90. [!UserState] SetValue If($WifiInterface="",If($NetDev="","Disconnected",
  91. $NetDev + ": " +
  92. If(Cached(NetCount) = NetCount,Cached($NetIp), $NetIp) + " "),
  93. If(Cached(NetCount) = NetCount,Cached($WifiSsid), $WifiSsid) +
  94. " (" + Str(WifiQuality,0) + "%) ")
  95. }
  96. function("ToggleInhibitor") {
  97. [!IdleInhibit] IdleInhibit "on"
  98. [!IdleInhibit] SetStyle "idle_inhibitor_activated"
  99. [!IdleInhibit] SetValue ""
  100. [!IdleInhibit] SetTooltip "activated"
  101. [IdleInhibit] IdleInhibit "off"
  102. [IdleInhibit] SetStyle "idle_inhibitor"
  103. [IdleInhibit] SetValue ""
  104. [IdleInhibit] SetTooltip "deactivated"
  105. }
  106. function("RecordCmd") {
  107. Exec ".config/waybar/wf-rec.py --click"
  108. }
  109. function("ToggleRecorder") {
  110. [UserState] UserState "off"
  111. [UserState] Function "RecordCmd"
  112. [UserState] SetTooltip "not recording"
  113. [UserState] SetValue ""
  114. [!UserState] UserState "on"
  115. [!UserState] SetTooltip "recording"
  116. [!UserState] Function "RecordCmd"
  117. [!UserState] SetValue "R"
  118. }
  119. #function("SfwbarInit") {
  120. # SetLayer "bottom"
  121. #}
  122. # Panel layout
  123. layout {
  124. button {
  125. #value = "open-menu-symbolic"
  126. value = "icons/milis-logo.svg"
  127. style = "startmenu"
  128. action = exec "nwg-drawer"
  129. tooltip = "Menu"
  130. }
  131. include("showdesktop.widget")
  132. pager {
  133. style = "pager"
  134. rows = 1
  135. preview = true
  136. numeric = true
  137. }
  138. taskbar {
  139. rows = 1
  140. css = "* { -GtkWidget-hexpand: true; }" # take up empty space, set icon size
  141. icons = true # display icons
  142. labels = true # display titles
  143. action[3] = Menu "winops"
  144. }
  145. label {
  146. style = "panel_item"
  147. value = ''
  148. action[1] = Exec ".config/swappy/area.sh"
  149. }
  150. label {
  151. style = "panel_item"
  152. interval = 6000
  153. action = Function "ToggleNet"
  154. action[0] = Function "ToggleNet"
  155. action[1] = Exec "connman-gtk"
  156. }
  157. label {
  158. style = "panel_item"
  159. interval = 500
  160. value = If(BluetoothState = 1," ","")
  161. }
  162. #label {
  163. # style = "panel_item"
  164. # interval = 10000
  165. # value = Str(CpuUsage,0) + '% '
  166. #}
  167. #label {
  168. # style = "panel_item"
  169. # interval = 30000
  170. # value = Str((MemTotal-MemAvailable)/MemTotal*100,0) + '% '
  171. #}
  172. label {
  173. style = "panel_item"
  174. interval = 10000
  175. value = Str(CPUTemp/1000,0) + '°C ' +
  176. if(CpuTemp/1000 < 20, "",
  177. if(CpuTemp/1000 < 40, "", ""))
  178. }
  179. label {
  180. style = "panel_item"
  181. interval = 500
  182. value = Str(BacklightActual/BacklightMax*100,0) +
  183. '% '
  184. action[4] = exec "light -A 5;light -O"
  185. action[5] = exec "light -U 5;light -O"
  186. }
  187. label {
  188. style = "panel_item"
  189. interval = 60000
  190. value = Str(BatteryLeft/BatteryTotal*100,0) + '% ' +
  191. if(BatteryLeft/BatteryTotal < .2,"",
  192. if(BatteryLeft/BatteryTotal < .4,"",
  193. if(BatteryLeft/BatteryTotal < .6,"",
  194. if(BatteryLeft/BatteryTotal < .8,"",""))))
  195. }
  196. include("weather.widget")
  197. include("pulse.widget")
  198. label {
  199. style = "panel_item"
  200. value = Time("%d %b %a %H:%M")
  201. action[1] = exec "gsimplecal"
  202. }
  203. tray {
  204. rows = 1
  205. }
  206. label {
  207. css = "* { padding-bottom: 1mm; }"
  208. value = ""
  209. action[1] = exec "nwgbar -b 272822"
  210. }
  211. }
  212. #CSS
  213. * {
  214. /* `otf-font-awesome` is required to be installed for icons */
  215. font-family: Roboto, Helvetica, Arial, sans-serif;
  216. font-size: 13px;
  217. }
  218. window#sfwbar {
  219. -GtkWidget-direction: bottom;
  220. background-color: rgba(43, 48, 59, 0.5);
  221. /* border-bottom: 3px solid rgba(100, 114, 125, 0.5); */
  222. color: #ffffff;
  223. transition-property: background-color;
  224. transition-duration: .5s;
  225. }
  226. button#taskbar_normal grid {
  227. -GtkWidget-hexpand: false;
  228. padding-right: 0px;
  229. margin-right: 0px;
  230. }
  231. button#taskbar_normal image, button#taskbar_active image, button#taskbar_normal:hover image {
  232. min-width: 0.4cm;
  233. min-height: 0.4cm;
  234. }
  235. button#taskbar_normal label, button#taskbar_active label, button#taskbar_normal:hover label {
  236. -GtkWidget-vexpand: true;
  237. -GtkWidget-hexpand: false;
  238. padding-left: 0.75mm;
  239. padding-top: 0px;
  240. padding-bottom: 0px;
  241. font: 0.4cm Sans;
  242. }
  243. button#taskbar_normal , button#taskbar_active , button#taskbar_normal:hover {
  244. padding-left: 0.75mm;
  245. padding-top: 0.5mm;
  246. padding-bottom: 0.5mm;
  247. background-image: none;
  248. /* border-radius: 3; */
  249. border: none;
  250. border-image: none;
  251. -GtkWidget-hexpand: false;
  252. background-image: none; background-color: transparent;
  253. }
  254. button#taskbar_active {
  255. background-color: #bbddff;
  256. color: #000000;
  257. }
  258. button#taskbar_normal:hover {
  259. background-color: #ffffff;
  260. }
  261. eventbox { background-image: none; background-color: transparent; }
  262. button#pager_normal *, button#pager_visible *, button#pager_focused * {
  263. padding: 0px;
  264. color: #ffffff;
  265. }
  266. button#pager_normal, button#pager_visible, button#pager_focused {
  267. padding: 0 5px;
  268. background-color: transparent;
  269. background-image: none;
  270. color: #ffffff;
  271. /* Use box-shadow instead of border so the text isn't offset */
  272. box-shadow: inset 0 -3px transparent;
  273. /* Avoid rounded borders under each workspace name */
  274. border: none;
  275. border-radius: 0;
  276. min-height: 30px;
  277. }
  278. button#pager_focused {
  279. background-color: #64727D;
  280. box-shadow: inset 0 -3px #ffffff;
  281. }
  282. #mode {
  283. background-color: #64727D;
  284. border-bottom: 3px solid #ffffff;
  285. }
  286. #panel_item,
  287. #pulseaudio,
  288. #pulseaudio_muted,
  289. #tray,
  290. #mode {
  291. padding: 0 8px;
  292. color: #ffffff;
  293. margin-right: 1px;
  294. }
  295. #window,
  296. #workspaces {
  297. margin: 0 4px;
  298. }
  299. #panel_item {
  300. background-image: none; background-color: transparent; border: none;
  301. }
  302. @keyframes blink {
  303. to {
  304. background-color: #ffffff;
  305. color: #000000;
  306. }
  307. }
  308. #battery.critical:not(.charging) {
  309. background-color: #f53c3c;
  310. color: #ffffff;
  311. animation-name: blink;
  312. animation-duration: 0.5s;
  313. animation-timing-function: linear;
  314. animation-iteration-count: infinite;
  315. animation-direction: alternate;
  316. }
  317. label:focus {
  318. background-color: #000000;
  319. }
  320. #network_disconnected {
  321. background-color: #f53c3c;
  322. }
  323. #pulseaudio {
  324. background-image: none; background-color: transparent;
  325. }
  326. #pulseaudio_muted {
  327. background-color: #90b1b1;
  328. color: #2a5c45;
  329. }
  330. image#tray_active, image#tray_passive, image#tray_attention {
  331. background-image: none; background-color: transparent;
  332. padding: 7px 5px;
  333. }
  334. image#tray_passive {
  335. -gtk-icon-effect: dim;
  336. }
  337. image#tray_attention {
  338. -gtk-icon-effect: highlight;
  339. background-image: none; background-color: transparent;
  340. }
  341. button#tray_active,
  342. button#tray_passive,
  343. button#tray_attention {
  344. background-image: none;background-color: transparent;
  345. border: 0px;
  346. padding: 0px;
  347. margin: 0px;
  348. border-image: none;
  349. border-radius: 0px;
  350. outline-style: none;
  351. box-shadow: none;
  352. }
  353. button#tray_active image,
  354. button#tray_passive image,
  355. button#tray_attention image {
  356. min-width: 5mm;
  357. min-height: 5mm;
  358. padding: 4px;
  359. }
  360. #language {
  361. background: #00b093;
  362. color: #740864;
  363. padding: 0 5px;
  364. margin: 0 5px;
  365. min-width: 16px;
  366. }
  367. #keyboard-state {
  368. background: #97e1ad;
  369. padding: 0 0px;
  370. margin: 0 5px;
  371. min-width: 16px;
  372. }
  373. #keyboard-state > label {
  374. padding: 0 5px;
  375. }
  376. #keyboard-state > label.locked {
  377. background: rgba(0, 0, 0, 0.2);
  378. }
  379. #hidden {
  380. -GtkWidget-visible: false;
  381. }
  382. button#pager_preview {
  383. background-image: none;
  384. border-radius: 0;
  385. border-image: none;
  386. border-color: #000000;
  387. border-width: 0.25mm;
  388. color: #777777;
  389. min-width: 5cm;
  390. min-height: 2.8125cm;
  391. }
  392. grid#switcher_active *, grid#switcher_active, grid#switcher_active * * {
  393. min-width: 1.25cm;
  394. min-height: 1.25cm;
  395. border-image: none;
  396. padding: 1.25mm;
  397. background-color: #2980b9;
  398. border-radius: 1.25mm;
  399. }
  400. grid#switcher_normal *, grid#switcher_normal, grid#switcher_normal * * {
  401. min-width: 1.25cm;
  402. min-height: 1.25cm;
  403. border-image: none;
  404. padding: 1.25mm;
  405. }
  406. window#switcher {
  407. border-style: solid;
  408. border-width: 0.25mm;
  409. border-color: #000000;
  410. border-radius: 1.25mm;
  411. padding: 1.25mm;
  412. -GtkWidget-hexpand: true;
  413. background-color: rgba(43, 48, 59, 0.5);
  414. border: 3px solid rgba(100, 114, 125, 0.5);
  415. color: #ffffff;
  416. transition-property: background-color;
  417. transition-duration: .5s;
  418. }
  419. grid#switcher {
  420. border-radius: 1.25mm;
  421. padding: 1.25mm;
  422. }