Merge remote-tracking branch 'upstream/main' into simple_additions

This commit is contained in:
Liam 2024-08-15 23:54:56 -07:00
commit e197bcf23d
No known key found for this signature in database
23 changed files with 229 additions and 34 deletions

56
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,56 @@
# Contributing Guidelines for Linutil
Thank you for considering contributing to Linutil! We appreciate your effort in helping improve this project. To ensure that your contributions align with the goals and quality standards of Linutil, please follow these guidelines:
## 1. Setting Up Your Development Environment
1. **Clone the repo**: Start by cloning the Linutil repository to your local machine.
```bash
git clone https://github.com/christitustech/linutil.git
cd linutil
```
2. **Install Rust**: Make sure you have Rust installed on your machine. If you don't, you can install it by following the instructions at [rust-lang.org](https://www.rust-lang.org/tools/install).
3. **Edit the files you want to change**: Make your changes to the relevant files.
4. **Test your changes**: Run `cargo run` to test your modifications in a local environment and ensure everything works as expected.
## 2. Make Meaningful Changes
- **Have a clear reason**: Dont change the way things are done without a valid reason. If you propose an alteration, be prepared to explain why its necessary and how it improves the project.
- **Respect existing conventions**: Changes should align with the existing code style, design patterns, and overall project philosophy. If you want to introduce a new way of doing things, justify it clearly.
## 3. Learn from Past Pull Requests (PRs)
- **Check merged PRs**: Reviewing merged pull requests can give you an idea of what kind of contributions are accepted and how they are implemented.
- **Study rejected PRs**: This is especially important as it helps you avoid making similar mistakes or proposing changes that have already been considered and declined.
## 4. Write Clean, Descriptive Commit Messages
- **Be descriptive**: Your commit messages should clearly describe what the change does and why it was made.
- **Use the imperative mood**: For example, "Add feature X" or "Fix bug in Y", rather than "Added feature X" or "Fixed bug in Y".
- **Keep commits clean**: Avoid committing a change and then immediately following it with a fix for that change. Instead, amend your commit or squash it if needed.
## 5. Keep Your Pull Requests (PRs) Small and Focused
- **Make small, targeted PRs**: Focus on one feature or fix per pull request. This makes it easier to review and increases the likelihood of acceptance.
- **Avoid combining unrelated changes**: PRs that tackle multiple unrelated issues are harder to review and might be rejected because of a single problem.
## 6. Code Review and Feedback
- **Expect feedback**: PRs will undergo code review. Be open to feedback and willing to make adjustments as needed.
- **Participate in reviews**: If you feel comfortable, review other contributors' PRs as well. Peer review is a great way to learn and ensure high-quality contributions.
## 7. Contributing Is More Than Just Code
- **Test the tool**: Running tests and providing feedback on how the tool works in different environments is a valuable contribution.
- **Write well-formed issues**: Clearly describe bugs or problems you encounter, providing as much detail as possible, including steps to reproduce the issue.
- **Propose reasonable feature requests**: When suggesting new features, ensure they fit within the scope, style, and design of the project. Provide clear reasoning and use cases.
## 8. Documentation
- **Update the documentation**: If your change affects the functionality, please update the relevant documentation files to reflect this.
## 9. License
- **Agree to the license**: By contributing to Linutil, you agree that your contributions will be licensed under the project's MIT license.
We appreciate your contributions and look forward to collaborating with you to make Linutil better!

View File

@ -5,27 +5,34 @@
![Preview](docs/assets/preview.png)
A distro-agnostic* toolbox which helps with everyday Linux tasks. It can help you set up applications and your system for specific use cases! Written with Rust 🦀
**Linutil** is a distro-agnostic toolbox designed to simplify everyday Linux tasks. It helps you set up applications and optimize your system for specific use cases. The utility is actively developed in Rust 🦀, providing performance and reliability.
\* — The project is in active development, so there could be some issues. Please consider [submitting feedback](https://github.com/ChrisTitusTech/linutil/issues).
*Note:* Since the project is still in active development, you may encounter some issues. Please consider [submitting feedback](https://github.com/ChrisTitusTech/linutil/issues) if you do.
## 💡 Usage
Open your terminal and paste this command:
To get started, open your terminal and run the following command:
```bash
curl -fsSL https://christitus.com/linux | sh
```
## 💖 Support
If you find Linutil helpful, please consider giving it a ⭐️ to show your support!
## 🎓 Documentation
### [LinUtil Official Documentation](https://christitustech.github.io/linutil/)
## 💖 Support
To morally and mentally support the project, make sure to leave a ⭐️!
For comprehensive information on how to use Linutil, visit the [Linutil Official Documentation](https://christitustech.github.io/linutil/).
## 🏅 Thanks to all Contributors
Thanks a lot for spending your time helping Linutil grow. Keep rocking 🍻.
## 🛠 Contributing
We welcome contributions from the community! Before you start, please review our [Contributing Guidelines](CONTRIBUTING.md) to understand how to make the most effective and efficient contributions.
## 🏅 Thanks to All Contributors
Thank you to everyone who has contributed to the development of Linutil. Your efforts are greatly appreciated, and youre helping make this tool better for everyone!
[![Contributors](https://contrib.rocks/image?repo=ChrisTitusTech/linutil)](https://github.com/ChrisTitusTech/linutil/graphs/contributors)
## Credits
Rust Shell written by [@JustLinuxUser](https://github.com/JustLinuxUser)
## 📜 Credits
Linutils Rust shell was developed by [@JustLinuxUser](https://github.com/JustLinuxUser).

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

@ -1,3 +0,0 @@
# Update Log
#

View File

@ -5,7 +5,6 @@ nav:
- Introduction: 'index.md'
- User Guide: 'userguide.md'
- Contribute: 'contribute.md'
- Updates: 'updates.md'
- Known Issues: 'KnownIssues.md'
- FAQ: 'faq.md'

View File

@ -7,7 +7,7 @@ setupAlacritty() {
if ! command_exists alacritty; then
case ${PACKAGER} in
pacman)
sudo ${PACKAGER} -S --noconfirm alacritty
sudo ${PACKAGER} -S --needed --noconfirm alacritty
;;
*)
sudo ${PACKAGER} install -y alacritty

View File

@ -13,7 +13,7 @@ setupDWM() {
echo "Installing DWM-Titus if not already installed"
case "$PACKAGER" in # Install pre-Requisites
pacman)
sudo "$PACKAGER" -S --noconfirm --needed base-devel libx11 libxinerama libxft imlib2
sudo "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2
;;
*)
sudo "$PACKAGER" install -y build-essential libx11-dev libxinerama-dev libxft-dev libimlib2-dev

View File

@ -7,7 +7,7 @@ setupKitty() {
if ! command_exists kitty; then
case ${PACKAGER} in
pacman)
sudo "${PACKAGER}" -S --noconfirm kitty
sudo "${PACKAGER}" -S --needed --noconfirm kitty
;;
*)
sudo "${PACKAGER}" install -y kitty

View File

@ -7,7 +7,7 @@ setupRofi() {
if ! command_exists rofi; then
case "$PACKAGER" in
pacman)
sudo "$PACKAGER" -S --noconfirm rofi
sudo "$PACKAGER" -S --needed --noconfirm rofi
;;
*)
sudo "$PACKAGER" install -y rofi

View File

@ -8,7 +8,7 @@ install_zsh() {
if ! command_exists zsh; then
case "$PACKAGER" in
pacman)
sudo "$PACKAGER" -Sy --noconfirm zsh
sudo "$PACKAGER" -S --needed --noconfirm zsh
;;
*)
sudo "$PACKAGER" install -y zsh

View File

@ -7,7 +7,7 @@ installPkg() {
if ! command_exists ufw; then
case ${PACKAGER} in
pacman)
sudo "${PACKAGER}" -Sy --noconfirm ufw
sudo "${PACKAGER}" -S --needed --noconfirm ufw
;;
*)
sudo "${PACKAGER}" install -y ufw

View File

@ -33,13 +33,13 @@ installDepend() {
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
echo "[multilib]" | sudo tee -a /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf
sudo "$PACKAGER" -Sy
sudo "$PACKAGER" -Syu
else
echo "Multilib is already enabled."
fi
if ! command_exists yay && ! command_exists paru; then
echo "Installing yay as AUR helper..."
sudo "$PACKAGER" --noconfirm -S base-devel
sudo "$PACKAGER" -S --needed --noconfirm base-devel
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R "$USER":"$USER" ./yay-git
cd yay-git && makepkg --noconfirm -si
else
@ -53,7 +53,7 @@ installDepend() {
echo "No AUR helper found. Please install yay or paru."
exit 1
fi
"$AUR_HELPER" --noconfirm -S "$DEPENDENCIES"
"$AUR_HELPER" -S --needed --noconfirm "$DEPENDENCIES"
;;
apt-get|nala)
COMPILEDEPS='build-essential'

View File

@ -9,13 +9,13 @@ installDepend() {
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
echo "[multilib]" | sudo tee -a /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf
sudo ${PACKAGER} -Sy
sudo ${PACKAGER} -Syu
else
echo "Multilib is already enabled."
fi
if ! command_exists yay && ! command_exists paru; then
echo "Installing yay as AUR helper..."
sudo ${PACKAGER} --noconfirm -S base-devel
sudo ${PACKAGER} -S --needed --noconfirm base-devel
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git
cd yay-git && makepkg --noconfirm -si
else
@ -29,7 +29,7 @@ installDepend() {
echo "No AUR helper found. Please install yay or paru."
exit 1
fi
${AUR_HELPER} --noconfirm -S wine giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap gnutls lib32-gnutls \
${AUR_HELPER} -S --needed --noconfirm wine giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap gnutls lib32-gnutls \
mpg123 lib32-mpg123 openal lib32-openal v4l-utils lib32-v4l-utils libpulse lib32-libpulse libgpg-error \
lib32-libgpg-error alsa-plugins lib32-alsa-plugins alsa-lib lib32-alsa-lib libjpeg-turbo lib32-libjpeg-turbo \
sqlite lib32-sqlite libxcomposite lib32-libxcomposite libxinerama lib32-libgcrypt libgcrypt lib32-libxinerama \

View File

@ -29,8 +29,7 @@ install_theme_tools() {
sudo dnf install -y qt6ct kvantum
;;
pacman)
sudo pacman -Sy
sudo pacman --noconfirm -S qt6ct kvantum
sudo pacman -S --needed --noconfirm qt6ct kvantum
;;
*)
printf "${RED}Unsupported package manager. Please install qt6ct and kvantum manually.${RC}\n"

View File

@ -0,0 +1,25 @@
#!/bin/sh -e
. "$(dirname "$0")/../../common-script.sh"
installDepend() {
case $PACKAGER in
pacman)
if ! command_exists paru; then
echo "Installing paru as AUR helper..."
sudo "$PACKAGER" -S --needed --noconfirm base-devel
cd /opt && sudo git clone https://aur.archlinux.org/paru.git && sudo chown -R "$USER": ./paru
cd paru && makepkg --noconfirm -si
echo "Paru installed"
else
echo "Paru already installed"
fi
;;
*)
echo "Unsupported package manager: $PACKAGER"
;;
esac
}
checkEnv
installDepend

View File

@ -0,0 +1,25 @@
#!/bin/sh -e
. "$(dirname "$0")/../../common-script.sh"
installDepend() {
case $PACKAGER in
pacman)
if ! command_exists yay; then
echo "Installing yay as AUR helper..."
sudo "$PACKAGER" -S --needed --noconfirm base-devel
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R "$USER": ./yay-git
cd yay-git && makepkg --noconfirm -si
echo "Yay installed"
else
echo "Aur helper already installed"
fi
;;
*)
echo "Unsupported package manager: $PACKAGER"
;;
esac
}
checkEnv
installDepend

View File

@ -7,7 +7,7 @@ fastUpdate() {
pacman)
if ! command_exists yay && ! command_exists paru; then
echo "Installing yay as AUR helper..."
sudo ${PACKAGER} --noconfirm -S base-devel || { echo -e "${RED}Failed to install base-devel${RC}"; exit 1; }
sudo ${PACKAGER} -S --needed --noconfirm base-devel || { echo -e "${RED}Failed to install base-devel${RC}"; exit 1; }
cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git
cd yay-git && makepkg --noconfirm -si || { echo -e "${RED}Failed to install yay${RC}"; exit 1; }
else
@ -21,7 +21,7 @@ fastUpdate() {
echo "No AUR helper found. Please install yay or paru."
exit 1
fi
${AUR_HELPER} --noconfirm -S rate-mirrors-bin
${AUR_HELPER} -S --needed --noconfirm rate-mirrors-bin
if [ -s /etc/pacman.d/mirrorlist ]; then
sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
fi

View File

@ -75,7 +75,7 @@ prompt_for_mac() {
fi
# Display devices with numbers
IFS=$'\n' read -rd '' -a device_list <<<"$devices"
IFS=$'\n' read -r -a device_list <<<"$devices"
for i in "${!device_list[@]}"; do
echo "$((i+1)). ${device_list[$i]}"
done
@ -128,4 +128,4 @@ remove_device() {
}
# Initialize
main_menu
main_menu

View File

@ -102,7 +102,7 @@ prompt_for_network() {
fi
# Display networks with numbers
IFS=$'\n' read -rd '' -a network_list <<<"$networks"
IFS=$'\n' read -r -a network_list <<<"$networks"
for i in "${!network_list[@]}"; do
ssid=$(echo "${network_list[$i]}" | awk -F: '{print $1}')
echo "$((i+1)). SSID: $ssid"
@ -166,4 +166,4 @@ remove_network() {
}
# Initialize
main_menu
main_menu

81
src/search.rs Normal file
View File

@ -0,0 +1,81 @@
use crossterm::event::{KeyCode, KeyEvent};
use ratatui::{
layout::Rect,
style::Style,
text::Span,
widgets::{Block, Borders, Paragraph},
Frame,
};
use crate::state::AppState;
pub struct SearchBar {
search_input: String,
in_search_mode: bool,
}
impl SearchBar {
pub fn new() -> Self {
SearchBar {
search_input: String::new(),
in_search_mode: false,
}
}
pub fn activate_search(&mut self) {
self.in_search_mode = true;
}
pub fn deactivate_search(&mut self) {
self.in_search_mode = false;
}
pub fn is_search_active(&self) -> bool {
self.in_search_mode
}
pub fn draw(&self, frame: &mut Frame, area: Rect, state: &AppState) {
//Set the search bar text (If empty use the placeholder)
let display_text = if !self.in_search_mode && self.search_input.is_empty() {
Span::raw("Press / to search")
} else {
Span::raw(&self.search_input)
};
//Create the search bar widget
let mut search_bar = Paragraph::new(display_text)
.block(Block::default().borders(Borders::ALL).title("Search"))
.style(Style::default().fg(state.theme.unfocused_color));
//Change the color if in search mode
if self.in_search_mode {
search_bar = search_bar
.clone()
.style(Style::default().fg(state.theme.focused_color));
}
//Render the search bar (First chunk of the screen)
frame.render_widget(search_bar, area);
}
pub fn handle_key(&mut self, event: KeyEvent) -> String {
//Insert user input into the search bar
match event.code {
KeyCode::Char(c) => {
self.search_input.push(c);
}
KeyCode::Backspace => {
self.search_input.pop();
}
KeyCode::Esc => {
self.search_input = String::new();
self.in_search_mode = false;
}
KeyCode::Enter => {
self.in_search_mode = false;
}
_ => {}
}
self.search_input.clone()
}
}

View File

@ -10,6 +10,8 @@ pub struct Theme {
pub tab_icon: &'static str,
pub success_color: Color,
pub fail_color: Color,
pub focused_color: Color,
pub unfocused_color: Color,
}
pub const THEMES: [Theme; 2] = [
@ -22,6 +24,8 @@ pub const THEMES: [Theme; 2] = [
tab_icon: ">> ",
success_color: Color::Green,
fail_color: Color::Red,
focused_color: Color::LightBlue,
unfocused_color: Color::Gray,
},
Theme {
dir_color: Color::Blue,
@ -32,5 +36,7 @@ pub const THEMES: [Theme; 2] = [
tab_icon: "",
fail_color: Color::Rgb(199, 55, 44),
success_color: Color::Rgb(5, 255, 55),
focused_color: Color::LightBlue,
unfocused_color: Color::Gray,
},
];