diff --git a/CHANGELOG.md b/CHANGELOG.md index 58abde0..71dc8e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,21 +1,27 @@ ### Features + - Install command (only if hosted in git repository) - New daemon comunication -- Fork process to background +- background fork process - Verbosity level -- Fix widget log file path +- Fix the widget's log file path - Add internal commands (battery, sysinfo, widget) -- Create nodejs bridgen to the internal API +- Create nodeJS bridge to internal APIs ### Refactor -- SbbwWidget new structure, more scalable and easy add features -- New arguments on cli -- Replace structopts to native clap + +- SbbwWidget new folder structure, more scalable and easy to add new features +- New CLI arguments +- Replaced structopts with native clap ### Details -New commands and migrate old commands and arguments + +New commands and migrated old ones and their arguments + --- + Old: + ```sh Sbbw Daemon 0.1.2 Sergio Ribera @@ -40,6 +46,7 @@ OPTIONS: ``` New: + ```sh sbbw 0.1.3 Sergio Ribera @@ -69,5 +76,6 @@ SUBCOMMANDS: ``` ### TODO + - Add event callbacks api -- implement media controller built-in +- implement built-in media controller diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eef6a1d..3945da7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,8 @@ # Sbbw Contributing Guide ### Contributing -- **sbbw**: this is the daemon, it is in charge of managing the widgets that are running, it is in charge of launching and closing the widgets based on commands or shortcuts. -- **sbbw-exec**: It is in charge of doing what is related to the first launching of the widget, such as generating the .lock or executing the autostart. -- **sbbw-widget**: It is the binary of the widget, this is the one that renders and communicates the web interface with the built-in functions, like detecting the battery, or controlling the multimedia. -- **sbbw-widget-conf**: Contains everything related to the widget manifest file and the sbbw configuration structures in general, as well as exports and validation. + +- **ssbw**: ssbw's main daemon manages all the currently running widgets by starting/closing them through commands or key shortcuts. +- **sbbw-exec**: It handles widget startup, as well, generating the lockfile (.lock) and autostarting. +- **sbbw-widget**: The widget's binary that renders and coordinates the widget's web interface with built-in commands (such as detecting the battery percentage or handling the multimedia interface). +- **sbbw-widget-conf**: Contains the widget's configuration manifest file and its self-export content & validations diff --git a/README.md b/README.md index a66e98d..29d76fc 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,43 @@ # Sbbw -This is a Simple and best tool for made Widgets and tools very easy with Web technologies and generate awesome interfaces. Based on `eww` and using [Wry](https://github.com/tauri-apps/wry) as a main window rendering. +Sbbww is the simplest and best way for making good-looking widgets & tools with web technologies. Based on `eww` and using [Wry](https://github.com/tauri-apps/wry) as rendering backend. -> **Note:** Each widget is configured independently in its corresponding folder +> **Note:** Each widget is configured independently within its associated folder. ![PreviewExamples](https://user-images.githubusercontent.com/56278796/153992032-82cf3c6a-f75a-475d-95ae-eb05ef6e21b5.gif) ## Examples + ### [sidebar](https://github.com/SergioRibera/sidebar-sbbw-widget) ![Screenshot_20220214_230856](https://user-images.githubusercontent.com/56278796/153992067-6e8a2cd3-969c-4eb2-9325-ac688489f45f.png) -> This project is made with [Vite](https://vitejs.dev) and [ReactJs](https://reactjs.org) +> Project made with [Vite](https://vitejs.dev) and [ReactJs](https://reactjs.org) ### [bottombar](https://github.com/SergioRibera/bottombar-sbbw-widget) ![image](https://user-images.githubusercontent.com/56278796/153992220-1445f40c-3ae3-4527-9df0-a4cc80e0b3ef.png) -> This project is made with [ReactJs](https://reactjs.org) +> Project made with [ReactJs](https://reactjs.org) ### [analog-clock](https://github.com/SergioRibera/analogclock-sbbw-widget) ![Screenshot_20220214_230947](https://user-images.githubusercontent.com/56278796/153992300-eab39961-0dbf-4d73-b3bc-a146377b1761.png) -> This project is made with [ReactJs](https://reactjs.org) +> Project made with [ReactJs](https://reactjs.org) ## Features -- All Web Frameworks supported -- Transparency -- Very fast -- Low cost -- Very Small + +- Supports all web frameworks +- Transparency support +- Fast performance +- Low memory usage +- Small-sized binaries - Autostart/Installation script support -- Cross Platform -- Test your widget using a web tools -- more... +- Cross-Platform +- Widget testing using web tools +- And much more... + ## Sbbw Usage + ```sh sbbw 0.1.3 Sergio Ribera -This is the launcher and manager for the Sbbw Wigets +This serves as the launcher and manager for Sbbw Widgets. USAGE: sbbw [OPTIONS] [SUBCOMMAND] @@ -56,20 +60,20 @@ SUBCOMMANDS: toggle ``` ## Installation -Agnostic to platform you need download the zip with binaries on [here](https://github.com/SergioRibera/sbbw/releases) depends of your Operative System, uncompress file and continue with next steps +By being platform-agnostic, you'll need only to download the zip file from the releases page [here](https://github.com/SergioRibera/sbbw/releases) and uncompress the file for performing the setup according to your operating system. **Windows** -> Only have to right click on `setup.bat` and run as Administrator for correct install +> Just right-click `setup.bat` and run as Administrator. **Linux/Mac** -> Open terminal on folder uncompressed and run: +> Open your terminal in the uncompressed folder path and run: > ```sh > sudo setup.sh > ``` -## Widget folder struct +## Widget folder structure ```sh ~ └─ .config @@ -85,30 +89,32 @@ Agnostic to platform you need download the zip with binaries on [here](https://g └─ config.toml ``` -The `~` home is variable on each operative system +The `~` stands for your user directory | SO | Value | Example | |--|--|--| | Linux | `$XDG_CONFIG_HOME` or `$HOME`/.config | /home/sergioribera/.config | | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\SergioRibera\AppData\Roaming | | MacOS | `$HOME`/Library/Application Support | /Users/SergioRibera/Library/Application Support | -> **Notes:** on here folder you need create a basic folder (or it's created anyways), but here is location where all widgets have stay -**Folders Explain** +> **Notes:** A basic folder should be created by the setup script. Otherwise, create it manually; the folder is required because of being the place where all sbbw widgets must be placed in. + + +**Folders structure & details** | Name | Details | |--|--| -| widget_name | This is a root of all files for your widget and this name is used by sbbw to call this | -| ui | On here is locate all web compiled or raw files for interface, notes are more Down with more details | -| autostart | On this folder is located all files what you need to run autostart commands, example: requirements.txt, `main.py`, or any you consider needed | -| scripts | Are a files you will need to get and modify system data, like a brightness, battery info, and more | -| config.toml | This file contains all configuration for show your widget | +| widget_name | Your widget's root path, the folder's name is used by sbbw for starting your widget | +| ui | Here is located all web-compiled or raw files for your widget interface, **there's a note below with further information about widget interfaces** | +| autostart | This folder encloses all required files to handle your widget's autostart lifecycle, examples:: requirements.txt, `main.py`, or any other file that your widget relies into | +| scripts | Files you'll need to fetch or modify system data or events, such as increasing/decreasing brightness, battery percentage information, and much more | +| config.toml | Contains all your widget configuration | -> **Note:** all this folders and file is extricted required for launch sbbw and show this plugin +> **Note:** These folders and the config.toml file are required for launching sbbw and displaying your widget -> **Other Note very important:** When you create a proyect using, vite, react, vue, any framework, you need set the homepage or basepath like `widget_name/ui`, `/ui` is very important for work correctly +> **UI-related note:** When creating a project using, vite, react, vue, or any framework, you'll need to set the homepage or basepath like this `widget_name/ui`, the `/ui` path plays an important role for your widget to function correctly ## Configuration -The struct of the configuration is this +The configuration struct schema looks like this: ```rust pub struct WidgetConfig { pub name: String, @@ -118,7 +124,7 @@ pub struct WidgetConfig { pub x: f32, pub y: f32, pub transparent: bool, - pub blur: bool, // Only works on Windows and Mac. For the linux users can be set with compositor + pub blur: bool, // Only works for Windows and Mac, linux users can set this from the compositor-side. pub always_on_top: bool, pub stick: bool, pub autostart: Vec @@ -127,37 +133,37 @@ pub struct WidgetConfig { **Explanation** | Name | Default | Type | Description | |--|--|--|--| -| name | Internal | String | This is a name of widget, this showed on name of window | -| class_name | Internal_class | String | This is only for linux, and this in reallity is a role but plus name, like this `{name}_{class_name}` | -| width | 200.0 | f64, Max | This define the width of widget | -| height | Max | f64, Max | This define the height of widget | -| x | 0.0 | f32 | This define a position in X of widget | -| y | 0.0 | f32 | This define a position in Y of widget | -| transparent | true | bool | This enable a transparency by default on start widget | -| blur | true | bool | This set a widget window as blurred, **This only works on MacOS and Windows** | -| always_on_top | true | bool | This define if always on top of other applications or widgets (in order of spawning) | -| stick | true | bool | This define widget as a persistent window on all workspaces, **For now, only works on Linux and soon on MacOS** | -| autostart | &[] | Vec | This is a list of commands to excecute on launch the first daemon of sbbw, but this only is executed if any file on `autostart` folder or `config.toml` are changed, and before execute all list, sbbw create a `config.lock` file (if you want share your widget you need ignore this `config.lock` file) | +| name | Internal | String | Your widget's name, shown on top of the widget's title | +| class_name | Internal_class | String | Linux-only, it's a role plus name, like `{name}_{class_name}` | +| width | 200.0 | f64, Max | Your widget's width | +| height | Max | f64, Max | Your widget's height | +| x | 0.0 | f32 | Defines your widget's position in the X axis | +| y | 0.0 | f32 | Defines your widget's position in the Y axis | +| transparent | true | bool | Enables transparency by default when your widget is starting | +| blur | true | bool | Enables widget blur; **only works in MacOS and Windows** | +| always_on_top | true | bool | Defines if the widget will be placed always on top of other applications/widgets when spawning | +| stick | true | bool | Defines a widget as a persistent window that goes throughout your workspaces, **At the moment, it's only working on Linux and soonly it'll work in MacOS also** | +| autostart | &[] | Vec | List of commands to execute when the first sbbw daemon is being launched; only executed when any file inside the `autostart` folder or your`config.toml` changed. Before sbbw executing this list of arguments, sbbw will create a `config.lock` file (In case of sharing your widget, you'll need to ignore this file) | **Example** ```toml name = "sidebar" -# Snake_case is acepted +# Snake_case is accepted class_name = "class_name" transparent = true -# On all variable names, the case is lowercase but accept snake_case +# Single variable names should be lowercased. Otherwise, snake_case naming should be used. alwaysontop = true stick = true blur = false width = "400.0" -# on width or height the case of "Max" is ignored +# In both width & height the case of "Max" is always ignored height = "mAx" x = 0.1 y = -850.0 -# This commands upgrade pip and install requirements on ./autostart -# where ./autostart is a root of subprocess command, -# so if you execute a `echo "$PWD"` the result is a {WIDGET_PATH}/autostart +# This upgrades pip and install all the widget's requirements on ./autostart +# where ./autostart is the autostart root path, +# You can check it by executing`echo "$PWD"`, the outcome will be {WIDGET_PATH}/autostart autostart = [ { cmd = "python", args = [ "-m", "ensurepip", "--upgrade" ] }, { cmd = "python", args = [ "-m", "pip", "install", "-r", "requirements.txt" ] }, @@ -165,18 +171,18 @@ autostart = [ ] ``` -**Details of Autostart parametter** -This is a list of commands, but this only have two parametters: +>**FYI**: **Autostart parametter** is command list requiring only two parameters per command: + | Name | Description | |--|--| -| cmd | This is a command for execute, can be are a binary or local file on `autostart` folder, so is accepted strings like this "python", "echo", "ls", "./main.py", "./script.sh", "node" | -| args | This is a list of strings, where each string is a argument for `cmd` | +| cmd | **Command for executing** whether file being a binary or local one inside the `autostart` folder, so strings like "python", "echo", "ls", "./main.py", "./script.sh", "node" are accepted | +| args | List of strings, where each string is an argument for `cmd` | -> **Note:** the `autostart` folder and `script` folder have a equals behaviour, but in other moment and context, the `autostart` is only executed on start **(if autostart content files or config.toml have changes)** daemon and `script` executed is determined by ui calls +> **Note:** Both `autostart` and `script` folders will behave the same, but `autostart` is only executed when starting **(or if the content files in autostart or config.toml have changed)** the sbbw daemon. `script` execution is determined by ui calls ## Widget NodeJs Module -You can see more details on [wiki page](https://github.com/SergioRibera/sbbw/wiki) +See more details on [wiki page](https://github.com/SergioRibera/sbbw/wiki) ### TODO -> NOTE: Moved to [TODO.md](TODO.md) +> FYI: Moved to [TODO.md](TODO.md) diff --git a/TODO.md b/TODO.md index 0be2213..93f73ba 100644 --- a/TODO.md +++ b/TODO.md @@ -1,52 +1,54 @@ # Sbbw TODO list -In this list you will find all the tasks that are being developed and those that are still to start, I invite you to see each one and see if you can collaborate in any way in any of them + +This list contains tasks currently under development, as well as tasks that are still in the backlog. I kindly request you to review the task list to catch up as much work progress as possible. Should you be interested in contributing, your participation would be greatly appreciated. ### Contributing -- **sbbw**: this is the daemon, it is in charge of managing the widgets that are running, it is in charge of launching and closing the widgets based on commands or shortcuts. -- **sbbw-exec**: It is in charge of doing what is related to the first launching of the widget, such as generating the .lock or executing the autostart. -- **sbbw-widget**: It is the binary of the widget, this is the one that renders and communicates the web interface with the built-in functions, like detecting the battery, or controlling the multimedia. -- **sbbw-widget-conf**: Contains everything related to the widget manifest file and the sbbw configuration structures in general, as well as exports and validation. + +- **ssbw**: ssbw's main daemon manages all the currently running widgets by starting/closing them through commands or key shortcuts. +- **sbbw-exec**: It handles widget startup, as well, generating the lockfile (.lock) and autostarting. +- **sbbw-widget**: The widget's binary that renders and coordinates the widget's web interface with built-in commands (such as detecting the battery percentage or handling the multimedia interface). +- **sbbw-widget-conf**: Contains the widget's configuration manifest file and its self-export content & validations ### TODO - [ ] MacOS - - [ ] Stick windows Support - - [ ] Implement brightness - - [ ] Implement media controll - - [ ] Implement wifi (get data) + - [ ] Implement support for macOS's pin window on top feature + - [ ] Implement brightness handling + - [ ] Implement media control handling + - [ ] Implement wifi interface support (to get network data) - [ ] Windows - - [ ] Implement media controll - - [ ] Implement wifi (get data) + - [ ] Implement media control handling + - [ ] Implement wifi interface support (to get network data) - [ ] Linux - [ ] TODO (xd) - [ ] General - - [ ] Sbbw daemon detect shortcuts and widgets configurable shortcuts - - [ ] Implement support for multiple widgets of the same open type - - [ ] Comunication between widgets - - [ ] A widget can launch another widget and get a response from it - - [ ] Widget request exit to daemon and daemon aprove close (Related to the above) - - [ ] Find better solution for launch command using shortcuts + - [ ] Implement shortcut detection & widget's configurable shortcut loading into sbbw daemon + - [ ] Implement widget multi-instance support + - [ ] Implement widget comunication system + - [ ] Implement nested widget calling/launching + - [ ] Implement widget closure handling (daemon should approve when widget's about to close) in sbbw daemon (It regards to the task below) + - [ ] SPIKE: Look into finding better approaches for executing commands by using key shortcuts. - [ ] NodeJs Module - - [ ] Fix issues using the module (When some functions are called, they do not have an expected behavior) + - [ ] Fix module issues (Calling some functions might end in unexpected behavior) ### In Progress -- [ ] ~~Refactor Code~~ +- [ ] Code refactor ### Done ✓ -- [x] ~~Test widget (using web tools)~~ -- [x] ~~Command to install widget easiest~~ -- [x] ~~Javascript variables, like as SO, Widget Name, and more~~ -- [x] ~~Nodejs module bridgen api~~ -- [x] ~~implement media controller built-in (linux)~~ -- [x] ~~Implement common commands natively (bat, brightness, sys_info, widget, media, wifi)~~ -- [x] ~~Sbbw daemon detect shortcuts and widgets configurable shortcuts~~ +- [x] ~~Widget unit testing using web tools~~ +- [x] ~~Command to install widgets the easy way~~ +- [x] ~~Javascript environment variables per widget (such as as OS information, Widget Name, and more)~~ +- [x] ~~NodeJS module package bridge api~~ +- [x] ~~implement built-in media controller (linux-only at the moment)~~ +- [x] ~~Implement support for common commands (bat, brightness, sys_info, widget, media, wifi) natively~~ +- [x] ~~Sbbw daemon detecting shortcuts and widgets configurable shortcuts~~ ### Rejected -- [x] ~~Lua support natively~~ +- [x] ~~Lua native support~~ diff --git a/sbbw-exec/src/lib.rs b/sbbw-exec/src/lib.rs index 01af219..3834398 100644 --- a/sbbw-exec/src/lib.rs +++ b/sbbw-exec/src/lib.rs @@ -32,7 +32,7 @@ fn generate_hash_from_file(path: PathBuf) -> Result> { } pub fn exec_command(pwd: String, params: Vec) -> Result { - let file = params.first().expect("The arguments cannot by empty"); + let file = params.first().expect("Arguments cannot be empty"); println!("{}", file); let mut args = params[1..].to_vec(); if file.starts_with("./") { diff --git a/sbbw-widget-conf/src/lib.rs b/sbbw-widget-conf/src/lib.rs index 951097a..4eae096 100644 --- a/sbbw-widget-conf/src/lib.rs +++ b/sbbw-widget-conf/src/lib.rs @@ -20,7 +20,7 @@ fn validate_config_from_string(config: &str) -> Result { match toml::from_str::<'_, WidgetConfig>(config) { Ok(conf) => Ok(conf), Err(e) => Err(format!( - "[{}] Config file is not valid: {}", + "[{}] Invalid config file: {}", "Error".red().bold(), e )), @@ -38,7 +38,7 @@ pub fn exits_widget(widget_name: String) -> bool { pub fn validate_config_toml(conf_path: PathBuf) -> Result { if !conf_path.exists() { return Err(format!( - "[{}] Config file for window not found: {}", + "[{}] window config file not found: {}", "Error".red().bold(), conf_path.display() )); diff --git a/sbbw-widget/src/builtin/brightness_ctl/win_tux.rs b/sbbw-widget/src/builtin/brightness_ctl/win_tux.rs index 72f365b..8cdea2f 100644 --- a/sbbw-widget/src/builtin/brightness_ctl/win_tux.rs +++ b/sbbw-widget/src/builtin/brightness_ctl/win_tux.rs @@ -11,7 +11,7 @@ use super::SbbwBrightnessDevice; pub fn get_main_brightness(_win: &Window, _name: String, _params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request brightness_ctl of main"); + trace!("Requesting main brightness_ctl"); match get_all_devices() { Ok(devices) => { @@ -34,7 +34,7 @@ pub fn get_main_brightness(_win: &Window, _name: String, _params: &str) -> SbbwR pub fn get_all_brightness(_win: &Window, _name: String, _params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request brightness_ctl of all"); + trace!("Requesting all the brightness_ctl instances"); match get_all_devices() { Ok(devices) => { @@ -52,7 +52,7 @@ pub fn get_all_brightness(_win: &Window, _name: String, _params: &str) -> SbbwRe pub fn set_main_brightness(_win: &Window, _name: String, params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request change brightness_ctl of main"); + trace!("Requesting main brightness_ctl for setting brightness"); match serde_json::from_str::(params) { Ok(value) => { @@ -73,7 +73,7 @@ pub fn set_main_brightness(_win: &Window, _name: String, params: &str) -> SbbwRe Err(_) => { error!("Bad params"); res.status = StatusCode::BAD_REQUEST.as_u16(); - res.data = "This require percent of brightness to set".to_string(); + res.data = "This requires the brightness percent to be set".to_string(); } } @@ -81,8 +81,8 @@ pub fn set_main_brightness(_win: &Window, _name: String, params: &str) -> SbbwRe } pub fn set_all_brightness(_win: &Window, _name: String, params: &str) -> SbbwResponse { - let mut res = SbbwResponse::default(); - trace!("Request change brightness_ctl of all"); + let mut res: SbbwResponse = SbbwResponse::default(); + trace!("Requesting for all brightness_ctl instances fto set brightness"); match serde_json::from_str::(params) { Ok(value) => { @@ -100,7 +100,7 @@ pub fn set_all_brightness(_win: &Window, _name: String, params: &str) -> SbbwRes Err(_) => { error!("Bad params"); res.status = StatusCode::BAD_REQUEST.as_u16(); - res.data = "This require percent of brightness to set".to_string(); + res.data = "This requires the brightness percent to be set".to_string(); } } diff --git a/sbbw-widget/src/builtin/media_ctl/linux.rs b/sbbw-widget/src/builtin/media_ctl/linux.rs index a03be33..0ea37bb 100644 --- a/sbbw-widget/src/builtin/media_ctl/linux.rs +++ b/sbbw-widget/src/builtin/media_ctl/linux.rs @@ -12,7 +12,7 @@ use crate::{ pub fn is_player_active(_win: &Window, _name: String, _params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request check if Player active"); + trace!("Requesting to check if player is currently active"); if let Some(player) = get_player(&mut res) { let value = player.is_running(); @@ -25,7 +25,7 @@ pub fn is_player_active(_win: &Window, _name: String, _params: &str) -> SbbwResp pub fn set_volume(_win: &Window, _name: String, params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request change volume"); + trace!("Requesting to change volume"); if let Some(volume) = get_from_str::(&mut res, params) { if let Some(player) = get_player(&mut res) { @@ -44,7 +44,7 @@ pub fn set_volume(_win: &Window, _name: String, params: &str) -> SbbwResponse { pub fn set_play_pause(_win: &Window, _name: String, params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request play/pause"); + trace!("Requesting to play/pause media"); if let Some(play) = get_from_str::(&mut res, params) { if let Some(player) = get_player(&mut res) { @@ -55,11 +55,11 @@ pub fn set_play_pause(_win: &Window, _name: String, params: &str) -> SbbwRespons res.data = "".to_string(); } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); - res.data = "Error to set play".to_string(); + res.data = "Error to send play event".to_string(); } } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); - res.data = "Cannot set play".to_string(); + res.data = "Cannot send play event".to_string(); } } else if player.can_pause().unwrap_or(false) { if player.checked_pause().is_ok_and(|v| v) { @@ -67,11 +67,11 @@ pub fn set_play_pause(_win: &Window, _name: String, params: &str) -> SbbwRespons res.data = "".to_string(); } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); - res.data = "Error to set pause".to_string(); + res.data = "Error to send pause event".to_string(); } } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); - res.data = "Cannot set pause".to_string(); + res.data = "Cannot send pause event".to_string(); } } } @@ -81,7 +81,7 @@ pub fn set_play_pause(_win: &Window, _name: String, params: &str) -> SbbwRespons pub fn set_next(_win: &Window, _name: String, _params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request next"); + trace!("Requesting next media"); if let Some(player) = get_player(&mut res) { if player.can_go_next().unwrap_or(false) { @@ -96,7 +96,7 @@ pub fn set_next(_win: &Window, _name: String, _params: &str) -> SbbwResponse { } } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); - res.data = "Error to set next".to_string(); + res.data = "Error to get next track".to_string(); } } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); @@ -109,7 +109,7 @@ pub fn set_next(_win: &Window, _name: String, _params: &str) -> SbbwResponse { pub fn set_prev(_win: &Window, _name: String, _params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request previous"); + trace!("Requesting previous media"); if let Some(player) = get_player(&mut res) { if player.can_go_previous().unwrap_or(false) { @@ -124,7 +124,7 @@ pub fn set_prev(_win: &Window, _name: String, _params: &str) -> SbbwResponse { } } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); - res.data = "Error to set next".to_string(); + res.data = "Error to get previous media".to_string(); } } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); @@ -137,7 +137,7 @@ pub fn set_prev(_win: &Window, _name: String, _params: &str) -> SbbwResponse { pub fn get_volume(_win: &Window, _name: String, _params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request change player volume"); + trace!("Requesting to change player's volume"); if let Some(player) = get_player(&mut res) { if let Ok(value) = player.get_volume() { @@ -145,7 +145,7 @@ pub fn get_volume(_win: &Window, _name: String, _params: &str) -> SbbwResponse { res.data = serde_json::to_string(&value).unwrap_or_else(|_| "0.0".to_string()); } else { res.status = StatusCode::INTERNAL_SERVER_ERROR.as_u16(); - res.data = "Cannot get volume".to_string(); + res.data = "Cannot set player's volume".to_string(); } } @@ -160,14 +160,14 @@ where Some(value) } else { res.status = StatusCode::BAD_REQUEST.as_u16(); - res.data = "Cannot get parametter".to_string(); + res.data = "Cannot get parameter".to_string(); None } } pub fn get_state(_win: &Window, _name: String, _params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request get current media player state"); + trace!("Requesting to get current media player state"); if let Some(player) = get_player(&mut res) { let state = internal_get_state(&player); diff --git a/sbbw-widget/src/builtin/widget.rs b/sbbw-widget/src/builtin/widget.rs index 4ec645b..cc91ee1 100644 --- a/sbbw-widget/src/builtin/widget.rs +++ b/sbbw-widget/src/builtin/widget.rs @@ -27,7 +27,7 @@ struct SbbwWidgetInfo { pub fn info(_win: &Window, name: String, _params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); let args = Args::parse(); - trace!("Request Widget data"); + trace!("Request widget data"); let info = SbbwWidgetInfo { name, @@ -42,7 +42,7 @@ pub fn info(_win: &Window, name: String, _params: &str) -> SbbwResponse { pub fn move_window(win: &Window, _name: String, params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request Widget move position: {:?}", params); + trace!("Request widget to move position: {:?}", params); match serde_json::from_str::(params) { Ok(value) => { @@ -55,9 +55,9 @@ pub fn move_window(win: &Window, _name: String, params: &str) -> SbbwResponse { res.data = "".to_string(); } Err(_) => { - error!("Bad params"); + error!("Invalid params"); res.status = StatusCode::BAD_REQUEST.as_u16(); - res.data = "This require X and Y as param".to_string(); + res.data = "This requires both X and Y axis coordinates to be passed as params".to_string(); } } @@ -66,7 +66,7 @@ pub fn move_window(win: &Window, _name: String, params: &str) -> SbbwResponse { pub fn resize_window(win: &Window, _name: String, params: &str) -> SbbwResponse { let mut res = SbbwResponse::default(); - trace!("Request Widget Resize: {:?}", params); + trace!("Request widget resize: {:?}", params); match serde_json::from_str::(params) { Ok(value) => { @@ -82,7 +82,7 @@ pub fn resize_window(win: &Window, _name: String, params: &str) -> SbbwResponse Err(_) => { error!("Bad params"); res.status = StatusCode::BAD_REQUEST.as_u16(); - res.data = "This require X and Y as param".to_string(); + res.data = "This requires both X and Y axis coordinates to be passed as params".to_string(); } } diff --git a/sbbw-widget/src/builtin/wifi/linux.rs b/sbbw-widget/src/builtin/wifi/linux.rs index 3e58511..60e6718 100644 --- a/sbbw-widget/src/builtin/wifi/linux.rs +++ b/sbbw-widget/src/builtin/wifi/linux.rs @@ -15,7 +15,7 @@ pub struct WirelessInfo { } pub fn get_wifi_info(_win: &Window, _name: String, ssid: &str) -> SbbwResponse { - trace!("Request get wifi information"); + trace!("Requesting wifi information"); let info = get_wireless_info(ssid.to_string()).unwrap(); let info = WirelessInfo { diff --git a/sbbw-widget/src/main.rs b/sbbw-widget/src/main.rs index 55ebe8f..a196993 100644 --- a/sbbw-widget/src/main.rs +++ b/sbbw-widget/src/main.rs @@ -97,7 +97,7 @@ fn main() { .with_ipc_handler(move |win, msg| { let mut response = SbbwResponse::default(); let params: Option = parse_params(&mut response, msg); - info!("Params from frontend parsed: {:?}", ¶ms); + info!("Frontend params have been parsed: {:?}", ¶ms); if response.status != 0 { response = process_ipc(win, widget_name.clone(), params.as_ref().unwrap()); @@ -107,7 +107,7 @@ fn main() { let webviews = ref_webview.borrow(); let webview = webviews.as_ref().unwrap(); let response_json = serde_json::to_string(&response).unwrap(); - trace!("Response for frontend: {}", &response_json); + trace!("Frontend response: {}", &response_json); let js = format!( r#"window.external.rpc._result({}, {})"#, params.unwrap().method_id, @@ -135,7 +135,7 @@ fn main() { } else { println!( "{}", - "Widget {} not found or not have config.toml file" + "Widget {} not found or doesn't have config.toml file" .red() .replace("{}", &args.widget_name.yellow().bold()) ); diff --git a/sbbw/src/cmd/args.rs b/sbbw/src/cmd/args.rs index 3c5b001..3f867ac 100644 --- a/sbbw/src/cmd/args.rs +++ b/sbbw/src/cmd/args.rs @@ -26,10 +26,10 @@ pub struct ArgOpt { #[derive(Subcommand, Debug, Clone)] pub enum WidgetCommands { - #[clap(help = "This run widget server and all features")] + #[clap(help = "This runs the widget server and all the features")] Run, Install { - #[clap(help = "Repository origin, ex: User/RepoName")] + #[clap(help = "Repo origin, ex: User/RepoName")] repo: String, #[clap(validator = validate_name_install)] new_name: Option, @@ -73,13 +73,13 @@ pub enum ShortcutsAction { List, Interactive, Add { - #[clap(help = "Action to trigger when keys has pressed")] + #[clap(help = "Action to trigger when key is pressed")] action: RpcAction, #[clap(help = "Widget to call")] widget: String, - #[clap(long, short, help = "Arguments for send to trigger")] + #[clap(long, short, help = "Arguments for sending to trigger")] widget_args: Option, - #[clap(help = "Keys to link action")] + #[clap(help = "Key to link to action")] keys: Vec, }, } @@ -107,7 +107,7 @@ fn validate_widgets(src: &str) -> Result<(), String> { Ok(()) } else { Err(format!( - "The value not in widgets installed {:?}", + "The value is not in the installed widgets {:?}", widgets.join(", ") )) } @@ -115,7 +115,7 @@ fn validate_widgets(src: &str) -> Result<(), String> { fn validate_name_install(src: &str) -> Result<(), String> { match validate_widgets(src) { - Ok(_) => Err("The widget alredy exists".to_string()), + Ok(_) => Err("This widget already exists".to_string()), Err(_) => Ok(()), } } @@ -159,6 +159,6 @@ pub fn to_request(widget_cmd: &WidgetCommands, url: String) -> Result Err("No valid Widget Command".to_string()), + _ => Err("No valid widget command".to_string()), } } diff --git a/sbbw/src/cmd/install.rs b/sbbw/src/cmd/install.rs index adde27f..e8accf5 100644 --- a/sbbw/src/cmd/install.rs +++ b/sbbw/src/cmd/install.rs @@ -99,18 +99,18 @@ pub fn install_widget(cmd: WidgetCommands) -> Result<(), String> { } else { let state = state.borrow_mut(); if let Some(pb) = &state.progress_bar { - pb.finish_with_message("Widget installed"); + pb.finish_with_message("Widget has been installed"); } autostarts(); Ok(()) } } else { - Err("Widget alredy exists".to_string()) + Err("The widget already exists".to_string()) } } else { - Err("Repo parameter has no format, check --help".to_string()) + Err("Invalid repo parameter format, check --help".to_string()) } } else { - Err("Install command is invalid, check --help".to_string()) + Err("Invalid install parameter format, check --help".to_string()) } } diff --git a/sbbw/src/keybinds/interactive.rs b/sbbw/src/keybinds/interactive.rs index 1bd7805..2cc2a09 100644 --- a/sbbw/src/keybinds/interactive.rs +++ b/sbbw/src/keybinds/interactive.rs @@ -26,7 +26,7 @@ where answer = String::from_utf8(buf[..c - 1].to_vec()).unwrap(); is_valid = validation(answer.trim()); } else { - println!("\t{}", "You need write something".magenta()); + println!("\t{}", "Please write something".magenta()); } } else { println!("\tAn error ocurred"); @@ -80,13 +80,13 @@ pub fn get_keys(conf: &SbbwConfig) -> Vec { pub fn get_shortcut_interactive(conf: &SbbwConfig) -> KeyboardShortcuts { let (names, _): (Vec, Vec) = get_widgets().into_iter().unzip(); - println!("{}\n", "Starting to get shortcuts".cyan()); + println!("{}\n", "Start receiving shortcuts".cyan()); let action = ask::("Action to be taken [open|close|toggle|test]", is_rpc_action).unwrap(); let keys = get_keys(conf); - let name = ask::("Which widget do we call?", |a| is_widget(a, &names)).unwrap(); + let name = ask::("Which widget should sbbw call?", |a| is_widget(a, &names)).unwrap(); let url: Option = ask::( - "You have your own url (perfect for testing, this is optional, you can leave it empty)", + "Do you have your own url? (perfect for testing, optional field so you can leave it empty)", |_| true, ) .ok(); diff --git a/sbbw/src/keybinds/mod.rs b/sbbw/src/keybinds/mod.rs index 64aa4a0..9295acd 100644 --- a/sbbw/src/keybinds/mod.rs +++ b/sbbw/src/keybinds/mod.rs @@ -48,5 +48,5 @@ fn add_shortcut(conf: &mut SbbwConfig, shortcut: KeyboardShortcuts) { println!("\n\t{}", "Cannot update your configuration".red()); std::process::exit(1); } - println!("\n\t{}", "Succes add the shortcut".green()); + println!("\n\t{}", "Shortcut added successfully".green()); } diff --git a/sbbw/src/main.rs b/sbbw/src/main.rs index 986157f..6e897c6 100644 --- a/sbbw/src/main.rs +++ b/sbbw/src/main.rs @@ -58,7 +58,7 @@ fn main() { Err(e) => { println!( "{} reason: {:?}", - "Binary for launch Widgets not found".red().bold(), + "sbbw-widget binary not found, cannot launch widgets".red().bold(), e ); } @@ -77,7 +77,7 @@ fn main() { Err(_) => { println!("Generating default config file"); let cfg = SbbwConfig::default(); - generate_config_sbbw(cfg.clone()).expect("Failed generating config File"); + generate_config_sbbw(cfg.clone()).expect("Failed while generating default config file"); Some(cfg) } }; @@ -88,7 +88,7 @@ fn main() { let s = System::new_all(); let processes = s.processes_by_exact_name("sbbw"); if processes.count() > 1 { - println!("{}", "Other Sbbw Daemon is running".red().bold()); + println!("{}", "Another instance of Sbbw Daemon is running".red().bold()); std::process::exit(1); } } @@ -129,7 +129,7 @@ fn main() { Ok(_) => { println!( "{}", - "Config of widget {} is valid" + "{} widget configuration is valid" .green() .replace("{}", &widget_name.yellow().bold()) ); @@ -138,7 +138,7 @@ fn main() { error!("Error on check config {e}"); println!( "{}", - "Config of widget {} is not valid" + "Invalid widget configuration for {} " .red() .replace("{}", &widget_name.yellow().bold()) ); @@ -157,7 +157,7 @@ fn main() { service: service.to_owned(), }) { Err(e) => println!("{e}"), - Ok(_) => println!("Success Widget installed"), + Ok(_) => println!("Widget installed successfully"), } } WidgetCommands::Shortcuts { action } => process_arg(conf.as_mut().unwrap(), action), @@ -171,16 +171,16 @@ fn main() { match actix_rt::System::new().block_on(post) { Ok(res) => { if !res.status().is_success() { - println!("Cannot comunicate with daemon"); + println!("Cannot communicate with the daemon"); } else { std::process::exit(1); } } - Err(e) => println!("Error calling daemon: {}", e), + Err(e) => println!("Error while calling the daemon: {}", e), } } Err(e) => { - error!("Failed map request: {e}") + error!("Failed to map request: {e}") } }, }; diff --git a/sbbw/src/widget/internal.rs b/sbbw/src/widget/internal.rs index 484cda9..106422e 100644 --- a/sbbw/src/widget/internal.rs +++ b/sbbw/src/widget/internal.rs @@ -41,7 +41,7 @@ fn loop_listen_keybinds(cfg: SbbwConfig) { }) .collect::, String, Vec)>>(); - trace!("Starting listen keybinds"); + trace!("Starting keybind listening"); loop { let keys = device_state.get_keys(); if keys.is_empty() { @@ -92,8 +92,8 @@ pub fn open_widget( ) -> Result<(), String> { let (name, _) = widget_data; if widgets.contains_key(name) { - warn!("[{}] Widget alredy opened", "Daemon".green().bold()); - return Err(format!("Widget {} already opened", name)); + warn!("[{}] Widget is already open", "Daemon".green().bold()); + return Err(format!("Widget {} is already up", name)); } trace!("[{}] Open: {:?}", "Daemon".green().bold(), name); let file = OpenOptions::new() @@ -122,7 +122,7 @@ pub fn open_widget( { Ok(subprocess) => { trace!( - "[{}] Widget \"{:?}\" added to opens", + "[{}] Widget \"{:?}\" is now up and has been added to the open widgets list", "Daemon".green().bold(), name ); @@ -138,15 +138,15 @@ pub fn close_widget( widget_data: &(String, Option), ) -> Result<(), String> { if !widgets.contains_key(&widget_data.0) { - log::error!("[{}] Widget not before open", "Daemon".green().bold()); - return Err("Widget not before open".to_string()); + log::error!("The widget [{}] hasn't been started", "Daemon".green().bold()); + return Err("Widget hasn't been started".to_string()); } trace!("[{}] Close: {:?}", "Daemon".green().bold(), widget_data.0); if let Some(mut subprocess) = widgets.remove(&widget_data.0) { subprocess.kill().unwrap(); drop(subprocess); trace!( - "[{}] Widget process \"{:?}\" droped", + "[{}] Widget process \"{:?}\" has been dropped", "Daemon".green().bold(), widget_data.0 ); @@ -162,15 +162,15 @@ pub fn toggle_widget( url: Option, ) -> Result<(), String> { trace!( - "[{}] Toggle widget \"{:?}\"", + "[{}] Toggling widget \"{:?}\"", "Daemon".green().bold(), widget_data.0 ); if !widgets.contains_key(&widget_data.0) { - trace!("[{}] Toggle widget (Open) ", "Daemon".green().bold()); + trace!("[{}] Toggling widget (Open) ", "Daemon".green().bold()); open_widget(widgets, widget_data, action, widget_params, url) } else { - trace!("[{}] Toggle widget (Close)", "Daemon".green().bold()); + trace!("[{}] Toggling widget (Closed)", "Daemon".green().bold()); close_widget(widgets, widget_data) } } diff --git a/sbbw/src/widget/rpc.rs b/sbbw/src/widget/rpc.rs index 81a9379..e055bb7 100644 --- a/sbbw/src/widget/rpc.rs +++ b/sbbw/src/widget/rpc.rs @@ -49,7 +49,7 @@ fn open_widget_rpc( data: Json, ) -> HttpResponse { info!( - "[{}] Current widgets openned: {:?}", + "[{}] Current opened widgets: {:?}", "Daemon".green().bold(), widgets ); @@ -76,7 +76,7 @@ fn close_widget_rpc( data: Json, ) -> HttpResponse { info!( - "[{}] Current widgets openned: {:?}", + "[{}] Current opened widgets: {:?}", "Daemon".green().bold(), widgets ); @@ -97,7 +97,7 @@ fn toggle_widget_rpc( data: Json, ) -> HttpResponse { info!( - "[{}] Current widgets openned: {:?}", + "[{}] Current opened widgets: {:?}", "Daemon".green().bold(), widgets ); diff --git a/sbbw_node/package.json b/sbbw_node/package.json index 8d4b633..1f04988 100644 --- a/sbbw_node/package.json +++ b/sbbw_node/package.json @@ -1,7 +1,7 @@ { "name": "@sbbw/api", "version": "0.0.6", - "description": "Types for create widgets using sbbw", + "description": "Types for creating sbbw widgets", "repository": "https://github.com/SergioRibera/sbbw", "author": "SergioRibera", "license": "MIT", diff --git a/sbbw_node/src/media.ts b/sbbw_node/src/media.ts index cadc199..c2c1fc7 100644 --- a/sbbw_node/src/media.ts +++ b/sbbw_node/src/media.ts @@ -1,86 +1,88 @@ -import { invoke } from "./sbbw" +import { invoke } from "./sbbw"; type SbbwMediaMetadata = { - /* - * The track ID - */ - track_id: string, - /* - * The track name - */ - title: string, - /* - * The name of the album the track appears on - */ - album_name: string, - /* - * A list of artists of the album the track appears on - */ - album_artists: Array, - /* - * A list of artists of the track - */ - artists: Array, - /* - * An URL to album art of the current track - */ - art_url: string | null, - /* - * The duration of the track, in microseconds - */ - track_length: number | null, -} + /* + * The track ID + */ + track_id: string; + /* + * The track name + */ + title: string; + /* + * The name of the album on which the track appears + */ + album_name: string; + /* + * A list of artists on the album where the track appears + */ + album_artists: Array; + /* + * A list of artists for the track + */ + artists: Array; + /* + * A URL to the album art of the current track + */ + art_url: string | null; + /* + * The track duration, in microseconds + */ + track_length: number | null; +}; type SbbwMediaState = { - /* - * Id of player, (usually something like :1.1337) - * > Note: Only on linux - */ - id: string, - /* - * This is usually the application's name, like Spotify - */ - player_name: string, - /* - * This contains data for current player an track - */ - metadata: SbbwMediaMetadata | null, - /* - * A player volume - * Volume should be between 0.0 and 1.0 - */ - volume: number | null, - /* - * Track progress on microseconds - */ - track_progress: number, - /* - * True if the player has enable the "Shuffle" mode - */ - shuffle: boolean, -} - + /* + * Player Id, (e.g. 1.1337) + * > Note: Linux-only + */ + id: string; + /* + * Application's name (e.g. Spotify) + */ + player_name: string; + /* + * This contains the metadata for the current media player and playing track + */ + metadata: SbbwMediaMetadata | null; + /* + * Player volume + * Volume should be between 0.0 and 1.0 + */ + volume: number | null; + /* + * Track progress in microseconds + */ + track_progress: number; + /* + * True if player has enabled the "Shuffle" mode + */ + shuffle: boolean; +}; const setPlayPause = (play_pause: boolean): Promise => - invoke("media.play_pause", play_pause) + invoke("media.play_pause", play_pause); -const setNext = (): Promise => - invoke("media.next", null) +const setNext = (): Promise => invoke("media.next", null); -const setPrev = (): Promise => - invoke("media.prev", null) +const setPrev = (): Promise => invoke("media.prev", null); const setVolume = (volume: number): Promise => - invoke("media.set_volume", volume) + invoke("media.set_volume", volume); -const getState = (): Promise => - invoke("media.state", null) +const getState = (): Promise => invoke("media.state", null); -const getVolume = (): Promise => - invoke("media.get_volume", null) +const getVolume = (): Promise => invoke("media.get_volume", null); -const isPlayerActive = (): Promise => - invoke("media.active", null) +const isPlayerActive = (): Promise => invoke("media.active", null); -export type { SbbwMediaState, SbbwMediaMetadata } -export { setPlayPause, setNext, setPrev, setVolume, getState, getVolume, isPlayerActive } +export type { SbbwMediaState, SbbwMediaMetadata }; +export { + setPlayPause, + setNext, + setPrev, + setVolume, + getState, + getVolume, + isPlayerActive, +}; diff --git a/sbbw_node/src/sysinfo.ts b/sbbw_node/src/sysinfo.ts index 0fbe29b..351532e 100644 --- a/sbbw_node/src/sysinfo.ts +++ b/sbbw_node/src/sysinfo.ts @@ -1,202 +1,207 @@ -import { invoke } from "./sbbw" +import { invoke } from "./sbbw"; type SbbwSysInfo = { - /** - * Returns the system hostname based off DNS - */ - hostname: string, - /** - * Returns system uptime (in seconds) - */ - uptime: number, - /** - * Returns the system’s kernel version - */ - kernel_version: string, - /** - * Returns the system version (e.g. for MacOS this will return 11.1 rather than the kernel version) - */ - os_version: string, - /** - * Returns the system long os version (e.g “MacOS 11.2 BigSur”) - */ - long_os_version: string, - /** - * - */ - users: Array, -} + /** + * Returns the system hostname based out of the DNS + */ + hostname: string; + /** + * Returns system uptime (in seconds) + */ + uptime: number; + /** + * Returns the system’s kernel version + */ + kernel_version: string; + /** + * Returns the system version (e.g. for MacOS this will return 11.1 rather than the kernel version) + */ + os_version: string; + /** + * Returns the system long os version (e.g “MacOS 11.2 BigSur”) + */ + long_os_version: string; + /** + * + */ + users: Array; +}; type SbbwSysInfoUser = { - /** - * Return the user id of the user - */ - id: string, - /** - * Return the group id of the user - * > Note: On Windows, this value defaults to 0. Windows doesn’t have a username specific group assigned to the user - */ - group_id: string, - /** - * Returns the name of the user - */ - name: string, - /** - * Returns the groups of the user - */ - groups: Array, -} + /** + * Return the user's id + */ + id: string; + /** + * Return the group id of the user + * > Note: On Windows, this value defaults to 0. Windows doesn’t have a username specific group assigned to the user + */ + group_id: string; + /** + * Returns the name of the user + */ + name: string; + /** + * Returns the groups of the user + */ + groups: Array; +}; type SbbwSysInfoDisk = { - /** - * Returns the disk name - */ - name: string, - /** - * Returns the total disk size, in bytes - */ - total_space: number, - /** - * Returns the available disk size, in bytes - */ - free_space: number, - /** - * Returns true if the disk is removable - */ - is_removable: boolean, - /** - * Returns the mount point of the disk - */ - mount_point: string, - /** - * Returns the file system used on this disk - */ - file_system: string, -} + /** + * Returns the disk name + */ + name: string; + /** + * Returns the total disk size, in bytes + */ + total_space: number; + /** + * Returns the available disk size, in bytes + */ + free_space: number; + /** + * Returns true if the disk is removable + */ + is_removable: boolean; + /** + * Returns the mount point of the disk + */ + mount_point: string; + /** + * Returns the file system used on this disk + */ + file_system: string; +}; type SbbwSysInfoNetwork = { - /** - * Returns the name of Network interface - */ - name: string, - /** - * Returns the number of received bytes - */ - received: number, - /** - * Returns the total number of received bytes - */ - total_received: number, - /** - * Returns the number of transmitted bytes - */ - transmitted: number, - /** - * Returns the total number of transmitted bytes - */ - total_transmitted: number, - /** - * Returns the number of incoming packets - */ - packets_received: number, - /** - * Returns the total number of incoming packets - */ - total_packets_received: number, - /** - * Returns the number of outcoming packets - */ - packets_transmitted: number, - /** - * Returns the total number of outcoming packets - */ - total_packets_transmitted: number, - /** - * Returns the number of incoming errors since the last refresh - */ - errors_on_received: number, - /** - * Returns the total number of incoming errors - */ - total_errors_on_received: number, - /** - * Returns the number of outcoming errors since the last refresh - */ - errors_on_transmitted: number, - /** - * Returns the total number of outcoming errors - */ - total_errors_on_transmitted: number, -} + /** + * Returns the name of Network interface + */ + name: string; + /** + * Returns the number of received bytes + */ + received: number; + /** + * Returns the total number of received bytes + */ + total_received: number; + /** + * Returns the number of transmitted bytes + */ + transmitted: number; + /** + * Returns the total number of transmitted bytes + */ + total_transmitted: number; + /** + * Returns the number of incoming packets + */ + packets_received: number; + /** + * Returns the total number of incoming packets + */ + total_packets_received: number; + /** + * Returns the number of outcoming packets + */ + packets_transmitted: number; + /** + * Returns the total number of outcoming packets + */ + total_packets_transmitted: number; + /** + * Returns the number of incoming errors since the last refresh + */ + errors_on_received: number; + /** + * Returns the total number of incoming errors + */ + total_errors_on_received: number; + /** + * Returns the number of outcoming errors since the last refresh + */ + errors_on_transmitted: number; + /** + * Returns the total number of outcoming errors + */ + total_errors_on_transmitted: number; +}; type SbbwSysInfoMemory = { - /** - * Returns the RAM size in KB - */ - total: number, - /** - * Returns the amount of free RAM in KB - */ - free: number, - /** - * Returns the amount of available RAM in KB - */ - aviable: number, - /** - * Returns the amount of used RAM in KB - */ - used: number, - /** - * Returns the SWAP size in KB - */ - swap_total: number, - /** - * Returns the amount of free SWAP in KB - */ - swap_free: number, - /** - * Returns the amount of used SWAP in KB - */ - swap_used: number, -} + /** + * Returns the RAM size in KB + */ + total: number; + /** + * Returns the amount of free RAM in KB + */ + free: number; + /** + * Returns the amount of available RAM in KB + */ + aviable: number; + /** + * Returns the amount of used RAM in KB + */ + used: number; + /** + * Returns the SWAP size in KB + */ + swap_total: number; + /** + * Returns the amount of free SWAP in KB + */ + swap_free: number; + /** + * Returns the amount of used SWAP in KB + */ + swap_used: number; +}; type SbbwSysInfoCpu = { - /** - * Returns this CPU’s usage - */ - cpu_usage: number, - /** - * Returns this CPU’s name - */ - name: string, - /** - * Returns the CPU’s vendor id - */ - vendor_id: string, - /** - * Returns the CPU’s brand - */ - brand: string, - /** - * Returns the CPU’s frequency - */ - frequency: number, -} + /** + * Returns this CPU’s usage + */ + cpu_usage: number; + /** + * Returns this CPU’s name + */ + name: string; + /** + * Returns the CPU’s vendor id + */ + vendor_id: string; + /** + * Returns the CPU’s brand + */ + brand: string; + /** + * Returns the CPU’s frequency + */ + frequency: number; +}; const getAllDisks = (): Promise> => - invoke("sys.disks", null) + invoke("sys.disks", null); const getAllNetworks = (): Promise> => - invoke("sys.net", null) + invoke("sys.net", null); -const getSysInfo = (): Promise> => - invoke("sys.info", null) +const getSysInfo = (): Promise> => invoke("sys.info", null); const getMemory = (): Promise> => - invoke("sys.memory", null) + invoke("sys.memory", null); -const getCpu = (): Promise> => - invoke("sys.cpu", null) +const getCpu = (): Promise> => invoke("sys.cpu", null); -export type { SbbwSysInfo, SbbwSysInfoUser, SbbwSysInfoDisk, SbbwSysInfoNetwork, SbbwSysInfoMemory, SbbwSysInfoCpu } -export { getAllDisks, getAllNetworks, getSysInfo, getMemory, getCpu } +export type { + SbbwSysInfo, + SbbwSysInfoUser, + SbbwSysInfoDisk, + SbbwSysInfoNetwork, + SbbwSysInfoMemory, + SbbwSysInfoCpu, +}; +export { getAllDisks, getAllNetworks, getSysInfo, getMemory, getCpu }; diff --git a/setup/setup.bat b/setup/setup.bat index 790ba55..962cdbb 100644 --- a/setup/setup.bat +++ b/setup/setup.bat @@ -3,7 +3,7 @@ goto check_Permissions :check_Permissions - echo Administrative permissions required. Detecting permissions... + echo Run as administrator. Detecting permissions... net session >nul 2>&1 if not %errorLevel% == 0 ( @@ -20,7 +20,7 @@ echo Installing sbbw timeout /t 2 > NUL if exist "%PATH_TO_INSTALL%\sbbw.exe" ( - echo sbbw already installed + echo sbbw is already installed echo Updating sbbw ) if not exist "%CURRENT_DIR%\sbbw.exe" ( @@ -47,6 +47,6 @@ copy "%CURRENT_DIR%\sbbw-widget.exe" "%PATH_TO_INSTALL%" echo [ OK ] Sbbw Installed timeout /t 2 > NUL -echo [ OK ] Done, you can close this +echo [ OK ] Done, now you can close this pause >nul diff --git a/setup/setup.sh b/setup/setup.sh index bd4aa48..7adeb21 100755 --- a/setup/setup.sh +++ b/setup/setup.sh @@ -9,7 +9,7 @@ NC='\033[0m' # No Colors PATH_TO_INSTALL="/usr/local/bin" if [[ $(id -u) -ne 0 ]]; then - echo -e "${RED}Please run as root${NC}" + echo -e "${RED}Please run this script with root privileges${NC}" exit 1 fi @@ -17,7 +17,7 @@ echo -e "${BLUE}Installing sbbw${NC}" sleep 2 if [[ -f "$PATH_TO_INSTALL/sbbw" ]]; then - echo -e "${RED}sbbw already installed${NC}" + echo -e "${RED}sbbw is already installed${NC}" echo -e "${BLUE}Updating ...${NC}" fi @@ -32,12 +32,12 @@ fi chmod +x sbbw chmod +x sbbw-widget -echo -e "[ ${GREEN}✓${NC} ] ${GREEN}Made executable${NC}" +echo -e "[ ${GREEN}✓${NC} ] ${GREEN}executable created${NC}" sleep 2 cp {sbbw,sbbw-widget} $PATH_TO_INSTALL -echo -e "[ ${GREEN}✓${NC} ] ${GREEN}Sbbw Installed${NC}" +echo -e "[ ${GREEN}✓${NC} ] ${GREEN}Sbbw is now installed${NC}" sleep 2 echo -e "[ ${GREEN}✓${NC} ] ${GREEN}Done${NC}"