-
Notifications
You must be signed in to change notification settings - Fork 0
/
rc.yue
992 lines (819 loc) · 21.9 KB
/
rc.yue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
--- Clear the console. Makes it cleaner for debugging.
os.execute("clear")
macro LUA = (code) ->
{
:code
type: "lua"
}
--$LUA [==[
--if something then
-- print("YES")
--end
--]==]
macro FENNEL = (var, input, is_local="false") ->
if not input
input = var
var = "_"
path = os.tmpname()
file = assert(io.open(path, "w"))
code = ""
declaration = if is_local == "false"
""
else
"local "
try
file::write(input)
command = assert(io.popen("fennel --compile #{path}", "r"))
stdout = command
::read("*all")
::gsub("^%s*", "")
::gsub("%s*$", "")
command::close()
code = "#{declaration}#{var} = (function()\n\t#{stdout::gsub('\n', '\n\t')}\nend)()"
file::close()
catch err
file::close()
print("COMPILE ERROR: #{err}")
{
:code
type: "lua"
}
--$FENNEL [==[
--(print "Hello, world!")
--
--(fn myfunc [foo bar])
--]==]
require = require
xpcall = xpcall
--- Turn globals into locals for performance
print = print
pcall = pcall
os = os
io = io
table = table
string = string
tostring = tostring
tonumber = tonumber
rawget = rawget
rawset = rawset
unpack = unpack or table.unpack
getmetatable = getmetatable
setmetatable = setmetatable
--- Same as above, but for awesome built-ins
awesome = awesome
screen = screen
client = client
mouse = mouse
--- If LuaRocks is installed, make sure that packages installed through it are
--- found (e.g. lgi). If LuaRocks is not installed, do nothing.
pcall(require, "luarocks.loader")
import "yue"
import "lgi"
import Gio, GLib from lgi
--- Import awesome standard libraries
import awful, gears, wibox, naughty, beautiful, menubar from require("awesome_std")
awful.hotkeys_popup = require("awful.hotkeys_popup")
do
cg = collectgarbage
cg("setpause", 110)
cg("setstepmul", 1000)
gears.timer {
timeout: 5
autostart: true
call_now: true
callback: () ->
cg("collect")
}
wibox.layout.overflow = require("overflow")
--- Enable hrtkeys help widget for VIM and other apps
--- when client with a matching name is opened:
require("awful.hotkeys_popup.keys")
--- {{{ Error handling
--- Check if awesome encountered an error during startup and fell back to
--- another config (This code will only ever execute for the fallback config)
naughty.connect_signal("request::display_error", (message, startup=false) ->
message = tostring(message)
if not message::match("traceback")
message = yue.traceback(message, 4)
naughty.notification {
urgency: "critical"
title: "An error occured during " .. (startup and "startup!" or "runtime!")
message: message
timeout: 0
}
)
do
_error = error
global error = (msg, ...) ->
naughty.emit_signal("request::display_error", msg)
_error(msg, ...)
--- }}}
--- {{{ Auto reload
--[[
awful.spawn.with_line_callback([=[bash -c '
inotifywait --event modify \
--include '"'"'.*\.lua'"'"' \
--recursive ./ \
--monitor \
--quiet \
2> /dev/null
']=], { stdout: (line) -> awesome.restart() })
--]]
--- }}}
--- {{{ App autostart
--- Picom, for transparency and other compositing effects.
--- Note: You should really be using the glx backend, which is OpenGL accelerated.
--- The reason xrender is used here is purely because Xephyr does not work
--- with glx at all, with the window just showing a "screenshot" of when picom
--- was started.
run_once = (command) ->
(stdout, stderr, reason, exit_code) <- awful.spawn.easy_async { "pgrep", "-f", "-U", os.getenv("USER"), command[1] }
if exit_code == 1
awful.spawn(command)
run_once { "picom", --[[ "--backend=xrender" ]] }
--- }}}
--- {{{ Variable definitions
--- Themes define colours, icons, font and wallpapers.
beautiful.init(gears.filesystem.get_configuration_dir() .. "themes/skyyysi/theme.lua")
import "slimeos"
import util from slimeos.lib
import Enum from slimeos.lib.collection
logblock = (msg) ->
with util.terminal
print()
.log.stroke()
print()
.log.block(msg, {
shadow: true
empty_shadow: false
foreground: .color.foreground.normal.black
background: .color.background.normal.blue
})
print()
logerror = (msg) ->
with util.terminal
.log.block("ERROR: #{msg}", {
shadow: true
empty_shadow: false
foreground: .color.foreground.normal.black
background: .color.background.normal.red
})
print()
try_or_log = (fn, ...) ->
success, output = xpcall(fn, debug.traceback, ...)
if not success
--logerror(output)
print(output)
with util.terminal
.log.block("Welcome to SlimeOS!", {
shadow: true
empty_shadow: false
foreground: .color.foreground.normal.black
background: .color.background.normal.blue
})
print()
.log.stroke()
print()
--- This is used later as the default terminal and editor to run.
terminal = os.getenv("TERMINAL") ?? "xterm"
editor = os.getenv("EDITOR") ?? "#{terminal} -e nano"
cli_editors = Enum {
"nano"
"micro"
}
if cli_editors[editor]
editor = "#{terminal} -e #{editor}"
menubar.utils.terminal = terminal
--- Default modkey.
--- Usually, Mod4 is the key with a logo between Control and Alt.
--- If you do not like this or do not have such a key,
--- I suggest you to remap Mod4 to another key using xmodmap or other tools.
--- However, you can use another modifier like Mod1, but it may interact with others.
modkey = "Mod4"
awful.spawn { "xrdb", "-merge", os.getenv("HOME") .. "/.Xresources" }
main_menu = slimeos.boxes.main_menu {
terminal: terminal
}
--- }}}
--[[
do
print()
util.terminal.log.stroke()
print()
import List, Map, Tuple from require("slimeos.lib.collection")
l, m, t = List({"foo", "bar", "biz", "baz"}), Map({ foo: "bar", biz: "baz"}), Tuple({"foo", "bar", "biz", "baz"})
print("List -> #{l}")
print("Map -> #{m}")
print("Tuple -> #{t}")
--]]
--[[
l[] = "lua"
m.yue = "lua"
t[] = "lua" -- Should crash!
print("List -> #{l}")
print("Map -> #{m}")
print("Tuple -> #{t}")
--]]
--- {{{ Tag layout
--- Table of layouts to cover with awful.layout.inc, order matters.
tag.connect_signal("request::default_layouts", () -> awful.layout.append_default_layouts {
awful.layout.suit.tile
awful.layout.suit.floating
--awful.layout.suit.floating
--awful.layout.suit.tile
--awful.layout.suit.tile.left
--awful.layout.suit.tile.bottom
--awful.layout.suit.tile.top
--awful.layout.suit.fair
--awful.layout.suit.fair.horizontal
--awful.layout.suit.spiral
--awful.layout.suit.spiral.dwindle
--awful.layout.suit.max
--awful.layout.suit.max.fullscreen
--awful.layout.suit.magnifier
--awful.layout.suit.corner.nw
})
--- }}}
awful.spawn.with_bash = (cmd) ->
awful.spawn("bash -c '" .. cmd::gsub([[']], [['"'"']]) .. "'")
awful.spawn.with_bash_silently = (cmd) ->
awful.spawn("bash -c '" .. cmd::gsub([[']], [['"'"']]) .. " &> /dev/null'")
--- {{{ Wallpaper
--[[
do
run_silently = (cmd) ->
awful.spawn.with_bash_silently(cmd)
screen.connect_signal("request::wallpaper", (s) ->
run_silently("nitrogen --restore")
)
--]]
--- }}}
--- {{{ Per-screen settings
--- Wallpapers
wallpapers = {
[1]: "/usr/share/backgrounds/gnome/blobs-d.svg"
[2]: "/usr/share/backgrounds/gnome/drool-d.svg"
}
screen.connect_signal("request::wallpaper", () =>
awful.wallpaper {
screen: @,
widget: {
{
horizontal_fit_policy: "fit"
vertical_fit_policy: "fit"
image: wallpapers[@index]
resize: true
widget: wibox.widget.imagebox
}
bg: "#350F2A"
widget: wibox.container.background
}
}
)
screen.connect_signal("request::desktop_decoration", (s) ->
--- Top panel
slimeos.bars.main {
screen: s
menu: main_menu
terminal: terminal
}
s.system_center::show()
util.after_timeout(0, (() -> s.system_center::hide()))
)
--- }}}
popup_launcher = slimeos.boxes.popup_launcher()
require("slimeos.settings.bindings") {
menu: main_menu
modkey: modkey
terminal: terminal
launcher_show_callback: () ->
popup_launcher::launcher_toggle()
}
require("slimeos.settings.rules")
require("slimeos.settings.titlebar")
--- Enable sloppy focus, so that focus follows mouse.
client.connect_signal("mouse::enter", (c) ->
c::activate {
context: "mouse_enter"
raise: false
}
)
parse_action = (app_info) ->
if not app_info
return {}
file = app_info::get_filename()
keyfile = GLib.KeyFile()
if not keyfile::load_from_file(file, {})
return {}
-- TODO: This appears to not be working half the time (the try-catch did not fix it)
actions = {}
try
for action in *app_info::list_actions()
action_entry = "Desktop Action #{action}"
action_icon = keyfile::get_string(action_entry, "Icon")
icon = if action_icon
gears.surface(action_icon)
else
nil
actions[action] = {
name: app_info::get_action_name(action)
icon: icon
launch: () -> app_info::launch_action(action)
}
catch err
util.notify("ERROR: #{err}\n#{yue.traceback()}", 0)
actions
---
client.connect_signal("manage", (c) ->
if not c.class
return
gio_search_results = Gio.DesktopAppInfo.search(c.class)[1]
if gio_search_results == nil
return
app = gio_search_results[1]
if app == nil
return
c.__gdesktop_app_info = Gio.DesktopAppInfo.new(app)
c.__gdesktop_name = c.__gdesktop_app_info::get_name()
c.__gdesktop_icon = util.lookup_gicon(c.__gdesktop_app_info::get_icon())
c.__gdesktop_actions = parse_action(c.__gdesktop_app_info)
--util.notify("client: '#{c.class}' -> #{select(2, next(c.__gdesktop_actions))}")
awesome.emit_signal("Gio.DesktopAppInfo::added_info_to", c)
)
--[[
do
--import "slimeos.lib.draggable"
import "slimeos.layouts.draggable"
my_box = wibox {
ontop: true
visible: true
width: util.scale(200)
height: util.scale(100)
}
awful.placement.top_left(my_box, {
honor_workarea: true
margins: {
top: util.scale(10)
}
})
util.apcall ->
my_box.widget = {
{
text: "Foo"
widget: wibox.widget.textbox
}
{
text: "Bar"
widget: wibox.widget.textbox
}
{
text: "Biz"
widget: wibox.widget.textbox
}
{
text: "Baz"
widget: wibox.widget.textbox
}
--layout: wibox.layout.manual
layout: draggable
}
<- util.after_timeout(2)
--draggable.connect_widget(my_box.widget)
--]]
picom_set = (window, property, value) ->
window = tostring(window)
if type(value) == "boolean"
value = if value
"1"
else
"0"
awful.spawn { "xprop", "-id", window, "-f", property, "32c", "-set", property, value }
update_client_shape = do
forced_rect_shape = false
client_border_width = beautiful.border_width or util.scale(1)
client_shape = beautiful.client_shape or (cr, w, h) ->
gears.shape.rounded_rect(cr, w, h, beautiful.corner_radius or util.scale(20))
rectangle = gears.shape.rectangle
set_picom_property = (window, enabled) ->
--enabled_str = enabled and "1" or "0"
--window_str = tostring(window)
picom_set(window, "_PICOM_ROUNDED_CORNERS", enabled)
picom_set(window, "_PICOM_SHADOWS", enabled)
--awful.spawn { "xprop", "-id", window_str, "-f", "_PICOM_ROUNDED_CORNERS", "32c", "-set", "_PICOM_ROUNDED_CORNERS", enabled_str }
--awful.spawn { "xprop", "-id", window_str, "-f", "_PICOM_SHADOWS", "32c", "-set", "_PICOM_SHADOWS", enabled_str }
(c) ->
window = c.window
if forced_rect_shape
c._old_border_width = c._old_border_width or client_border_width
c.border_width = client_border_width
c.shape = rectangle
set_picom_property(window, false)
return
if c.maximized or c.fullscreen
c._old_border_width = c._old_border_width or client_border_width
c.border_width = 0
c.shape = rectangle
set_picom_property(window, false)
else
c.border_width = c._old_border_width or client_border_width
if c.type == "normal"
c.shape = client_shape
set_picom_property(window, true)
awesome.connect_signal("beautiful::gaps_status_changed", () ->
forced_rect_shape = not beautiful.gaps_enabled
for c in *client.get()
update_client_shape(c)
)
for c in *client.get()
update_client_shape(c)
client.connect_signal("manage", update_client_shape)
client.connect_signal("property::fullscreen", update_client_shape)
client.connect_signal("property::maximized", update_client_shape)
tag_has_maxmimized_client = (t) ->
result = false
for _, c in t::clients()
if c.maximized or c.fullscreen
result = true
break
awesome.emit_signal("tag::has_maximized_client", result)
result
-- TODO: Make the panel and system center have rectengular corners if a client is maximized on the current tag
require("awesome-extrautils")()
if screen[2] != nil
rwdesktop = require("awesome-rwdesktop")()
global notify = util.notify
--notify(rwdesktop)
rwdesktop {
screen: screen[2]
}
--{{{ Experiments
do
import "slimeos.widgets.Button"
box = wibox {
width: 200
height: 100
visible: true
ontop: true
widget: {
{
font: "Source Sans Pro, Bold 22"
halign: "center"
valign: "center"
markup: "Restart"
widget: wibox.widget.textbox
}
on_click: () -> awesome.restart()
widget: Button
}
}
awful.placement.top_left(box, margins: 10, honor_workarea: true)
macro CIMPORT = (module) ->
modname = (module::match(".*%.(.*)") or module)
if module::match(".*/#{modname}")
module = module::gsub("/#{modname}$", "")
path = module::gsub("%.", "/")
"const #{modname::gsub('-', '_')} = do
old_path = package.cpath
package.cpath ..= " .. [[";#{gears.filesystem.get_configuration_dir()}/]] .. path .. [[.so"]] .. "
module = require(\"#{modname}\")
package.cpath = old_path
module
"
--[ [
try
import "slimeos.widgets.filter"
starting_surface = "/slimeos-yuescript/test.png" --[[do
import GdkPixbuf, cairo from require("lgi")
--$CIMPORT slimeos.widgets.c_filter
package.cpath ..= ";/home/simon/projects/awesome/slimeos-yuescript/slimeos/widgets/?.so"
const c_filter = require("c_filter")
pixbuf = GdkPixbuf.Pixbuf.new_from_file("/home/simon/projects/awesome/slimeos-yuescript/test.png")
blurred_pixbuf = GdkPixbuf.Pixbuf(c_filter.blur_pixbuf(pixbuf._native, 10))
print("pixbuf = #{pixbuf}\nblurred_pixbuf = #{blurred_pixbuf}")
surface = awesome.pixbuf_to_surface(blurred_pixbuf._native, gears.surface())
if cairo.Surface::is_type_of(surface)
surface
else
cairo.Surface(surface, true)
--]]
--[ [
--imagebox = wibox.widget {
-- image: starting_surface -- "/slimeos-yuescript/test.png"
-- widget: wibox.widget.imagebox
--}
imagebox = wibox.widget {
font: "Source Sans Pro 16"
halign: "center"
valign: "center"
markup: "<b>Hello</b> <i>world</i>"
widget: wibox.widget.textbox
}
--gears.timer {
-- timeout: 2
-- autostart: true
-- single_shot: true
-- callback: () -> imagebox.image = "/slimeos-yuescript/test2.png"
--}
<- util.after_timeout(0.01)
box = wibox {
width: 500
height: 250
visible: true
ontop: true
bg: "#FFFFFF40"
widget: {
imagebox
{
imagebox
radius: 10
--edge_strategy: "repeat" -- "repeat"|"black"|"transparent"
widget: filter.blur
}
layout: wibox.layout.flex.horizontal
}
}
awful.placement.left(box, margins: 10, honor_workarea: true)
--]]
catch err
util.notify_error(err)
--]]
--- Rubato
--[[
do
import "rubato"
import "rubato.easing"
import "slimeos.boxes.animated_wibox"
counter = 0
textbox = wibox.widget {
halign: "center"
valign: "center"
text: "current count: #{counter}"
widget: wibox.widget.textbox
}
wb_full_width = util.scale(300)
wb_full_height = util.scale(300)
<- util.apcall()
wb = animated_wibox {
direction: "up"
container_args: {
ontop: true
visible: false
x: 0
y: 0
width: wb_full_width
height: wb_full_height
widget: {
{
textbox
shape: (cr, w, h) -> gears.shape.rounded_rect(cr, w, h, util.scale(10))
widget: wibox.container.background
}
margins: util.scale(4)
widget: wibox.container.margin
}
}
rubato_args: {
duration: 1
easing: {
F: 1/5
easing: (t) ->
--- (t ^ 4) but [maybe] a tiny bit more efficient
t2 = t * 2
t2 * t2
}
}
}
wb::connect_signal("visibility::show", () =>
counter += 1
textbox.text = "current count: #{counter}"
)
import "slimeos.widgets.Button"
toggle_box = wibox {
ontop: true
visible: true
width: util.scale(100)
height: util.scale(100)
widget: {
{
halign: "center"
valign: "center"
text: "Toggle"
widget: wibox.widget.textbox
}
buttons: {
awful.button({}, 1, nil, (() -> wb::toggle()))
}
widget: Button
}
}
awful.placement.centered(toggle_box)
--]]
--[[
with Button = slimeos.widgets.Button
placement = () => awful.placement.left(@, { honor_workarea: true, margins: util.scale(10) })
local wb
try_or_log(() ->
wb = wibox {
ontop: true
visible: true
width: util.scale(200)
height: util.scale(100)
bg: gears.color.transparent
widget: {
{
{
nil,
{
{
image: util.lookup_icon("system-restart-symbolic")
halign: "center"
valign: "center"
forced_width: util.scale(30)
forced_height: util.scale(30)
widget: wibox.widget.imagebox
}
{
markup: "<b>Restart awesome</b>"
halign: "center"
valign: "center"
widget: wibox.widget.textbox
}
spacing: util.scale(10)
layout: wibox.layout.fixed.horizontal
}
expand: "outside"
layout: wibox.layout.align.horizontal
}
buttons: {
awful.button({}, 1, nil, () -> awesome.restart())
}
widget: Button
--widget: wibox.container.background
}
bg: beautiful.bg_normal
fg: beautiful.fg_normal
border_color: beautiful.fg_normal
border_width: util.scale(2)
widget: wibox.container.background
}
}
placement(wb)
)
--]]
--[[
with TagLayoutIndicator = slimeos.widgets.TagLayoutIndicator
placement = () => awful.placement.centered(@, { honor_workarea: true })
local wb
try_or_log(() ->
wb = wibox {
ontop: true
visible: true
width: util.scale(100)
height: util.scale(100)
bg: gears.color.transparent
widget: {
{
--awful.widget.layoutbox
id: "foobar"
widget: TagLayoutIndicator
}
bg: beautiful.bg_normal
fg: beautiful.fg_normal
border_color: beautiful.fg_normal
border_width: util.scale(2)
widget: wibox.container.background
}
}
placement(wb)
)
--]]
--[[
with util.terminal
.log.matrix2({
{ { "left", "foo" }, { "right", "bar" } }
{ { "left", "biz" }, { "right", "baz" } }
{ { "left", "lua" }, { "center", "moon" }, { "right", "yue" } }
{ { "center", "centered" }, { "right", "shorter line\nloooooooooooooooooooooooonger line" } }
{ { "left", "loooooooooooooooooooooooooooooooooooooooooooooooooooooooong" }, { "center", "I'm centered" } }
{ { "left", "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz" }, { "left", "I'm left and very loooooooooooooooooooooooooooooooooooong" } }
}, {
shadow: false
empty_shadow: false
foreground: .color.foreground.normal.black
background: .color.background.normal.blue
--columns: 2
--rows: 3
})
--]]
--[[
do
--- A song lyrics widget. Requires https://github.com/Jugran/lyrics-in-terminal
--- in addion to playerctl.
lyrics_box_textbox = wibox.widget {
valign: "top"
widget: wibox.widget.textbox
}
lyrics_box = wibox {
width: util.scale(400)
height: util.scale(700)
--below = true
ontop: true
visible: true
widget: {
{
lyrics_box_textbox
layout: wibox.layout.overflow.vertical
},
margins: util.scale(10)
widget: wibox.container.margin
}
}
awful.placement.right(lyrics_box, {
honor_workarea: true
margins: util.scale(20)
})
---@type PlayerctlMetadata
local previous_metadata
awesome.connect_signal("playerctl::metadata", (metadata) ->
---@cast metadata PlayerctlMetadata
if metadata::same_song_as(previous_metadata)
return
--notify(metadata, 0)
awful.spawn.easy_async({ "lyrics", "-t", metadata.artist, metadata.title }, (stdout, stderr, reason, exit_code) ->
lyrics_box_textbox.text = stdout or ""
)
previous_metadata = metadata
)
--]]
--[[
do
import ClassPlus from require("slimeos.lib")
wrap_gears_object = (gears_object, name="gears.object", ...) ->
go = gears_object(...)
local GearsObject
GearsObject = ClassPlus
name: name
new: (cls, ...) ->
@ = gears.table.crush({}, go)
@.<> = cls.__body
@
for k, v in pairs(go)
if rawget(GearsObject.__body, k) == nil
rawset(GearsObject.__body, k, v)
GearsObject
local Background
Background = ClassPlus
name: "Background"
parents: { wrap_gears_object(wibox.container.background, "wibox.container.background") }
local GradientBackground
GradientBackground = ClassPlus
name: "GradientBackground"
parents: { Background }
body:
set_bg: (color, ...) =>
local super = () -> ClassPlus.super(GradientBackground)
if type(color) != "string"
return super().set_bg(@, color, ...)
c = gears.color {
type: "linear"
from: { 0, 0 }
to: { util.scale(80), util.scale(80) }
stops: { { 0, color }, { 1, "#5000D0" } }
}
print(" >>> Using gradient instead of normal color ('#{color}') <<<")
print(" >>> #{super().set_bg} <<<")
super().set_bg(@, c, ...)
wb = wibox {
width: util.scale(80)
height: util.scale(80)
visible: true
ontop: true
}
awful.placement.top_left(wb, { honor_workarea: true, margins: util.scale(10) })
wb.widget = wibox.widget {
bg: "#FF0000" --- Works :)
widget: GradientBackground
}
--wb.widget::set_bg("#0000FF") --- Doesn't work :(
--wb.widget.bg = "#00FF00" --- Doesn't work :(
--]]
--}}}
--[[
util.apcall ->
local print = (msg) ->
util.notify(msg, 0, true)
extrautils = require("awesome-extrautils")()
import asyncio from extrautils
import async, await, async_run from asyncio
async_run ->
--await asyncio.sleep(7.5)
print("Running now...")
stdout, stderr, reason, exit_code = await asyncio.spawn_with_bash([=[echo $HOME]=])
print("stdout = '%s'\nstderr = '%s'\nreason = '%s'\nexit_code = '%d'\n"::format(
stdout
::gsub("\027%[[^a-zA-Z]*[a-zA-Z]", "")
::gsub("%s+$", ""),
stderr, reason, exit_code
))
print("Done!")
--]]