ENH use module-specific geometries

This commit is contained in:
Nathan Dwarshuis 2022-08-15 23:23:15 -04:00
parent c50a704c0f
commit 99ce64bbb6
10 changed files with 130 additions and 54 deletions

View File

@ -6,48 +6,113 @@ let Margin = Vector2 Natural
let FSPath = { name : Text, path : Text }
let FileSystem = { show_smart : Bool, fs_paths : List FSPath }
let FSGeo =
{ Type = { spacing : Natural, bar_pad : Natural, sep_spacing : Natural }
, default = { spacing = 20, bar_pad = 100, sep_spacing = 20 }
}
let FileSystem =
{ Type =
{ show_smart : Bool, fs_paths : List FSPath, geometry : FSGeo.Type }
, default.geometry = FSGeo::{=}
}
let PlotGeo =
{ Type = { sec_break : Natural, height : Natural }
, default = { sec_break = 20, height = 56 }
}
let GfxGeo =
{ Type =
{ sep_spacing : Natural, text_spacing : Natural, plot : PlotGeo.Type }
, default = { sep_spacing = 20, text_spacing = 20, plot = PlotGeo::{=} }
}
let Graphics =
{ dev_power : Text
, show_temp : Bool
, show_clock : Bool
, show_gpu_util : Bool
, show_mem_util : Bool
, show_vid_util : Bool
{ Type =
{ dev_power : Text
, show_temp : Bool
, show_clock : Bool
, show_gpu_util : Bool
, show_mem_util : Bool
, show_vid_util : Bool
, geometry : GfxGeo.Type
}
, default.geometry = GfxGeo::{=}
}
let MemGeo =
{ Type = { text_spacing : Natural, plot : PlotGeo.Type }
, default = { plot = PlotGeo::{=}, text_spacing = 20 }
}
let Memory =
{ show_stats : Bool
, show_plot : Bool
, show_swap : Bool
, table_rows : Natural
{ Type =
{ show_stats : Bool
, show_plot : Bool
, show_swap : Bool
, table_rows : Natural
, geometry : MemGeo.Type
}
, default.geometry = MemGeo::{=}
}
let Network =
{ Type = { geometry : { plot : PlotGeo.Type } }
, default.geometry.plot = PlotGeo::{=}
}
let ProcGeo = { Type = { plot : PlotGeo.Type }, default.plot = PlotGeo::{=} }
let Processor =
{ core_rows : Natural
, core_padding : Natural
, show_stats : Bool
, show_plot : Bool
, table_rows : Natural
{ Type =
{ core_rows : Natural
, core_padding : Natural
, show_stats : Bool
, show_plot : Bool
, table_rows : Natural
, geometry : ProcGeo.Type
}
, default.geometry = ProcGeo::{=}
}
let RaplSpec = { name : Text, address : Text }
let Power = { battery : Text, rapl_specs : List RaplSpec }
let PwrGeo =
{ Type = { text_spacing : Natural, plot : PlotGeo.Type }
, default = { text_spacing = 20, plot = PlotGeo::{=} }
}
let ReadWrite = { devices : List Text }
let Pacman =
{ Type = { geometry : { text_spacing : Natural } }
, default.geometry.text_spacing = 20
}
let Power =
{ Type =
{ battery : Text, rapl_specs : List RaplSpec, geometry : PwrGeo.Type }
, default.geometry = PwrGeo::{=}
}
let RWGeo = { Type = { plot : PlotGeo.Type }, default.plot = PlotGeo::{=} }
let ReadWrite =
{ Type = { devices : List Text, geometry : RWGeo.Type }
, default.geometry = RWGeo::{=}
}
let System = Pacman
let ModType =
< filesystem : FileSystem
| graphics : Graphics
| memory : Memory
| network
| pacman
| processor : Processor
| power : Power
| readwrite : ReadWrite
| system
< filesystem : FileSystem.Type
| graphics : Graphics.Type
| memory : Memory.Type
| network : Network.Type
| pacman : Pacman.Type
| processor : Processor.Type
| power : Power.Type
| readwrite : ReadWrite.Type
| system : System.Type
>
let Annotated = \(a : Type) -> { type : Text, data : a }
@ -246,9 +311,12 @@ in { toConfig
, FileSystem
, Graphics
, Memory
, Network
, Pacman
, Processor
, Power
, ReadWrite
, System
, Theme
, mod
}

View File

@ -2,7 +2,8 @@ let C = ./config.dhall
let memory =
C.ModType.memory
{ show_stats = False
C.Memory::{
, show_stats = False
, show_swap = False
, show_plot = True
, table_rows = 3
@ -10,7 +11,8 @@ let memory =
let processor =
C.ModType.processor
{ core_rows = 0
C.Processor::{
, core_rows = 0
, core_padding = 0
, show_stats = False
, show_plot = True
@ -24,7 +26,7 @@ let layout =
{ columns =
[ C.Column.CCol
{ blocks =
[ C.mod C.ModType.network
[ C.mod (C.ModType.network C.Network::{=})
, C.Block.Pad 10
, C.mod memory
, C.Block.Pad 10

View File

@ -3,9 +3,10 @@ local pure = require 'pure'
local impure = require 'impure'
return function(main_state, config, common, width, point)
local SPACING = 20
local BAR_PAD = 100
local SEPARATOR_SPACING = 20
local geo = config.geometry
local SPACING = geo.spacing
local BAR_PAD = geo.bar_pad
local SEPARATOR_SPACING = geo.sep_spacing
-----------------------------------------------------------------------------
-- smartd

View File

@ -2,10 +2,11 @@ local pure = require 'pure'
local i_o = require 'i_o'
return function(update_freq, config, common, width, point)
local SEPARATOR_SPACING = 20
local TEXT_SPACING = 20
local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56
local geo = config.geometry
local SEPARATOR_SPACING = geo.sep_spacing
local TEXT_SPACING = geo.text_spacing
local PLOT_SEC_BREAK = geo.plot.sec_break
local PLOT_HEIGHT = geo.plot.height
local NA = 'N/A'
local NVIDIA_EXE = 'nvidia-settings'
local __string_match = string.match

View File

@ -5,14 +5,15 @@ local pure = require 'pure'
local sys = require 'sys'
return function(update_freq, config, common, width, point)
local geo = config.geometry
local DIAL_THICKNESS = 8
local DIAL_RADIUS = 32
local DIAL_SPACING = 40
local DIAL_X_SPACING = 40
local CACHE_Y_OFFSET = 7
local CACHE_X_OFFSET = 50
local TEXT_SPACING = 20
local PLOT_SECTION_BREAK = 23
local PLOT_HEIGHT = 56
local TEXT_SPACING = geo.text_spacing
local PLOT_SECTION_BREAK = geo.plot.sec_break
local PLOT_HEIGHT = geo.plot.height
local TABLE_SECTION_BREAK = 20
local __math_floor = math.floor
@ -54,7 +55,7 @@ return function(update_freq, config, common, width, point)
local CACHE_X
local SWAP_X
if _show_swap == true then
SWAP_X = MEM_X + DIAL_DIAMETER + DIAL_SPACING
SWAP_X = MEM_X + DIAL_DIAMETER + DIAL_X_SPACING
CACHE_X = SWAP_X + CACHE_X_OFFSET + DIAL_DIAMETER / 2
else
CACHE_X = MEM_X + CACHE_X_OFFSET + DIAL_DIAMETER / 2

View File

@ -3,9 +3,10 @@ local pure = require 'pure'
local i_o = require 'i_o'
local sys = require 'sys'
return function(update_freq, _, common, width, point)
local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56
return function(update_freq, config, common, width, point)
local geo = config.geometry
local PLOT_SEC_BREAK = geo.plot.sec_break
local PLOT_HEIGHT = geo.plot.height
local interface_paths = sys.get_net_interface_paths()
local get_bits = function(path)

View File

@ -1,7 +1,7 @@
local pure = require 'pure'
return function(main_state, _, common, width, point)
local TEXT_SPACING = 20
return function(main_state, config, common, width, point)
local TEXT_SPACING = config.geometry.text_spacing
local __string_match = string.match
local __string_gmatch = string.gmatch

View File

@ -3,9 +3,10 @@ local pure = require 'pure'
local sys = require 'sys'
return function(update_freq, config, common, width, point)
local TEXT_SPACING = 20
local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56
local geo = config.geometry
local TEXT_SPACING = geo.text_spacing
local PLOT_SEC_BREAK = geo.plot.sec_break
local PLOT_HEIGHT = geo.plot.height
local power_label_function = function(plot_max)
local fmt = common.y_label_format_string(plot_max, 'W')

View File

@ -5,8 +5,9 @@ local i_o = require 'i_o'
local impure = require 'impure'
return function(update_freq, config, common, width, point)
local PLOT_SEC_BREAK = 20
local PLOT_HEIGHT = 56
local geo = config.geometry
local PLOT_SEC_BREAK = geo.plot.sec_break
local PLOT_HEIGHT = geo.plot.height
local mod_state = {read = 0, write = 0}
local device_paths = sys.get_disk_paths(config.devices)

View File

@ -1,8 +1,8 @@
local i_o = require 'i_o'
local pure = require 'pure'
return function(main_state, _, common, width, point)
local TEXT_SPACING = 20
return function(main_state, config, common, width, point)
local TEXT_SPACING = config.geometry.text_spacing
local __string_match = string.match