RustyBun is a clipboard management tool designed to streamline your workflow by providing convenient access to copied items. With RustyBun, users can easily access a history of copied text, eliminating the need to switch between multiple applications or re-copy content
(Currently only for Debian-based distros) Use the .deb file and install it on your Debian system.
Inspired by the Windows clipboard, the awesome devs of Rust, and Stranger Things' Dusty Bun, RustyBun aims to bring you ease of use and the ability to have multiple copied texts available to you at one click. The structure consists of three parts: Rust Backend, Electron GUI, and the build folder.
Rust Backend is the main logic for taking stuff from the x11-clipboard and saving it in the clipboard.json file. I chose to save the copied text in a file as I needed the feature for sudden crashes of devices so that the copied text remains. It also uses serde to handle JSON files.
-
main:
- The execution starts here.
- It checks if the folder
/home/ritu/Documents/RustyBunis present or not. If not, it creates this folder. - It initializes the clipboard, runs an infinite loop to track clipboard changes, and handles appending data to
clipboard.json. - It also checks if the created JSON is valid. If it's not, it simply clears the
clipboard.jsonand increments the counter.
-
load_id_counter:
- It takes the latest ID of the entry in the JSON.
- This is used to keep track of the number of entries done to the clipboard.
- When the counter reaches 200, the JSON is purged on the next start of the application, and a fresh clipboard is given.
-
save_id_counter:
- It saves the latest ID in the
id_counter.txtfile. - If the file does not exist, it creates the file and then puts the value.
- Else, it removes the data from the file and enters the latest value.
- It saves the latest ID in the
-
append_to_json:
- This is the most important function of the Rust part of the code.
- It checks if the clipboard is present in the location
/home/<user>/Documents/RustyBun/clipboard.jsonas an absolute path. - If it is not present, it creates the file and puts an empty JSON.
- It then opens the file and parses it to convert it to JSON.
- It creates a new entry from the value received by it from the main function and parses the new JSON after appending the new value to the old JSON and then clears the file to write the new JSON.
-
main:
- It reads the file in the
main.jsitself and sends data to the mainWindow renderer and if there is any change in the file then also sends that data. - It also tries to hide the menu with unnecessary features.
- If we try to read the clipboard in renderer if rails to read due to some issue.
- It reads the file in the
-
style.css:
- Handles all the styling details.
-
renderer:
- First, we try to run the binary file that is generated by building the Rust part as a spawn which uses a new thread apparently.
- Whenever there is any console changes, it prints the console of the program.
ipcRendererrenders the GUI boxes based on theclipboard.jsondata provided.- Whenever the mouse is near the top of the menu, it unhides the menu.
renderJSONrenders the basic window and the boxes.- Loops through each object in the JSON data in reverse order creates new boxes for the JSON and re-sends them to the DOM forcing it to re-render.
- build.sh:
- The build folder has the build script so if you want to build the application from the repository you could simply run the
./build.sh.
- The build folder has the build script so if you want to build the application from the repository you could simply run the
Contributions and feedback are greatly appreciated! Please create a new topic/issue for them.
Run sudo dpkg -r rustybun in terminal
- Use Ctrl+V or Win+V (V1.1.0)
- Add an option to start the program at startup (V1.1.0)
- Build for windows and other linux distros
- Make the path for
clipboard.jsondynamic for each user. - Handle opening of multiple instances better or altogether stop multiple instances from opening. If multiple instances are opened, the
clipboard.jsonfile is overwritten by both instances, causing invalid JSON. - Make sure that the full menu is not visible at startup.
- Make sure that the zoom features work.
- Consider removing
id_counter.txtas it does not serve a lot of purpose (if I can read the latest ID in the JSON). - Add a preference menu to change the color scheme.
- Add a clear option to the clipboard.
- Add a clear option to each entry/box.
- Error handled in line 51-65 of
backend/src/main.rscan be handled in code line 153 (serde_json::from_str(&json_data)) as the JSON becomes invalid when checked here and Rust panics. - Give the user the option to set the cleanup limit for clipboard entries.
- Install Rust
- Versions:
- rustup 1.27.1
- cargo 1.78.0
- clone backend
- cargo run to check
- cargo build --release to get Binary file in target/release/clip_cpy
- the crashes in the rust part might happen due to bad formatting of JSON
- println! prints to stdout in rust so the renderer.js in GUI can read it print it in our console if needed
- Make sure that the absolute path set in the clipboard.json and id_counter are to your username
- setup electron https://www.electronjs.org/docs/latest/tutorial/tutorial-first-app
- setup electron builder
- Versions:
- npm -v 10.5.2
- npm -v 10.5.2
- electron : ^30.0.4
- electron-builder : ^24.13.3
- npm run dist:linux to build .deb in dist
- the copying may fail if focus is gone from the window
- the need for external json is that once packaged the files become read-only, we cant change permission from inside application
- the icon needs to be icns in linux too, my build path is root hence I place it there
- take care to add extraFiles and icon in package.json
- to trouble shoot you can run the clip_cpy and rustybun binaries after installation from /opt/rustybun
- to enable console uncomment
mainWindow.webContents.openDevTools();in main.js
