Skip to content

Commit

Permalink
Merge pull request #3 from like-engels/feature/improve-localization
Browse files Browse the repository at this point in the history
Improve localizations & translations.
  • Loading branch information
SergioRibera authored Feb 25, 2024
2 parents f294b85 + 7dbfe34 commit 9b75709
Show file tree
Hide file tree
Showing 23 changed files with 452 additions and 428 deletions.
24 changes: 16 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -40,6 +46,7 @@ OPTIONS:
```

New:

```sh
sbbw 0.1.3
Sergio Ribera
Expand Down Expand Up @@ -69,5 +76,6 @@ SUBCOMMANDS:
```

### TODO

- Add event callbacks api
- implement media controller built-in
- implement built-in media controller
9 changes: 5 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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
114 changes: 60 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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<AutoStartCommand>
Expand All @@ -127,56 +133,56 @@ 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<AutoStartCommand> | 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<AutoStartCommand> | 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" ] },
{ cmd = "python", args = [ "main.py" ] },
]
```

**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)
56 changes: 29 additions & 27 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -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~~
2 changes: 1 addition & 1 deletion sbbw-exec/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn generate_hash_from_file(path: PathBuf) -> Result<String, Box<dyn Error>> {
}

pub fn exec_command(pwd: String, params: Vec<String>) -> Result<String, String> {
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("./") {
Expand Down
4 changes: 2 additions & 2 deletions sbbw-widget-conf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn validate_config_from_string(config: &str) -> Result<WidgetConfig, String> {
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
)),
Expand All @@ -38,7 +38,7 @@ pub fn exits_widget(widget_name: String) -> bool {
pub fn validate_config_toml(conf_path: PathBuf) -> Result<WidgetConfig, String> {
if !conf_path.exists() {
return Err(format!(
"[{}] Config file for window not found: {}",
"[{}] window config file not found: {}",
"Error".red().bold(),
conf_path.display()
));
Expand Down
Loading

0 comments on commit 9b75709

Please sign in to comment.