glava-config entry progress (incomplete), handle account rename links in documentation

This commit is contained in:
Jarcode
2019-09-07 22:44:36 -07:00
parent e46967cc02
commit 0695c9cec0
3 changed files with 192 additions and 59 deletions

View File

@@ -6,7 +6,7 @@
**Compiling:** **Compiling:**
```bash ```bash
$ git clone https://github.com/wacossusca34/glava $ git clone https://github.com/jarcode-foss/glava
$ cd glava $ cd glava
$ meson build --prefix /usr $ meson build --prefix /usr
$ ninja -C build $ ninja -C build
@@ -52,7 +52,7 @@ Some distributions have a package for `glava`. If your distribution is not liste
- NixOS [package](https://github.com/NixOS/nixpkgs/blob/release-18.09/pkgs/applications/misc/glava/default.nix) - NixOS [package](https://github.com/NixOS/nixpkgs/blob/release-18.09/pkgs/applications/misc/glava/default.nix)
- openSUSE [package](https://build.opensuse.org/package/show/X11:Utilities/glava) - openSUSE [package](https://build.opensuse.org/package/show/X11:Utilities/glava)
## [Configuration](https://github.com/wacossusca34/glava/wiki) ## [Configuration](https://github.com/jarcode-foss/glava/wiki)
GLava will start by looking for an entry point in the user configuration folder (`~/.config/glava/rc.glsl`), and will fall back to loading from the shader installation folder (`/etc/xdg/glava`). The entry point will specify a module to load and should set global configuration variables. Configuration for specific modules can be done in their respective `.glsl` files, which the module itself will include. GLava will start by looking for an entry point in the user configuration folder (`~/.config/glava/rc.glsl`), and will fall back to loading from the shader installation folder (`/etc/xdg/glava`). The entry point will specify a module to load and should set global configuration variables. Configuration for specific modules can be done in their respective `.glsl` files, which the module itself will include.
@@ -60,7 +60,7 @@ You should start by running `glava --copy-config`. This will copy over default c
To embed GLava in your desktop (for EWMH compliant window managers), run it with the `--desktop` flag and then position it accordingly with `#request setgeometry x y width height` in your `rc.glsl`. To embed GLava in your desktop (for EWMH compliant window managers), run it with the `--desktop` flag and then position it accordingly with `#request setgeometry x y width height` in your `rc.glsl`.
For more information, see the [main configuration page](https://github.com/wacossusca34/glava/wiki). For more information, see the [main configuration page](https://github.com/jarcode-foss/glava/wiki).
## Desktop window compatibility ## Desktop window compatibility
@@ -69,7 +69,7 @@ GLava aims to be compatible with _most_ EWMH compliant window managers. Below is
| WM | ! | Details | WM | ! | Details
| :---: | --- | --- | | :---: | --- | --- |
| Mutter (GNOME, Budgie) | ![-](https://placehold.it/15/118932/000000?text=+) | `"native"` (default) opacity should be used | Mutter (GNOME, Budgie) | ![-](https://placehold.it/15/118932/000000?text=+) | `"native"` (default) opacity should be used
| KWin (KDE) | ![-](https://placehold.it/15/118932/000000?text=+) | "Show Desktop" [temporarily hides GLava](https://github.com/wacossusca34/glava/issues/4#issuecomment-419729184) | KWin (KDE) | ![-](https://placehold.it/15/118932/000000?text=+) | "Show Desktop" [temporarily hides GLava](https://github.com/jarcode-foss/glava/issues/4#issuecomment-419729184)
| Openbox (LXDE or standalone) | ![-](https://placehold.it/15/118932/000000?text=+) | No issues | Openbox (LXDE or standalone) | ![-](https://placehold.it/15/118932/000000?text=+) | No issues
| Xfwm (XFCE) | ![-](https://placehold.it/15/118932/000000?text=+) | No issues | Xfwm (XFCE) | ![-](https://placehold.it/15/118932/000000?text=+) | No issues
| Fluxbox | ![-](https://placehold.it/15/118932/000000?text=+) | No issues | Fluxbox | ![-](https://placehold.it/15/118932/000000?text=+) | No issues

View File

@@ -19,6 +19,12 @@ return {
field_type = "float", field_type = "float",
description = "Some Float" description = "Some Float"
}, },
{
"request:fakecolorexpr",
field_type = "color-expr",
field_attrs = { alpha = true },
description = "Color Expression"
},
{ {
"request:setbg", "request:setbg",
field_type = "color", field_type = "color",
@@ -31,8 +37,8 @@ return {
field_type = { "int", "int" }, field_type = { "int", "int" },
field_attrs = { field_attrs = {
frame_label = "Version", frame_label = "Version",
{ label = "Major:", lower = 0, upper = 10, width = 2 }, { lower = 0, upper = 10, width = 2 },
{ label = "Minor:", lower = 0, upper = 10, width = 2 } { lower = 0, upper = 10, width = 2 }
}, },
description = "OpenGL context version request" description = "OpenGL context version request"
} }

View File

@@ -134,14 +134,14 @@ return function()
local ConfigView = function(tbl) local ConfigView = function(tbl)
local grid = { local grid = {
row_spacing = 5, row_spacing = 2,
column_spacing = 12, column_spacing = 12,
column_homogeneous = false, column_homogeneous = false,
row_homogeneous = true row_homogeneous = false
} }
local list = {} local list = {}
local idx = 0 local idx = 0
local function cbuild(list, entry, idx) local function cbuild(list, entry)
list[#list + 1] = { list[#list + 1] = {
Gtk.Label { label = entry[1], halign = "START", valign = "START" }, Gtk.Label { label = entry[1], halign = "START", valign = "START" },
left_attach = 0, top_attach = idx left_attach = 0, top_attach = idx
@@ -151,20 +151,29 @@ return function()
left_attach = 1, top_attach = idx left_attach = 1, top_attach = idx
} }
list[#list + 1] = { list[#list + 1] = {
apply { halign = "FILL", hexpand = false, entry[2] }, apply { halign = "END", entry[3] or Gtk.Box {} },
left_attach = 2, top_attach = idx left_attach = 2, top_attach = idx
} }
list[#list + 1] = {
apply { halign = "FILL", hexpand = false, entry[2] },
left_attach = 3, top_attach = idx
}
list[#list + 1] = {
Gtk.Separator {
vexpand = false
},
left_attach = 0, top_attach = idx + 1, width = 3
}
idx = idx + 2
end end
for _, entry in ipairs(tbl) do for _, entry in ipairs(tbl) do
cbuild(list, entry, idx) cbuild(list, entry)
idx = idx + 1
end end
local adv = {} local adv = {}
if tbl.advanced then if tbl.advanced then
idx = 0 idx = 0
for _, entry in ipairs(tbl.advanced) do for _, entry in ipairs(tbl.advanced) do
cbuild(adv, entry, idx) cbuild(adv, entry)
idx = idx + 1
end end
end end
for k, v in pairs(grid) do for k, v in pairs(grid) do
@@ -215,9 +224,12 @@ return function()
} }
end, end,
["string"] = function(attrs) ["string"] = function(attrs)
local widget = attrs.entries ~= nil local widget = apply {
and apply { hexpand = true, ComboBoxFixed(attrs.entries) } attrs.entries ~= nil
or Gtk.Entry { width_chars = 16 } and apply { ComboBoxFixed(attrs.entries) }
or Gtk.Entry { width_chars = 12 },
hexpand = true
}
return { return {
widget = wrap_label(widget, attrs.label), widget = wrap_label(widget, attrs.label),
internal = widget, internal = widget,
@@ -260,7 +272,7 @@ return function()
lower = attrs.lower or 0, lower = attrs.lower or 0,
upper = attrs.upper or 100, upper = attrs.upper or 100,
page_size = 1, page_size = 1,
step_increment = attrs.increment and (attrs.increment / 10) or 0.1, step_increment = attrs.increment or 1,
page_increment = attrs.increment or 1 page_increment = attrs.increment or 1
}, },
width_chars = attrs.width or 6, width_chars = attrs.width or 6,
@@ -280,7 +292,7 @@ return function()
lower = attrs.lower or 0, lower = attrs.lower or 0,
upper = attrs.upper or 100, upper = attrs.upper or 100,
page_size = 1, page_size = 1,
step_increment = attrs.increment and math.min(math.floor((attrs.increment / 10)), 1) or 1, step_increment = attrs.increment or 1,
page_increment = attrs.increment or 1 page_increment = attrs.increment or 1
}, },
width_chars = attrs.width or 6, width_chars = attrs.width or 6,
@@ -392,14 +404,129 @@ return function()
entry:set_text(s) entry:set_text(s)
end end
} }
end,
["color-expr"] = function(attrs, header)
local controls = {
{ "Baseline", "d" },
{ "X axis", "gl_FragCoord.x" },
{ "Y axis", "gl_FragCoord.y" }
}
local control_list = {}
for i, v in ipairs(controls) do
control_list[i] = v[1]
end
local cetypes = {
{ "Gradient",
fields = {
{ "color" },
{ "color" },
{ "string", entries = control_list, header = "Axis:" },
{ "float", header = "Scale:" }
},
get_data = function(self, c0, c1, i0, i1)
end,
-- match against GLSL mix expression, ie.
-- `mix(#3366b2, #a0a0b2, clamp(d / GRADIENT, 0, 1))`
match = "mix%s*%(" ..
"%s*(#[%dA-Fa-f]*)%s*," ..
"%s*(#[%dA-Fa-f]*)%s*," ..
"%s*clamp%s*%(%s*(%w+)%s*/%s*(%w+)%s*,%s*0%s*,%s*1%s*%)%s*%)"
},
{ "Solid",
fields = { { "color" } },
get_data = function(self, c)
end,
match = "#[%dA-Fa-f]*",
default = true
}
}
local stack = Gtk.Stack { vhomogeneous = false }
local hstack = Gtk.Stack { vhomogeneous = false }
local cekeys = {}
local default = nil
local didx = -1
for i, v in ipairs(cetypes) do
cekeys[i] = v[1]
cetypes[v[1]] = v
local wfields = {}
local hfields = {
Gtk.Label {
halign = "END",
valign = "START",
label = header
}
}
for k, v in ipairs(v.fields) do
v.alpha = attrs.alpha
local g = widget_generators[v[1]](v)
wfields[k] = g.widget
hfields[#hfields + 1] = Gtk.Label {
halign = "END",
label = v.header
}
end
v.widget = Gtk.Box(
apply {
homogeneous = true,
orientation = "VERTICAL",
spacing = 1,
wfields
}
)
v.hwidget = Gtk.Box(
apply {
homogeneous = true,
orientation = "VERTICAL",
spacing = 1,
hfields
}
)
hstack:add_named(v.hwidget, v[1])
stack:add_named(v.widget, v[1])
if v.default then
didx = i - 1
default = v[1]
end
v.set_data = function(self, x)
end
end
local cbox = apply {
hexpand = true,
ComboBoxFixed(cekeys)
}
cbox:set_active(didx)
stack:set_visible_child(cetypes[default].widget)
hstack:set_visible_child(cetypes[default].hwidget)
cetypes[default].widget:show()
cetypes[default].hwidget:show()
function cbox:on_changed()
local t = cbox:get_active_text()
stack:set_visible_child_name(t)
hstack:set_visible_child_name(t)
end
local widget = Gtk.Box {
orientation = "VERTICAL",
spacing = 1,
wrap_label(cbox, attrs.label), stack
}
return {
widget = widget,
header_widget = hstack
}
end end
} }
local ServiceView = function(self) local ServiceView = function(self)
local switch = Gtk.Switch { local switch = Gtk.Switch {
id = "autostart_enabled", id = "autostart_enabled",
sensitive = false, sensitive = false,
hexpand = false hexpand = false
} }
local method = ComboBoxFixed { local method = ComboBoxFixed {
"None", "None",
@@ -443,14 +570,20 @@ return function()
local layout = {} local layout = {}
for _, e in ipairs(v) do for _, e in ipairs(v) do
if type(e) == "table" then if type(e) == "table" then
local header = nil
local fields = {} local fields = {}
local ftypes = type(e.field_type) == "table" and e.field_type or { e.field_type } local ftypes = type(e.field_type) == "table" and e.field_type or { e.field_type }
local fattrs = type(e.field_type) == "table" and e.field_attrs or { e.field_attrs } local fattrs = type(e.field_type) == "table" and e.field_attrs or { e.field_attrs }
if not fattrs then fattrs = {} end if not fattrs then fattrs = {} end
for i, f in ipairs(ftypes) do for i, f in ipairs(ftypes) do
local entry = widget_generators[f](fattrs[i] or {}) local entry = widget_generators[f](fattrs[i] or {}, e.header)
if not header then
header = entry.header_widget
end
fields[#fields + 1] = entry.widget fields[#fields + 1] = entry.widget
end end
-- disable header display widget if there are multiple fields
if #fields > 1 then header = nil end
fields.orientation = "VERTICAL" fields.orientation = "VERTICAL"
fields.spacing = 2 fields.spacing = 2
local fwidget = { local fwidget = {
@@ -465,7 +598,8 @@ return function()
margin_bottom = 4, margin_bottom = 4,
Gtk.Box(fields) Gtk.Box(fields)
} }
} or Gtk.Box(fields) } or fields[1],
header or (e.header and Gtk.Label { valign = "START", label = e.header } or Gtk.Box {})
} }
if not e.advanced then if not e.advanced then
layout[#layout + 1] = fwidget layout[#layout + 1] = fwidget
@@ -552,36 +686,29 @@ return function()
} }
} }
}, },
Gtk.Box { (function()
orientation = "HORIZONTAL", local box = Gtk.Box {
spacing = 4, homogeneous = true,
apply { Gtk.Button {
hexpand = false, id = "reload",
homogeneous = true, label = "Reload",
(function() image = Gtk.Image { stock = Gtk.STOCK_REFRESH }
local box = Gtk.Box { },
Gtk.Button { Gtk.Button {
id = "reload", id = "add",
label = "Reload", label = "New",
image = Gtk.Image { stock = Gtk.STOCK_REFRESH } image = Gtk.Image { stock = Gtk.STOCK_NEW },
}, },
Gtk.Button { Gtk.Button {
id = "add", id = "remove",
label = "New", label = "Delete",
image = Gtk.Image { stock = Gtk.STOCK_NEW }, sensitive = false,
}, image = Gtk.Image { stock = Gtk.STOCK_DELETE },
Gtk.Button { }
id = "remove", }
label = "Delete", box:get_style_context():add_class("linked")
sensitive = false, return box
image = Gtk.Image { stock = Gtk.STOCK_DELETE }, end)(),
}
}
box:get_style_context():add_class("linked")
return box
end)()
}
},
}, },
Gtk.Stack { Gtk.Stack {
id = "stack_view", id = "stack_view",