Skip to content

Commit

Permalink
Merge branch 'main' into logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevithakannan2 committed Nov 8, 2024
2 parents 7a70939 + f5f3824 commit f764939
Show file tree
Hide file tree
Showing 74 changed files with 754 additions and 118 deletions.
3 changes: 2 additions & 1 deletion .shellcheckrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
external-sources=true
source=core/tabs/common-script.sh
source=core/tabs/common-script.sh
source=core/tabs/common-service-script.sh
5 changes: 2 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ license = "MIT"
version = "24.9.28"
edition = "2021"

[workspace.dependencies]
ego-tree = "0.6.2"

[workspace]
members = ["tui", "core", "xtask"]
default-members = ["tui", "core"]
Expand Down
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ curl -fsSL https://christitus.com/linux | sh
```bash
curl -fsSL https://christitus.com/linuxdev | sh
```
<details>
<summary>CLI arguments</summary>

Linutil supports various command-line arguments to customize its behavior. Here are some common arguments you can use:

- `-t, --theme <THEME>` : Set the theme to use in the application [default: default] [possible values: default, compatible].
- `--override-validation` : Show all available options, disregarding compatibility checks (UNSAFE).
- `-h, --help` : Print help.

For more detailed usage, run:

```bash
curl -fsSL https://christitus.com/linux | sh -s -- --help
```

```bash
linutil --help
```
</details>

## ⬇️ Installation

Linutil is also available as a package in various repositories:
Expand Down Expand Up @@ -58,7 +78,15 @@ paru -S linutil
Replace `paru` with your preferred helper and `linutil` with your preferred package.

</details>
<details>
<summary>OpenSUSE</summary>

Linutil can be installed on OpenSUSE with:
```bash
sudo zypper install linutil
```

</details>
<details>
<summary>Cargo</summary>

Expand All @@ -72,6 +100,28 @@ Note that crates installed using `cargo install` require manual updating with `c

</details>

## Configuration

Linutil supports configuration through a TOML config file. Path to the file can be specified with `--config` (or `-c`).

Available options:
- `auto_execute` - a list of commands to execute automatically (can be combined with `--skip-confirmation`)

Example config:
```toml
# example_config.toml

auto_execute = [
"Fastfetch",
"Alacritty",
"Kitty"
]
```

```bash
linutil --config /path/to/example_config.toml
```

## 💖 Support

If you find Linutil helpful, please consider giving it a ⭐️ to show your support!
Expand Down
8 changes: 2 additions & 6 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ repository = "https://github.com/ChrisTitusTech/linutil/tree/main/core"
edition = "2021"
version.workspace = true
license.workspace = true
include = [
"src/*.rs",
"Cargo.toml",
"tabs/**",
]
include = ["src/*.rs", "Cargo.toml", "tabs/**"]

[dependencies]
include_dir = "0.7.4"
temp-dir = "0.1.14"
serde = { version = "1.0.205", features = ["derive"], default-features = false }
toml = { version = "0.8.19", features = ["parse"], default-features = false }
which = "6.0.3"
ego-tree = { workspace = true }
ego-tree = "0.9.0"
28 changes: 28 additions & 0 deletions core/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use serde::Deserialize;
use std::path::Path;
use std::process;

#[derive(Deserialize)]
pub struct Config {
pub auto_execute: Vec<String>,
}

impl Config {
pub fn from_file(path: &Path) -> Self {
let content = match std::fs::read_to_string(path) {
Ok(content) => content,
Err(e) => {
eprintln!("Failed to read config file {}: {}", path.display(), e);
process::exit(1);
}
};

match toml::from_str(&content) {
Ok(config) => config,
Err(e) => {
eprintln!("Failed to parse config file: {}", e);
process::exit(1);
}
}
}
}
16 changes: 16 additions & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
mod config;
mod inner;

use std::rc::Rc;

pub use ego_tree;
use ego_tree::Tree;
use std::path::PathBuf;

pub use config::Config;
pub use inner::{get_tabs, TabList};

#[derive(Clone, Hash, Eq, PartialEq)]
Expand Down Expand Up @@ -33,3 +36,16 @@ pub struct ListNode {
pub task_list: String,
pub multi_select: bool,
}

impl Tab {
pub fn find_command(&self, name: &str) -> Option<Rc<ListNode>> {
self.tree.root().descendants().find_map(|node| {
let value = node.value();
if value.name == name && !node.has_children() {
Some(value.clone())
} else {
None
}
})
}
}
3 changes: 3 additions & 0 deletions core/tabs/applications-setup/Developer-tools/meld-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ installMeld() {
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" -y install meld
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add meld
;;
*)
checkFlatpak
flatpak install -y flathub org.gnome.meld
Expand Down
3 changes: 3 additions & 0 deletions core/tabs/applications-setup/Developer-tools/neovim-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ installNeovim() {
dnf|zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck git
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add neovim ripgrep fzf py3-virtualenv luarocks go shellcheck git
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
Expand Down
6 changes: 5 additions & 1 deletion core/tabs/applications-setup/Developer-tools/vscode-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
. ../../common-script.sh

installVsCode() {
if ! command_exists code; then
if ! command_exists com.visualstudio.code && ! command_exists code; then
printf "%b\n" "${YELLOW}Installing VS Code..${RC}."
case "$PACKAGER" in
apt-get|nala)
Expand All @@ -28,6 +28,10 @@ installVsCode() {
printf "%b\n" '[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc' | "$ESCALATION_TOOL" tee /etc/yum.repos.d/vscode.repo > /dev/null
"$ESCALATION_TOOL" "$PACKAGER" install -y code
;;
apk)
checkFlatpak
flatpak install -y flathub com.visualstudio.code
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
. ../../common-script.sh

installVsCodium() {
if ! command_exists codium; then
if ! command_exists com.vscodium.codium && ! command_exists codium; then
printf "%b\n" "${YELLOW}Installing VS Codium...${RC}"
case "$PACKAGER" in
apt-get|nala)
Expand All @@ -26,6 +26,10 @@ installVsCodium() {
printf "%b\n" "[gitlab.com_paulcarroty_vscodium_repo]\nname=download.vscodium.com\nbaseurl=https://download.vscodium.com/rpms/\nenabled=1\ngpgcheck=1\nrepo_gpgcheck=1\ngpgkey=https://gitlab.com/paulcarroty/vscodium-deb-rpm-repo/-/raw/master/pub.gpg\nmetadata_expire=1h" | "$ESCALATION_TOOL" tee -a /etc/yum.repos.d/vscodium.repo
"$ESCALATION_TOOL" "$PACKAGER" install -y codium
;;
apk)
checkFlatpak
flatpak install -y flathub com.vscodium.codium
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
Expand Down
3 changes: 3 additions & 0 deletions core/tabs/applications-setup/alacritty-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ installAlacritty() {
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm alacritty
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add alacritty
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y alacritty
;;
Expand Down
3 changes: 3 additions & 0 deletions core/tabs/applications-setup/android-debloat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ install_adb() {
dnf|zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -y android-tools
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add android-tools
;;
*)
printf "%b\n" "${RED}Unsupported package manager: "$PACKAGER"${RC}"
exit 1
Expand Down
6 changes: 5 additions & 1 deletion core/tabs/applications-setup/browsers/brave.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
. ../../common-script.sh

installBrave() {
if ! command_exists brave; then
if ! command_exists com.brave.Browser && ! command_exists brave; then
printf "%b\n" "${YELLOW}Installing Brave...${RC}"
case "$PACKAGER" in
apt-get|nala)
Expand All @@ -29,6 +29,10 @@ installBrave() {
"$ESCALATION_TOOL" rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
"$ESCALATION_TOOL" "$PACKAGER" install -y brave-browser
;;
apk)
checkFlatpak
flatpak install -y flathub com.brave.Browser
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
Expand Down
3 changes: 3 additions & 0 deletions core/tabs/applications-setup/browsers/chromium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ if ! command_exists chromium; then
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm chromium
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add chromium
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y chromium
;;
Expand Down
3 changes: 3 additions & 0 deletions core/tabs/applications-setup/browsers/firefox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ installFirefox() {
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y firefox
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add firefox
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
Expand Down
6 changes: 5 additions & 1 deletion core/tabs/applications-setup/browsers/librewolf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
. ../../common-script.sh

installLibreWolf() {
if ! command_exists librewolf; then
if ! command_exists io.gitlab.librewolf-community && ! command_exists librewolf; then
printf "%b\n" "${YELLOW}Installing Librewolf...${RC}"
case "$PACKAGER" in
apt-get|nala)
Expand Down Expand Up @@ -32,6 +32,10 @@ Signed-By: /usr/share/keyrings/librewolf.gpg" | "$ESCALATION_TOOL" tee /etc/apt/
pacman)
"$AUR_HELPER" -S --needed --noconfirm librewolf-bin
;;
apk)
checkFlatpak
flatpak install flathub io.gitlab.librewolf-community
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
Expand Down
3 changes: 3 additions & 0 deletions core/tabs/applications-setup/browsers/lynx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ installLynx() {
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm lynx
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add lynx
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y lynx
;;
Expand Down
1 change: 1 addition & 0 deletions core/tabs/applications-setup/browsers/thorium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ installThrorium() {
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;;
esac
else
Expand Down
34 changes: 34 additions & 0 deletions core/tabs/applications-setup/browsers/tor-browser.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh -e

. ../../common-script.sh

installTorBrowser() {
if ! command_exists torbrowser-launcher; then
printf "%b\n" "${YELLOW}Installing Tor Browser...${RC}"
case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y torbrowser-launcher
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install torbrowser-launcher
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm torbrowser-launcher
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y torbrowser-launcher
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac
else
printf "%b\n" "${GREEN}Tor Browser is already installed.${RC}"
fi
}

checkEnv
checkEscalationTool
installTorBrowser

6 changes: 3 additions & 3 deletions core/tabs/applications-setup/browsers/waterfox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
. ../../common-script.sh

installWaterfox() {
if ! command_exists waterfox; then
if ! command_exists net.waterfox.waterfox && ! command_exists waterfox; then
printf "%b\n" "${YELLOW}Installing waterfox...${RC}"
case "$PACKAGER" in
pacman)
"$AUR_HELPER" -S --needed --noconfirm waterfox-bin
"$AUR_HELPER" -S --needed --noconfirm waterfox-bin
;;
*)
. ../setup-flatpak.sh
checkFlatpak
flatpak install -y flathub net.waterfox.waterfox
;;
esac
Expand Down
Loading

0 comments on commit f764939

Please sign in to comment.