LV - local variables

LV: local variables (get and set local variable values)

Syntax

lv()

Arguments

    Examples

    FormulaDescription
    $lv("foo", "Some Value")$Value is: $lv(foo)$Sets a simple variable and shows value using lv()
    $lv("foo", df(m))$$"Minutes are: "+#foo$Sets a simple variable and shows value using #

    MI - music info

    MI: music info (playing track, artist, album cover…)

    Syntax

    mi(type)

    Arguments

    • type: Info type, see examples

    Examples

    FormulaDescription
    $mi(album)$Current Album (if set)
    $mi(artist)$Current Artist (if set)
    $mi(title)$Current Track Title (if set)
    $tf(mi(len), mm:ss)$Current Track Duration (in mm:ss format)
    $tf(mi(pos), mm:ss)$Current Track Position (in mm:ss format)
    $mi(len)$Current Track Duration (in seconds)
    $mi(pos)$Current Track Position (in seconds)
    $mi(vol)$Current Music Volume (0 to 100)
    $mi(percent)$Current Track Position (in percentage)
    $mi(cover)$Current Cover Image (to be used in Image module or Background as formula)
    $mi(package)$Current Player Package Name
    $mi(track)$Current track in playlist (if available, to be used with mq)
    $ni(mi(package), bicon)$Current Player App Icon (to be used in Image module or Background as formula)
    $mi(state)$Current Player State, one of:: STOPPED, PAUSED, PLAYING, FORWARDING, REWINDING, SKIPPING_FORWARDS, SKIPPING_BACKWARDS, BUFFERING, ERROR, NONE

    MQ - music queue

    MQ: music queue (get current playlist or next track name, duration…)

    Syntax

    mq(type, [index])

    Arguments

    • type: Track Index (len for playlist length)
    • index: Info type, see examples

    Examples

    FormulaDescription
    $mq(title, mi(track) + 1)$Next track title (if available)
    $mq(sub, mi(track) - 1)$Prev track sub title (if available)
    $mq(len)$Playlist length

    MU - math utilities

    MU: math utilities (floor, ceil, sqrt, min, max…)

    Syntax

    mu(var, [default])

    Arguments

    • var: Function (one of ceil, floor or sqrt)
    • default: One or more values depending on the function

    Examples

    FormulaDescription
    $mu(ceil, 3.14)$Will return ceil of 3.14
    $mu(floor, 3.80)$Will return floor of 3.80
    $mu(sqrt, 2)$Will return square root of 2
    $mu(round, 2.80)$Will round 2.80 to the nearest integer
    $mu(round, 2.858284, 2)$Will round number to 2 decimals
    $mu(min, 1, 3)$Will return min between 1 and 3
    $mu(max, 1, 3)$Will return max between 1 and 3
    $mu(abs, -1)$Will return absolute value of -1
    $mu(cos, 90)$Cosine of 90 degrees
    $mu(sin, 90)$Sine of 90 degrees
    $mu(tan, 45)$Tangent of 45 degrees
    $mu(acos, 1)$Inverse Cosine of 1
    $mu(asin, 1)$Inverse Sine of 1
    $mu(atan, 45)$Inverse Tangent of 45 degrees
    $mu(log, 5)$Logarithm of 5
    $mu(pow, 2, 3)$2 raised to the power of 3
    $mu(ln, 5)$Natural logarithm of 5
    $mu(rnd, 10, 100)$Random number between 10 and 100
    $mu(h2d, 5F)$Converts an hex number to decimal
    $mu(d2h, 123)$Converts a decimal number to hex

    NC - network connectivity

    NC: network connectivity (wifi / phone signal, operator name, network state…)

    Syntax

    nc(text)

    Arguments

    • text: Info type, see examples and reference

    Examples

    FormulaDescription
    $nc(csig)$Cell signal from 0 to 4
    $nc(operator)$Current cell operator
    $nc(dtype)$Current cellular data connection type (LTE, HSUPA…)
    $nc(dtypes)$Current cellular data connection short type (4G, 3G…)
    $nc(ssid)$Current WiFi SSID (if connected)
    $nc(wsig)$Wifi signal from 0 to 9
    $nc(csiga)$Cell signal level as an asu value between 0..31, 99 is unknown
    $nc(csigd)$Cell signal level in dbm
    $nc(wrssi)$Wifi signal raw (RSSI)
    $nc(wspeed)$Wifi speed in Megabit
    $nc(bt)$Current BlueTooth static, 0 disabled, 1 enabled, 2 connected
    $nc(acount)$Count of currently connected Audio Devices
    $nc(aname, 0)$Name of the first audio device
    $nc(aaddr, 0)$Address of the first BT audio device
    $nc(abatt, 0)$Battery of the first BT audio device (when supported)
    $nc(airplane)$Airplane mode, 0 if disabled, 1 if enabled
    $nc(simcount)$Get current number of active SIMs
    $nc(ifip)$Returns IPv4 of first non loopback interface
    $nc(ifname)$Returns name of first non loopback interface
    $nc(ifip, 1)$Returns IPv4 of second non loopback interface (if present)
    $nc(cid)$Cell ID (CID) from network operator
    $nc(lac)$Location Area Code (LAC) from network operator
    $nc(carrier, 0)$Get SIM operator name for first SIM
    $nc(csig, 1)$Cell signal for second sim
    $nc(operator, 1)$Current cell operator for second sim
    $nc(operator, nc(svoice))$Default SIM Operator for Voice
    $nc(operator, nc(sdata))$Default SIM Operator for Data
    $nc(operator, 1)$Current cell operator for second sim
    $nc(cell)$Current cellular status, one of:: OFF, AIRPLANE, ON, DATA, ROAMING, DATAROAMING
    $nc(wifi)$Current WiFi status, one of:: DISABLED, ENABLED, CONNECTED

    NI - system notification

    NI: system notification (status bar notification data like title, icon, line count…)

    Syntax

    ni(type)

    Arguments

    • type: Info type, see examples

    Examples

    FormulaDescription
    $ni(count)$Cancellable notifications count
    $ni(scount)$Persistent notifications count
    $ni(pcount, com.facebook.orca)$Facebook messenger notifications count
    $ni(pcount, com.whatsapp)$Whatsapp notifications count
    $ni(pcount, com.google.android.gm)$Gmail notifications count
    $ni(0, title)$Title of first cancellable notification
    $ni(0, text)$Short text of first cancellable notification
    $ni(0, desc)$Long text of first cancellable notification
    $ni(0, icon)$Icon of first cancellable notification (to be used as Bitmap formula)
    $ni(0, bicon)$Large icon of first cancellable notification (to be used as Bitmap formula)
    $ni(0, count)$Lines count of first cancellable notification
    $ni(0, pkg)$Pkg of first cancellable notification
    $ni(0, app)$App name of first cancellable notification
    $tf(ni(0, time))$Time since first cancellable notification
    $ni(s0, text)$Short text of first persistent notification
    $ni(com.google.android.gm, text)$Text of first Gmail notification (if there)

    Resources (kfile)

    Kustom resources#

    As you might notice when you start using formulas for Bitmaps or other type of objects you might realize that Kustom refers internally to resources using the form kfile://provider/path, this is the internal URL scheme for looking up local and remote files.

    The provider represents the “source” and can be of two different types:

    • Relative: when source is not known and Kustom has to look it up, a relative provider is always “org.kustom.provider”, this is the default when you export a preset and it will tell Kustom to search all available sources for a given preset and search for “path”
    • Absolute: when source is known, this can generaly be
      • A provider from an APK pack (their content provider)
      • Kustom own provider (so for KWGT org.kustom.widget.provider)
      • The SD card provider (starts with SDxx)
      • The internal storage provider (starts with storage)

    Please never hardcode a provider in a KFile, always use the relative path if you need to reference files manually

    RM - resource monitor

    RM: resource monitor (cpu usage, memory, storage usage…)

    Syntax

    rm(type, [fs])

    Arguments

    • type: Info type, see examples
    • fs: FS to get stats from, use int for internal, ext for SD (default) or specify custom absolute path

    Examples

    FormulaDescription
    $rm(cidle)$%Current idle cpu in %
    $rm(cused)$%Current used (sys + usr) cpu in %
    $rm(cusr)$%Current user cpu in %
    $rm(csys)$%Current system cpu in %
    $rm(fmin)$MhzMin CPU frequency in Mhz
    $rm(fmax)$MhzMax CPU frequency in Mhz
    $rm(fcur)$MhzCurrent CPU frequency in Mhz
    $rm(mtot)$MBTotal memory in Mb
    $rm(mfree)$MBFree memory in Mb
    $rm(mused)$MBUsed memory in Mb
    $rm(fstot)$MBTotal SD FS space in Mb
    $rm(fsfree)$MBFree SD FS space in Mb
    $rm(fsused)$MBUsed SD FS space in Mb
    $rm(fstot, int)$MBTotal internal FS space in Mb
    $rm(fsfree, int)$MBFree internal FS space in Mb
    $rm(fsfree, "/sdcard/external_sd")$MBFree space of FS mounted in /sdcard/external_sd in Mb

    SH - shell command

    SH: shell command (execute a command in the underlying shell)

    Syntax

    sh(cmd, [timeout], [lines])

    Arguments

    • cmd: Command to execute
    • timeout: Refresh timeout in minutes or fractions (default 1 minute)
    • lines: Max lines to output (default 5)

    Examples

    FormulaDescription
    $sh("ps | grep '^u' | wc -l")$Number of user processes
    $sh("cat /proc/cpuinfo | grep Hardware | sed 's/.*: //'")$Current CPU technology

    SI - system info

    SI: system info (next alarm, uptime, device model, dark mode, orientation, rom…)

    Syntax

    si(type)

    Arguments

    • type: Info type, see examples

    Examples

    FormulaDescription
    $df("EEE hh:mma", si(alarmd))$Next alarm formatted date (if set)
    $si(alarmt)$Next alarm as original text
    $si(alarmon)$Alarm switch, return 1 if alarm is set, 0 otherwise
    Next alarm $tf(si(alarmd))$Time to next alarm (if set)
    $si(land)$Screen Orientation (gives 0 in portrait, 1 if landscape)
    $si(locked)$Device Lock (gives 1 if locked, 0 if not)
    $si(lmode)$Location mode, one of: OFF, SENSORS_ONLY, BATTERY_SAVING, HIGH_ACCURACY, UNKNOWN
    Uptime: $tf(df(S) - df(S, si(boot)))$Time since boot (uptime)
    $si(volr)$Ringer volume (0 to 100)
    $si(vola)$Alarm volume (0 to 100)
    $si(ringer)$Ringer mode, one of:: NORMAL, SILENT, VIBRATE
    $si(darkmode)$Returns 1 if system dark mode is on
    $si(darkwp)$Returns 1 if current wallpaper prefers dark colors
    $si(powersave)$Returns 1 if system is in power save mode (saving battery)
    $si(wpcolor1)$Primary color of wallpaper if available, 0 otherwise
    $si(wpcolor2)$Secondary color of wallpaper if available, 0 otherwise
    $si(rwidth)$Width of root container (in kustom points)
    $si(rheight)$Height of root container (in kustom points)
    $si(rratio)$Aspect ratio of root container (in kustom points)
    $si(model)$Phone Model
    $si(man)$Phone Manufacturer
    $si(build)$ROM Name
    $si(aver)$Android version number
    $si(mindex)$Module index in its parent
    $si(mcount)$Current group module count
    $si(mindex, 1)$Module index in its parent's parent
    $si(lnchname)$Name of currently set Launcher
    $si(lnchpkg)$Pkg of currently set Launcher
    $si(pkgname, si(lnchpkg))$Give name of an app from a pkg name
    $si(pkgver)$Gives version name of pkg if specified, of kustom if not
    $si(pkgvern, si(lnchpkg))$Gives version number of pkg if specified, of kustom if not
    $si(system, screen_brightness)$Current screen brightness
    $si(swidth)$Width of screen in DPI
    $si(sheight)$Height of screen in DPI
    $si(sdpi)$DPI
    $si(sdensity)$Density (Pixel Per DPI)
    $si(skpi)$KPI (Pixels per Kustom Point)
    $si(wpzoomed)$Returns 1 if wallpaper is currently zoomed (ex: app drawer is open)
    $si(sysca1, 50)$System (MaterialYou) first accent color at 50% tone (0 is white, 100 is black)
    $si(sysca2, 80)$System (MaterialYou) third accent color at 80% tone
    $si(syscn1, 20)$System (MaterialYou) first neutral color at 20% tone



    Privacy Policy