Module: lib-tde.hardware-check

Perform queries on the hardware to validate certain components from existing.

Each piece of hardware is different and supports different components. For example a laptop vs desktop, usually a laptop has a battery whilst a desktop doesn't. You can query this api to discover certain components that should exist.

lib-tde.hardware-check.battery() -- returns True if a battery exists
lib-tde.hardware-check.wifi() -- returns True if wifi is supported
lib-tde.hardware-check.bluetooth() -- returns True if bluetooth is supported
lib-tde.hardware-check.sound() -- returns True if sound is working

You can also use this module to verify if the environment is configured correctly. For example you can have hard dependencies on some software to get a plugin working. An example is the build in screen recorder that depends on ffmpeg being installed.

lib-tde.hardware-check.has_package_installed("ffmpeg") -- returns True if ffmpeg is installed

Warning never try to use lib-tde.hardware-check.execute unless you known what you are doing. execute runs on the main thread and can cause input from not being handled. Which introduces lag to the system. Here is an example that locks the desktop for 2 seconds (where you can't do anything).

lib-tde.hardware-check.execute("sleep 2") -- block the main thread for 2 seconds

This module is constantly updated to support new queries and new possible dependencies. PR's are always welcome :)

Info:

  • Copyright: 2020 Tom Meyers
  • Author: Tom Meyers

Static module functions

lib-tde.hardware-check.execute (string) -> tuple Executes a shell command on the main thread, This is dangerous and should be avoided as it blocks input!!
lib-tde.hardware-check.hasBattery () -> bool Check to see if a battery exists on the hardware
lib-tde.hardware-check.hasWifi () -> bool Check to see the hardware has a network card
lib-tde.hardware-check.hasBluetooth () -> bool Check to see the hardware has a network card with bluetooth support
lib-tde.hardware-check.has_package_installed (string) -> bool Check if a certain piece of software is installed
lib-tde.hardware-check.hasFfmpeg () -> bool Check to see if ffmpeg is installed
lib-tde.hardware-check.hasSound () -> bool Check to see the hardware has a sound card installed
lib-tde.hardware-check.getDefaultIP () -> () Returns the ip address of the default route
lib-tde.hardware-check.getRamInfo () -> number, Returns general information about system ram
lib-tde.hardware-check.getCpuInfo () -> number, Returns general information about the cpu
lib-tde.hardware-check.isWeakHardware () -> () Returns if the hardware is to weak, e.g.
lib-tde.hardware-check.getDisplayFrequency () -> () Returns The frequency of the display panel in Hertz, for example 60 Hz


Static module functions

lib-tde.hardware-check.execute (string) -> tuple
Executes a shell command on the main thread, This is dangerous and should be avoided as it blocks input!!

Parameters:

  • string cmd The command to execute

Returns:

    tuple number> The first element is the standard output of the command (string), the second element is the exit code (number)

Usage:

    -- This returns Tuple<"hello", 0>
     lib-tde.hardware-check.execute("echo hello")
lib-tde.hardware-check.hasBattery () -> bool
Check to see if a battery exists on the hardware

Returns:

    bool True if a battery exists, false otherwise

Usage:

    -- This True if it is a laptop
     lib-tde.hardware-check.hasBattery()
lib-tde.hardware-check.hasWifi () -> bool
Check to see the hardware has a network card

Returns:

    bool True if a network card exists, false otherwise

Usage:

    -- This True if a network card with wifi exists
     lib-tde.hardware-check.hasWifi()
lib-tde.hardware-check.hasBluetooth () -> bool
Check to see the hardware has a network card with bluetooth support

Returns:

    bool True if a network card exists with bluetooth support, false otherwise

Usage:

    -- This True if a network card exists with bluetooth support
     lib-tde.hardware-check.hasBluetooth()
lib-tde.hardware-check.has_package_installed (string) -> bool
Check if a certain piece of software is installed

Parameters:

  • string name The name of the software package

Returns:

    bool True that piece of software is installed, false otherwise

Usage:

    -- This True for TOS based systems
     lib-tde.hardware-check.has_package_installed("linux-tos")
lib-tde.hardware-check.hasFfmpeg () -> bool
Check to see if ffmpeg is installed

Returns:

    bool True if ffmpeg is installed, false otherwise

Usage:

    -- This True if ffmpeg is installed (a video processor)
     lib-tde.hardware-check.hasFfmpeg()
lib-tde.hardware-check.hasSound () -> bool
Check to see the hardware has a sound card installed

Returns:

    bool True if a sound card exists, false otherwise

Usage:

    -- This True if a sound card exists
     lib-tde.hardware-check.hasSound()
lib-tde.hardware-check.getDefaultIP () -> ()
Returns the ip address of the default route

Returns:

    string ipv4 address as a string

Usage:

    -- For example returns 192.168.1.12
     lib-tde.hardware-check.getDefaultIP()
lib-tde.hardware-check.getRamInfo () -> number,
Returns general information about system ram

Returns:

    number, number The ram usage and ram total in KiloBytes

Usage:

    -- For example, 50(%), 10000000(kB)
     lib-tde.hardware-check.getRamInfo()
lib-tde.hardware-check.getCpuInfo () -> number,
Returns general information about the cpu

Returns:

    number, number, string, number The cpu core count, thread count, canonical name and frequency in MHz

Usage:

    -- For example, 8 (cores), 16 (threads), "AMD Ryzen 7 PRO 5800X", 3000(MHz)
     lib-tde.hardware-check.getCpuInfo()
lib-tde.hardware-check.isWeakHardware () -> ()
Returns if the hardware is to weak, e.g. little amount of ram, cpu etc

Returns:

    bool true if the hardware is below a certain threshold

Usage:

    -- If ram is below 1G or only one cpu core is present
     lib-tde.hardware-check.isWeakHardware()
lib-tde.hardware-check.getDisplayFrequency () -> ()
Returns The frequency of the display panel in Hertz, for example 60 Hz

Returns:

    number The frequency of the display in Hertz

Usage:

    -- Returns The frequency of the display panel in Hertz, for example 60 Hz
     lib-tde.hardware-check.getDisplayFrequency()
generated by LDoc 1.4.6 Build with 💜 By F0xedb Last updated 2021-05-21 03:30:15