Merge branch 'main' into mouse-scroll

This commit is contained in:
Jeevitha Kannan K S 2024-11-07 07:06:12 +05:30
commit f2b1edf2eb
No known key found for this signature in database
GPG Key ID: 5904C34A2F7CE333
30 changed files with 785 additions and 234 deletions

View File

@ -7,11 +7,4 @@ updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
ignore:
- dependency-name: "actions/stale"
versions: '>= 9'
- dependency-name: "actions/setup-python"
versions: '> 4'
- dependency-name: "crossterm"
versions: '> 0.27.0'
interval: "weekly"

25
Cargo.lock generated
View File

@ -435,7 +435,6 @@ dependencies = [
"ansi-to-tui",
"anstyle",
"clap",
"crossterm",
"ego-tree",
"linutil_core",
"oneshot",
@ -443,6 +442,7 @@ dependencies = [
"rand",
"ratatui",
"temp-dir",
"textwrap",
"tree-sitter-bash",
"tree-sitter-highlight",
"tui-term",
@ -889,6 +889,12 @@ version = "1.13.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "smawk"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c"
[[package]]
name = "static_assertions"
version = "1.1.0"
@ -955,6 +961,17 @@ dependencies = [
"libc",
]
[[package]]
name = "textwrap"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9"
dependencies = [
"smawk",
"unicode-linebreak",
"unicode-width 0.1.14",
]
[[package]]
name = "thiserror"
version = "1.0.64"
@ -1067,6 +1084,12 @@ version = "1.0.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
[[package]]
name = "unicode-linebreak"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f"
[[package]]
name = "unicode-segmentation"
version = "1.11.0"

View File

@ -1,6 +1,7 @@
use std::{
fs::File,
io::{BufRead, BufReader, Read},
ops::{Deref, DerefMut},
os::unix::fs::PermissionsExt,
path::{Path, PathBuf},
rc::Rc,
@ -14,8 +15,34 @@ use temp_dir::TempDir;
const TAB_DATA: Dir = include_dir!("$CARGO_MANIFEST_DIR/tabs");
pub fn get_tabs(validate: bool) -> (TempDir, Vec<Tab>) {
let (temp_dir, tab_files) = TabList::get_tabs();
// Allow the unused TempDir to be stored for later destructor call
#[allow(dead_code)]
pub struct TabList(pub Vec<Tab>, TempDir);
// Implement deref to allow Vec<Tab> methods to be called on TabList
impl Deref for TabList {
type Target = Vec<Tab>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl DerefMut for TabList {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl IntoIterator for TabList {
type Item = Tab;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter {
self.0.into_iter()
}
}
pub fn get_tabs(validate: bool) -> TabList {
let (temp_dir, tab_files) = TabDirectories::get_tabs();
let tabs: Vec<_> = tab_files
.into_iter()
@ -33,40 +60,28 @@ pub fn get_tabs(validate: bool) -> (TempDir, Vec<Tab>) {
let tabs: Vec<Tab> = tabs
.into_iter()
.map(
|(
TabEntry {
name,
data,
multi_selectable,
},
directory,
)| {
let mut tree = Tree::new(Rc::new(ListNode {
name: "root".to_string(),
description: String::new(),
command: Command::None,
task_list: String::new(),
}));
let mut root = tree.root_mut();
create_directory(data, &mut root, &directory, validate);
Tab {
name,
tree,
multi_selectable,
}
},
)
.map(|(TabEntry { name, data }, directory)| {
let mut tree = Tree::new(Rc::new(ListNode {
name: "root".to_string(),
description: String::new(),
command: Command::None,
task_list: String::new(),
multi_select: false,
}));
let mut root = tree.root_mut();
create_directory(data, &mut root, &directory, validate, true);
Tab { name, tree }
})
.collect();
if tabs.is_empty() {
panic!("No tabs found");
}
(temp_dir, tabs)
TabList(tabs, temp_dir)
}
#[derive(Deserialize)]
struct TabList {
struct TabDirectories {
directories: Vec<PathBuf>,
}
@ -74,12 +89,6 @@ struct TabList {
struct TabEntry {
name: String,
data: Vec<Entry>,
#[serde(default = "default_multi_selectable")]
multi_selectable: bool,
}
fn default_multi_selectable() -> bool {
true
}
#[derive(Deserialize)]
@ -94,6 +103,12 @@ struct Entry {
entry_type: EntryType,
#[serde(default)]
task_list: String,
#[serde(default = "default_true")]
multi_select: bool,
}
fn default_true() -> bool {
true
}
#[derive(Deserialize)]
@ -174,8 +189,11 @@ fn create_directory(
node: &mut NodeMut<Rc<ListNode>>,
command_dir: &Path,
validate: bool,
parent_multi_select: bool,
) {
for entry in data {
let multi_select = parent_multi_select && entry.multi_select;
match entry.entry_type {
EntryType::Entries(entries) => {
let mut node = node.append(Rc::new(ListNode {
@ -183,8 +201,9 @@ fn create_directory(
description: entry.description,
command: Command::None,
task_list: String::new(),
multi_select,
}));
create_directory(entries, &mut node, command_dir, validate);
create_directory(entries, &mut node, command_dir, validate, multi_select);
}
EntryType::Command(command) => {
node.append(Rc::new(ListNode {
@ -192,6 +211,7 @@ fn create_directory(
description: entry.description,
command: Command::Raw(command),
task_list: String::new(),
multi_select,
}));
}
EntryType::Script(script) => {
@ -210,6 +230,7 @@ fn create_directory(
file: script,
},
task_list: entry.task_list,
multi_select,
}));
}
}
@ -252,9 +273,9 @@ fn is_executable(path: &Path) -> bool {
.unwrap_or(false)
}
impl TabList {
impl TabDirectories {
fn get_tabs() -> (TempDir, Vec<PathBuf>) {
let temp_dir = TempDir::new().unwrap();
let temp_dir = TempDir::with_prefix("linutil_scripts").unwrap();
TAB_DATA
.extract(&temp_dir)
.expect("Failed to extract the saved directory");

View File

@ -5,7 +5,7 @@ use std::rc::Rc;
use ego_tree::Tree;
use std::path::PathBuf;
pub use inner::get_tabs;
pub use inner::{get_tabs, TabList};
#[derive(Clone, Hash, Eq, PartialEq)]
pub enum Command {
@ -23,7 +23,6 @@ pub enum Command {
pub struct Tab {
pub name: String,
pub tree: Tree<Rc<ListNode>>,
pub multi_selectable: bool,
}
#[derive(Clone, Hash, Eq, PartialEq)]
@ -32,4 +31,5 @@ pub struct ListNode {
pub description: String,
pub command: Command,
pub task_list: String,
pub multi_select: bool,
}

View File

@ -214,10 +214,28 @@ setupDisplayManager() {
printf "%b\n" "${YELLOW}3. GDM ${RC}"
printf "%b\n" "${YELLOW} ${RC}"
printf "%b" "${YELLOW}Please select one: ${RC}"
read -r DM
read -r choice
case "$choice" in
1)
DM="sddm"
;;
2)
DM="lightdm"
;;
3)
DM="gdm"
;;
*)
printf "%b\n" "${RED}Invalid selection! Please choose 1, 2, or 3.${RC}"
exit 1
;;
esac
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$DM"
if [ "$DM" = "lightdm" ]; then
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm lightdm-gtk-greeter
fi
;;
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DM"

View File

@ -0,0 +1,33 @@
#!/bin/sh -e
. ../common-script.sh
installPodmanCompose() {
if ! command_exists podman-compose; then
printf "%b\n" "${YELLOW}Installing Podman Compose...${RC}"
case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y podman-compose
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install podman-compose
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm --needed podman-compose
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y podman-compose
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac
else
printf "%b\n" "${GREEN}Podman Compose is already installed.${RC}"
fi
}
checkEnv
checkEscalationTool
installPodmanCompose

View File

@ -0,0 +1,33 @@
#!/bin/sh -e
. ../common-script.sh
installPodman() {
if ! command_exists podman; then
printf "%b\n" "${YELLOW}Installing Podman...${RC}"
case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y podman
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install podman
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm --needed podman
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y podman
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac
else
printf "%b\n" "${GREEN}Podman is already installed.${RC}"
fi
}
checkEnv
checkEscalationTool
installPodman

View File

@ -200,7 +200,7 @@ task_list = "FI"
[[data]]
name = "Alacritty"
description = "Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows.\nThis command installs and condifures alacritty terminal emulator."
description = "Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows. This command installs and configures alacritty terminal emulator."
script = "alacritty-setup.sh"
task_list = "I FM"
@ -212,13 +212,13 @@ task_list = "I"
[[data]]
name = "Bash Prompt"
description = "The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems.\nIt is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful.\nThis command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository.\nhttps://github.com/ChrisTitusTech/mybash"
description = "The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems. It is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful. This command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository. https://github.com/ChrisTitusTech/mybash"
script = "mybash-setup.sh"
task_list = "I FM"
[[data]]
name = "Bottles"
description = "Bottles allows Windows software, like applications and games, to run on Linux.\nBottles also provides tools to categorize, organize and optimize your applications."
description = "Bottles allows Windows software, like applications and games, to run on Linux. Bottles also provides tools to categorize, organize and optimize your applications."
script = "bottles-setup.sh"
task_list = "FI"
@ -228,6 +228,18 @@ description = "Docker is an open platform that uses OS-level virtualization to d
script = "docker-setup.sh"
task_list = "I SS"
[[data]]
name = "Podman"
description = "Podman is a daemon-less open platform that uses OS-level virtualization to deliver software in packages called containers."
script = "podman-setup.sh"
task_list = "I SS"
[[data]]
name = "Podman-compose"
description = "Podman Compose is a tool for defining and running multi-container applications using Podman."
script = "podman-compose-setup.sh"
task_list = "I SS"
[[data]]
name = "DWM-Titus"
description = "DWM is a dynamic window manager for X.\nIt manages windows in tiled, monocle and floating layouts.\nAll of the layouts can be applied dynamically, optimising the environment for the application in use and the task performed.\nThis command installs and configures DWM and a desktop manager.\nThe list of patches applied can be found in CTT's DWM repository\nhttps://github.com/ChrisTitusTech/dwm-titus"
@ -236,13 +248,13 @@ task_list = "I PFM SS"
[[data]]
name = "Fastfetch"
description = "Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily.\nIt is written mainly in C, with performance and customizability in mind.\nThis command installs fastfetch and configures from CTT's mybash repository.\nhttps://github.com/ChrisTitusTech/mybash"
description = "Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily. It is written mainly in C, with performance and customizability in mind. This command installs fastfetch and configures from CTT's mybash repository. https://github.com/ChrisTitusTech/mybash"
script = "fastfetch-setup.sh"
task_list = "I FM"
[[data]]
name = "Flatpak / Flathub"
description = "Flatpak is a universal application sandbox for Linux that uses isolated packages from Flathub to prevent conflicts and system alterations, while alleviating dependency concerns.\nThis command installs Flatpak and adds the Flathub repository"
description = "Flatpak is a universal application sandbox for Linux that uses isolated packages from Flathub to prevent conflicts and system alterations, while alleviating dependency concerns. This command installs Flatpak and adds the Flathub repository"
script = "setup-flatpak.sh"
task_list = "I"
@ -254,7 +266,7 @@ task_list = "PFM"
[[data]]
name = "Kitty"
description = "kitty is a free and open-source GPU-accelerated terminal emulator for Linux, macOS, and some BSD distributions, focused on performance and features.\nkitty is written in a mix of C and Python programming languages.\n This command installs and configures kitty."
description = "kitty is a free and open-source GPU-accelerated terminal emulator for Linux, macOS, and some BSD distributions, focused on performance and features. kitty is written in a mix of C and Python programming languages. This command installs and configures kitty."
script = "kitty-setup.sh"
task_list = "I FM"
@ -282,7 +294,7 @@ values = [ "linutil" ]
[[data]]
name = "Rofi"
description = "Rofi is a window switcher, run dialog, ssh-launcher and dmenu replacement that started as a clone of simpleswitcher, written by Sean Pringle and later expanded by Dave Davenport.\nThis command installs and configures rofi with configuration from CTT's DWM repo.\nhttps://github.com/ChrisTitusTech/dwm-titus"
description = "Rofi is a window switcher, run dialog, ssh-launcher and dmenu replacement that started as a clone of simpleswitcher, written by Sean Pringle and later expanded by Dave Davenport. This command installs and configures rofi with configuration from CTT's DWM repo. https://github.com/ChrisTitusTech/dwm-titus"
script = "rofi-setup.sh"
task_list = "I FM"
@ -298,6 +310,6 @@ values = [ "wayland", "Wayland" ]
[[data]]
name = "ZSH Prompt"
description = "The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.\nThis command installs ZSH prompt and provides basic configuration."
description = "The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh. This command installs ZSH prompt and provides basic configuration."
script = "zsh-setup.sh"
task_list = "I FM"

View File

@ -10,7 +10,7 @@ GREEN='\033[32m'
command_exists() {
for cmd in "$@"; do
export PATH=/home/jeeva/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH
export PATH="$HOME/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH"
command -v "$cmd" >/dev/null 2>&1 || return 1
done
return 0

View File

@ -5,6 +5,6 @@ name = "Diablo II Resurrected"
[[data.entries]]
name = "Loot Filter"
description = "This is a loot filter for Diablo II Resurrected.\nIt's designed to be a simple, clean, and easy to read loot filter that highlights the most important items.\nWorks on battle.net and single player.\nNo frills, no config, just highlights high runes and other valuable items.\nFor more information visit: https://github.com/ChrisTitusTech/d2r-loot-filter"
description = "This is a loot filter for Diablo II Resurrected. It's designed to be a simple, clean, and easy to read loot filter that highlights the most important items. Works on battle.net and single player. No frills, no config, just highlights high runes and other valuable items. For more information visit: https://github.com/ChrisTitusTech/d2r-loot-filter"
script = "diablo-ii/d2r-loot-filters.sh"
task_list = "FM"

View File

@ -2,6 +2,6 @@ name = "Security"
[[data]]
name = "Firewall Baselines (CTT)"
description = "Developed to ease iptables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall.\nThis command installs UFW and configures UFW based on CTT's recommended rules.\nFor more information visit: https://christitus.com/linux-security-mistakes"
description = "Developed to ease iptables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall. This command installs UFW and configures UFW based on CTT's recommended rules. For more information visit: https://christitus.com/linux-security-mistakes"
script = "firewall-baselines.sh"
task_list = "I SS"

View File

@ -0,0 +1,60 @@
#!/bin/sh -e
. ../../common-script.sh
setUpRepos() {
if ! grep -q "^\s*\[jupiter-staging\]" /etc/pacman.conf; then
printf "%b\n" "${CYAN}Adding jupiter-staging to pacman repositories...${RC}"
echo "[jupiter-staging]" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf
echo "Server = https://steamdeck-packages.steamos.cloud/archlinux-mirror/\$repo/os/\$arch" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf
echo "SigLevel = Never" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf
fi
if ! grep -q "^\s*\[holo-staging\]" /etc/pacman.conf; then
printf "%b\n" "${CYAN}Adding holo-staging to pacman repositories...${RC}"
echo "[holo-staging]" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf
echo "Server = https://steamdeck-packages.steamos.cloud/archlinux-mirror/\$repo/os/\$arch" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf
echo "SigLevel = Never" | "$ESCALATION_TOOL" tee -a /etc/pacman.conf
fi
}
installKernel() {
if ! "$PACKAGER" -Q | grep -q "\blinux-neptune"; then
printf "%b\n" "${CYAN}Installing linux-neptune..."
"$ESCALATION_TOOL" "$PACKAGER" -Syyu --noconfirm
"$ESCALATION_TOOL" "$PACKAGER" -S --noconfirm linux-neptune linux-neptune-headers steamdeck-dsp jupiter-staging/alsa-ucm-conf
"$ESCALATION_TOOL" mkinitcpio -P
else
printf "%b\n" "${GREEN}linux-neptune detected. Skipping installation.${RC}"
fi
if [ -f /etc/default/grub ]; then
printf "%b\n" "${CYAN}Updating GRUB...${RC}"
if ! grep -q '^UPDATEDEFAULT=' /etc/default/grub; then
echo 'UPDATEDEFAULT=yes' | "$ESCALATION_TOOL" tee -a /etc/default/grub
else
"$ESCALATION_TOOL" sed -i 's/^UPDATEDEFAULT=.*/UPDATEDEFAULT=yes/' /etc/default/grub
fi
if [ -f /boot/grub/grub.cfg ]; then
"$ESCALATION_TOOL" grub-mkconfig -o /boot/grub/grub.cfg
else
printf "%b\n" "${RED}GRUB configuration file not found. Run grub-mkconfig manually.${RC}"
fi
else
printf "%b\n" "${RED}GRUB not detected. Manually set your bootloader to use linux-neptune.${RC}"
fi
}
copyFirmwareFiles() {
printf "%b\n" "${CYAN}Copying firmware files...${RC}"
"$ESCALATION_TOOL" mkdir -p /usr/lib/firmware/cirrus
"$ESCALATION_TOOL" cp /usr/lib/firmware/cs35l41-dsp1-spk-cali.bin /usr/lib/firmware/cirrus/
"$ESCALATION_TOOL" cp /usr/lib/firmware/cs35l41-dsp1-spk-cali.wmfw /usr/lib/firmware/cirrus/
"$ESCALATION_TOOL" cp /usr/lib/firmware/cs35l41-dsp1-spk-prot.bin /usr/lib/firmware/cirrus/
"$ESCALATION_TOOL" cp /usr/lib/firmware/cs35l41-dsp1-spk-prot.wmfw /usr/lib/firmware/cirrus/
}
checkEnv
checkEscalationTool
setUpRepos
installKernel
copyFirmwareFiles

View File

@ -0,0 +1,120 @@
#!/bin/sh -e
. ../../common-script.sh
LIBVA_DIR="$HOME/.local/share/linutil/libva"
MPV_CONF="$HOME/.config/mpv/mpv.conf"
installDeps() {
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel dkms ninja meson git
installed_kernels=$("$PACKAGER" -Q | grep -E '^linux(| |-rt|-rt-lts|-hardened|-zen|-lts)[^-headers]' | cut -d ' ' -f 1)
for kernel in $installed_kernels; do
header="${kernel}-headers"
printf "%b\n" "${CYAN}Installing headers for $kernel...${RC}"
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$header"
done
}
checkNvidiaHardware() {
# Refer https://nouveau.freedesktop.org/CodeNames.html for model code names
model=$(lspci -k | grep -A 2 -E "(VGA|3D)" | grep NVIDIA | sed 's/.*Corporation //;s/ .*//' | cut -c 1-2)
case "$model" in
GM | GP | GV) return 1 ;;
TU | GA | AD) return 0 ;;
*) printf "%b\n" "${RED}Unsupported hardware." && exit 1 ;;
esac
}
checkIntelHardware() {
model=$(grep "model name" /proc/cpuinfo | head -n 1 | cut -d ':' -f 2 | cut -c 2-3)
[ "$model" -ge 11 ]
}
promptUser() {
printf "%b" "Do you want to $1 ? [y/N]:"
read -r confirm
[ "$confirm" = "y" ] || [ "$confirm" = "Y" ]
}
setKernelParam() {
PARAMETER="$1"
if grep -q "$PARAMETER" /etc/default/grub; then
printf "%b\n" "${YELLOW}NVIDIA modesetting is already enabled in GRUB.${RC}"
else
"$ESCALATION_TOOL" sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT=/ s/\"$/ $PARAMETER\"/" /etc/default/grub
printf "%b\n" "${CYAN}Added $PARAMETER to /etc/default/grub.${RC}"
"$ESCALATION_TOOL" grub-mkconfig -o /boot/grub/grub.cfg
fi
}
setupHardwareAcceleration() {
if ! command_exists grub-mkconfig; then
printf "%b\n" "${RED}Currently hardware acceleration is only available with GRUB.${RC}"
return
fi
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm libva-nvidia-driver
mkdir -p "$HOME/.local/share/linutil"
if [ -d "$LIBVA_DIR" ]; then
rm -rf "$LIBVA_DIR"
fi
printf "%b\n" "${YELLOW}Cloning libva from https://github.com/intel/libva in ${LIBVA_DIR}${RC}"
git clone --branch=v2.22-branch --depth=1 https://github.com/intel/libva "$LIBVA_DIR"
mkdir -p "$LIBVA_DIR/build"
cd "$LIBVA_DIR/build" && arch-meson .. -Dwith_legacy=nvctrl && ninja
"$ESCALATION_TOOL" ninja install
"$ESCALATION_TOOL" sed -i '/^MOZ_DISABLE_RDD_SANDBOX/d' "/etc/environment"
"$ESCALATION_TOOL" sed -i '/^LIBVA_DRIVER_NAME/d' "/etc/environment"
printf "LIBVA_DRIVER_NAME=nvidia\nMOZ_DISABLE_RDD_SANDBOX=1" | "$ESCALATION_TOOL" tee -a /etc/environment >/dev/null
printf "%b\n" "${GREEN}Hardware Acceleration setup completed successfully.${RC}"
if promptUser "enable Hardware Acceleration in MPV player"; then
mkdir -p "$HOME/.config/mpv"
if [ -f "$MPV_CONF" ]; then
sed -i '/^hwdec/d' "$MPV_CONF"
fi
printf "hwdec=auto" | tee -a "$MPV_CONF" >/dev/null
printf "%b\n" "${GREEN}MPV Hardware Acceleration enabled successfully.${RC}"
fi
}
installDriver() {
# Refer https://wiki.archlinux.org/title/NVIDIA for open-dkms or dkms driver selection
if checkNvidiaHardware && promptUser "install nvidia's open source drivers"; then
printf "%b\n" "${YELLOW}Installing nvidia open source driver...${RC}"
installDeps
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm nvidia-open-dkms nvidia-utils
else
printf "%b\n" "${YELLOW}Installing nvidia proprietary driver...${RC}"
installDeps
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm nvidia-dkms nvidia-utils
fi
if checkIntelHardware; then
setKernelParam "ibt=off"
fi
# Refer https://wiki.archlinux.org/title/NVIDIA/Tips_and_tricks#Preserve_video_memory_after_suspend
setKernelParam "nvidia.NVreg_PreserveVideoMemoryAllocations=1"
"$ESCALATION_TOOL" systemctl enable nvidia-suspend.service nvidia-hibernate.service nvidia-resume.service
printf "%b\n" "${GREEN}Driver installed successfully.${RC}"
if promptUser "setup Hardware Acceleration"; then
setupHardwareAcceleration
fi
printf "%b\n" "${GREEN}Please reboot your system for the changes to take effect.${RC}"
}
checkEnv
checkEscalationTool
installDriver

View File

@ -0,0 +1,168 @@
#!/bin/sh -e
. ../../common-script.sh
# This script automates the installation and root and home snapshot configuration of Snapper and installs Grub-Btrfs on Fedora.
# Also installs python3-dnf-plugin-snapper package for automatic snapshots after dnf commands.
# Install Btrfs-Assistant/snapper and dependencies
installBtrfsStack() {
if ! command_exists btrfs-assistant; then
printf "%b\n" "${YELLOW}==========================================${RC}"
printf "%b\n" "${YELLOW}Installing Btrfs Assistant with snapper...${RC}"
printf "%b\n" "${YELLOW}==========================================${RC}"
case "$PACKAGER" in
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y btrfs-assistant python3-dnf-plugin-snapper
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
;;
esac
else
printf "%b\n" "${GREEN}Btrfs Assistant is already installed.${RC}"
fi
}
# Create first snapper config for root and home and create new manual snapshots
configureSnapper() {
printf "%b\n" "${YELLOW}===========================================================================${RC}"
printf "%b\n" "${YELLOW}Creating snapper root(/) and /home config and taking the first snapshots...${RC}"
printf "%b\n" "${YELLOW}===========================================================================${RC}"
"$ESCALATION_TOOL" snapper -c home create-config /home && "$ESCALATION_TOOL" snapper -c home create --description "First home Snapshot"
"$ESCALATION_TOOL" snapper -c root create-config / && "$ESCALATION_TOOL" snapper -c root create --description "First root Snapshot"
printf "%b\n" "${YELLOW}Updating timeline settings...${RC}"
# Modifyling default timeline root config
"$ESCALATION_TOOL" sed -i'' '
s/^TIMELINE_LIMIT_HOURLY="[^"]*"/TIMELINE_LIMIT_HOURLY="1"/;
s/^TIMELINE_LIMIT_DAILY="[^"]*"/TIMELINE_LIMIT_DAILY="2"/;
s/^TIMELINE_LIMIT_WEEKLY="[^"]*"/TIMELINE_LIMIT_WEEKLY="1"/;
s/^TIMELINE_LIMIT_MONTHLY="[^"]*"/TIMELINE_LIMIT_MONTHLY="0"/;
s/^TIMELINE_LIMIT_YEARLY="[^"]*"/TIMELINE_LIMIT_YEARLY="0"/
' /etc/snapper/configs/root
# Modifyling default timeline for home config
"$ESCALATION_TOOL" sed -i'' '
s/^TIMELINE_LIMIT_HOURLY="[^"]*"/TIMELINE_LIMIT_HOURLY="2"/;
s/^TIMELINE_LIMIT_DAILY="[^"]*"/TIMELINE_LIMIT_DAILY="1"/;
s/^TIMELINE_LIMIT_WEEKLY="[^"]*"/TIMELINE_LIMIT_WEEKLY="0"/;
s/^TIMELINE_LIMIT_MONTHLY="[^"]*"/TIMELINE_LIMIT_MONTHLY="1"/;
s/^TIMELINE_LIMIT_YEARLY="[^"]*"/TIMELINE_LIMIT_YEARLY="0"/
' /etc/snapper/configs/home
printf "%b\n" "${GREEN}Snapper configs and first snapshots created.${RC}"
}
# Starting services
serviceStartEnable() {
printf "%b\n" "${YELLOW}==================================================================================${RC}"
printf "%b\n" "${YELLOW}Starting and enabling snapper-timeline.timer and snapper-cleanup.timer services...${RC}"
printf "%b\n" "${YELLOW}==================================================================================${RC}"
"$ESCALATION_TOOL" systemctl enable --now snapper-timeline.timer
"$ESCALATION_TOOL" systemctl enable --now snapper-cleanup.timer
printf "%b\n" "${GREEN}Snapper services started and enabled.${RC}"
}
# Ask user if they want to install grub-btrfs
askInstallGrubBtrfs() {
printf "%b\n" "${YELLOW}=====================================${RC}"
printf "%b\n" "${YELLOW}(optional) grub-btrfs installation...${RC}"
printf "%b\n" "${YELLOW}=====================================${RC}"
printf "%b\n" "${YELLOW}You can skip installing grub-btrfs and use only Btrfs Assistant GUI or snapper CLI.${RC}"
printf "%b\n" "${CYAN}Notice: grub-btrfs may cause problems with booting into snapshots and other OSes on systems with secure boot/tpm. You will be asked to apply mitigation for this issue in next step.${RC}"
while true; do
printf "%b" "${YELLOW}Do you want to install grub-btrfs? Press (y) for yes, (n) for no, (f) to apply tpm mitigation to already installed grub-btrfs: ${RC}"
read -r response
case "$response" in
[yY]*)
installGrubBtrfs
break
;;
[nN]*)
printf "%b\n" "${GREEN}Skipping grub-btrfs installation.${RC}"
break
;;
[fF]*)
mitigateTpmError
break
;;
*)
printf "%b\n" "${RED}Invalid input. Please enter 'y' for yes, 'n' for no, or (f) to apply tpm mitigation to already installed grub-btrfs.${RC}"
;;
esac
done
}
# Install grub-btrfs
installGrubBtrfs() {
# Check if the grub-btrfs dir exists before attempting to clone into it.
printf "%b\n" "${YELLOW}Downloading grub-btrfs and installing dependencies...${RC}"
if [ -d "$HOME/grub-btrfs" ]; then
rm -rf "$HOME/grub-btrfs"
fi
"$ESCALATION_TOOL" "$PACKAGER" install -y make git inotify-tools
cd "$HOME" && git clone https://github.com/Antynea/grub-btrfs
printf "%b\n" "${YELLOW}Installing grub-btrfs...${RC}"
cd "$HOME/grub-btrfs"
printf "%b\n" "${YELLOW}Modifying grub-btrfs configuration for Fedora...${RC}"
sed -i'' '/#GRUB_BTRFS_SNAPSHOT_KERNEL/a GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="systemd.volatile=state"' config
sed -i'' '/#GRUB_BTRFS_GRUB_DIRNAME/a GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"' config
sed -i'' '/#GRUB_BTRFS_MKCONFIG=/a GRUB_BTRFS_MKCONFIG=/sbin/grub2-mkconfig' config
sed -i'' '/#GRUB_BTRFS_SCRIPT_CHECK=/a GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check' config
"$ESCALATION_TOOL" make install
printf "%b\n" "${YELLOW}Updating grub configuration and enabling grub-btrfsd service...${RC}"
"$ESCALATION_TOOL" grub2-mkconfig -o /boot/grub2/grub.cfg && "$ESCALATION_TOOL" systemctl enable --now grub-btrfsd.service
printf "%b\n" "${YELLOW}Cleaning up installation files...${RC}"
cd .. && rm -rf "$HOME/grub-btrfs"
printf "%b\n" "${GREEN}Grub-btrfs installed and service enabled.${RC}"
printf "%b\n" "${CYAN}Notice: To perform a system recovery via grub-btrfs, perform a restore operation with Btrfs Assistant GUI after booting into the snapshot.${RC}"
mitigateTpmError
}
mitigateTpmError() {
printf "%b\n" "${YELLOW}===============================================${RC}"
printf "%b\n" "${YELLOW}Mitigation for 'tpm.c:150:unknown TPM error'...${RC}"
printf "%b\n" "${YELLOW}===============================================${RC}"
printf "%b\n" "${YELLOW}Some systems with secure boot/tpm may encounter 'tpm.c:150:unknown TPM error' when booting into snapshots.${RC}"
printf "%b\n" "${YELLOW}If you encounter this issue, you can come back later and apply this mitigation or you can apply it now.${RC}"
while true; do
printf "%b\n" "${YELLOW}Do you want to apply the TPM error mitigation? (y/n): ${RC}"
read -r response
case "$response" in
[yY]*)
printf "%b\n" "${YELLOW}Creating /etc/grub.d/02_tpm file...${RC}"
echo '#!/bin/sh' | "$ESCALATION_TOOL" tee /etc/grub.d/02_tpm > /dev/null
echo 'echo "rmmod tpm"' | "$ESCALATION_TOOL" tee -a /etc/grub.d/02_tpm > /dev/null
"$ESCALATION_TOOL" chmod +x /etc/grub.d/02_tpm # makes the file executable
"$ESCALATION_TOOL" grub2-mkconfig -o /boot/grub2/grub.cfg # updates grub config
printf "%b\n" "${GREEN}Mitigation applied and grub config updated.${RC}"
break
;;
[nN]*)
printf "%b\n" "${GREEN}Skipping TPM error mitigation.${RC}"
break
;;
*)
printf "%b\n" "${RED}Invalid input. Please enter 'y' for yes or 'n' for no.${RC}"
;;
esac
done
}
# Post install information
someNotices() {
printf "%b\n" "${YELLOW}================================NOTICES================================${RC}"
printf "%b\n" "${YELLOW}Notice: You can manage snapshots from GUI with Btrfs Assistant or CLI with snapper.${RC}"
printf "%b\n" "${YELLOW}Notice: You may change (Hourly, daily, weekly, monthly, yearly) timeline settings with Btrfs Assistant GUI.${RC}"
printf "%b\n" "${RED}Notice: If you used the default Fedora disk partitioning during OS installation, the /boot configured as an separate EXT4 partition. Therefore, it cannot be included in root snapshots. Backup separately...${RC}"
printf "%b\n" "${YELLOW}================================NOTICES================================${RC}"
printf "%b\n" "${GREEN}Setup process completed.${RC}"
}
checkEnv
checkEscalationTool
installBtrfsStack
configureSnapper
serviceStartEnable
askInstallGrubBtrfs
someNotices

View File

@ -21,12 +21,12 @@ installDepend() {
alsa-utils alsa-plugins lib32-alsa-plugins alsa-lib lib32-alsa-lib giflib lib32-giflib libpng lib32-libpng \
libldap lib32-libldap openal lib32-openal libxcomposite lib32-libxcomposite libxinerama lib32-libxinerama \
ncurses lib32-ncurses vulkan-icd-loader lib32-vulkan-icd-loader ocl-icd lib32-ocl-icd libva lib32-libva \
gst-plugins-base-libs lib32-gst-plugins-base-libs sdl2"
gst-plugins-base-libs lib32-gst-plugins-base-libs sdl2 lib32-sdl2 v4l-utils lib32-v4l-utils sqlite lib32-sqlite"
$AUR_HELPER -S --needed --noconfirm $DEPENDENCIES $DISTRO_DEPS
;;
apt-get|nala)
DISTRO_DEPS="libasound2 libsdl2 wine64 wine32"
DISTRO_DEPS="libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386 wine64 wine32"
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" dpkg --add-architecture i386
@ -36,7 +36,7 @@ installDepend() {
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES $DISTRO_DEPS
;;
dnf)
if [ "$(rpm -E %fedora)" -le 41 ]; then
if [ "$(rpm -E %fedora)" -le 41 ]; then
"$ESCALATION_TOOL" "$PACKAGER" install ffmpeg ffmpeg-libs -y
"$ESCALATION_TOOL" "$PACKAGER" install -y $DEPENDENCIES
else
@ -69,7 +69,7 @@ installAdditionalDepend() {
version_no_v=$(echo "$version" | tr -d v)
curl -sSLo "lutris_${version_no_v}_all.deb" "https://github.com/lutris/lutris/releases/download/${version}/lutris_${version_no_v}_all.deb"
printf "%b\n" "${YELLOW}Installing Lutris...${RC}"
"$ESCALATION_TOOL" "$PACKAGER" install ./lutris_"${version_no_v}"_all.deb

View File

@ -1,5 +1,4 @@
name = "System Setup"
multi_selectable = false
[[data]]
name = "Arch Linux"
@ -14,16 +13,34 @@ name = "Arch Server Setup"
description = "This command installs a minimal arch server setup under 5 minutes."
script = "arch/server-setup.sh"
task_list = "SI D"
multi_select = false
[[data.entries]]
name ="Linux Neptune for SteamDeck"
description = "Valve's fork of Linux Kernel for the SteamDeck"
script = "arch/linux-neptune.sh"
task_list = "I PFM K"
[[data.entries.preconditions]]
matches = true
data = { file = "/sys/devices/virtual/dmi/id/board_vendor" }
values = [ "Valve" ]
[[data.entries]]
name = "Nvidia Drivers && Hardware Acceleration"
description = "This script installs and configures nvidia drivers with Hardware Acceleration."
script = "arch/nvidia-drivers.sh"
task_list = "I FM SS"
[[data.entries]]
name = "Paru AUR Helper"
description = "Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction.\nTo know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers"
description = "Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction. To know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers"
script = "arch/paru-setup.sh"
task_list = "I"
[[data.entries]]
name = "Yay AUR Helper"
description = "Yet Another Yogurt - An AUR Helper Written in Go.\nTo know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers"
description = "Yet Another Yogurt - An AUR Helper Written in Go. To know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers"
script = "arch/yay-setup.sh"
task_list = "I"
@ -55,7 +72,7 @@ task_list = "I"
[[data.entries]]
name = "RPM Fusion"
description = "RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship.\nThat software is provided as precompiled RPMs for all current Fedora versions and current Red Hat Enterprise Linux or clones versions; you can use the RPM Fusion repositories with tools like yum and PackageKit.\nFor more information visit: https://rpmfusion.org/"
description = "RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship. That software is provided as precompiled RPMs for all current Fedora versions and current Red Hat Enterprise Linux or clones versions; you can use the RPM Fusion repositories with tools like yum and PackageKit. For more information visit: https://rpmfusion.org/"
script = "fedora/rpm-fusion-setup.sh"
task_list = "MP"
@ -71,6 +88,17 @@ description = "Enables Virtualization through dnf"
script = "fedora/virtualization.sh"
task_list = "I"
[[data.entries]]
name = "Btrfs Assistant, Snapper Config, grub-btrfs"
description = "Installs Btrfs Assistant, Snapper, dnf snapper plugin and takes the first root(/) and /home snapshots. Enables snapper-timeline and snapper-cleanup services. Installs Grub-Btrfs. Notice: To perform a system recovery via grub-btrfs, perform a restore operation with Btrfs Assistant GUI after booting into the snapshot. Notice: If you used the default Fedora disk partitioning during OS installation, the /boot configured as an separate EXT4 partition. Therefore, it cannot be included in root snapshots. Backup separately."
script = "fedora/fedora-btrfs-assistant.sh"
task_list = "I PFM SS"
[[data.preconditions]]
matches = true
data = "command_exists"
values = [ "btrfs" ]
[[data]]
name = "Build Prerequisites"
description = "This script is designed to handle the installation of various software dependencies across different Linux distributions"
@ -82,12 +110,14 @@ name = "Full System Cleanup"
description = "This script is designed to remove unnecessary packages, clean old cache files, remove temporary files, and to empty the trash."
script = "system-cleanup.sh"
task_list = "RP PFM"
multi_select = false
[[data]]
name = "Full System Update"
description = "This command updates your system to the latest packages available for your distro"
script = "system-update.sh"
task_list = "PFM"
multi_select = false
[[data]]
name = "Gaming Dependencies"

View File

@ -2,11 +2,6 @@
. ../common-script.sh
# setleds can be used in all distros
# This method works by calling a script using systemd service
# Create a script to toggle numlock
create_file() {
printf "%b\n" "Creating script..."
"$ESCALATION_TOOL" tee "/usr/local/bin/numlock" >/dev/null <<'EOF'
@ -21,7 +16,6 @@ EOF
"$ESCALATION_TOOL" chmod +x /usr/local/bin/numlock
}
# Create a systemd service to run the script on boot
create_service() {
printf "%b\n" "Creating service..."
"$ESCALATION_TOOL" tee "/etc/systemd/system/numlock.service" >/dev/null <<'EOF'
@ -39,7 +33,6 @@ EOF
}
numlockSetup() {
# Check if the script and service files exists
if [ ! -f "/usr/local/bin/numlock" ]; then
create_file
fi

View File

@ -1,8 +1,8 @@
name = "Utilities"
multi_selectable = false
[[data]]
name = "Monitor Control"
multi_select = false
[[data.preconditions]]
matches = true
@ -78,6 +78,7 @@ script = "monitor-control/set_resolutions.sh"
[[data]]
name = "User Account Manager"
multi_select = false
[[data.entries]]
name = "Add User"
@ -104,6 +105,7 @@ name = "Auto Mount Drive"
description = "This utility is designed to help with automating the process of mounting a drive on to your system."
script = "auto-mount.sh"
task_list = "PFM"
multi_select = false
[[data]]
name = "Auto Login"
@ -120,6 +122,7 @@ name = "Bluetooth Manager"
description = "This utility is designed to manage bluetooth in your system"
script = "bluetooth-control.sh"
task_list = "I SS"
multi_select = false
[[data]]
name = "Bootable USB Creator"
@ -133,7 +136,7 @@ task_list = "I FM"
[[data]]
name = "Numlock on Startup"
description = "This utility is designed to configure auto enabling of numlock on boot"
description = "This utility is designed to enable Num Lock at boot, rather than within desktop environments like KDE or GNOME"
script = "numlock.sh"
task_list = "PFM SS"

View File

@ -45,15 +45,10 @@ https://github.com/ChrisTitusTech/neovim
- **Thorium**: Thorium is a Chromium-based browser focused on privacy and performance.
- **Vivaldi**: Vivaldi is a freeware, cross-platform web browser developed by Vivaldi Technologies.
- **waterfox**: Waterfox is the privacy-focused web browser engineered to give you speed, control, and peace of mind on the internet.
- **Alacritty**: Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows.
This command installs and condifures alacritty terminal emulator.
- **Alacritty**: Alacritty is a modern terminal emulator that comes with sensible defaults, but allows for extensive configuration. By integrating with other applications, rather than reimplementing their functionality, it manages to provide a flexible set of features with high performance. The supported platforms currently consist of BSD, Linux, macOS and Windows. This command installs and configures alacritty terminal emulator.
- **Android Debloater**: Universal Android Debloater (UAD) is a tool designed to help users remove bloatware and unnecessary pre-installed applications from Android devices, enhancing performance and user experience.
- **Bash Prompt**: The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems.
It is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful.
This command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository.
https://github.com/ChrisTitusTech/mybash
- **Bottles**: Bottles allows Windows software, like applications and games, to run on Linux.
Bottles also provides tools to categorize, organize and optimize your applications.
- **Bash Prompt**: The .bashrc file is a script that runs every time a new terminal session is started in Unix-like operating systems. It is used to configure the shell session, set up aliases, define functions, and more, making the terminal easier to use and more powerful. This command configures the key sections and functionalities defined in the .bashrc file from CTT's mybash repository. https://github.com/ChrisTitusTech/mybash
- **Bottles**: Bottles allows Windows software, like applications and games, to run on Linux. Bottles also provides tools to categorize, organize and optimize your applications.
- **Docker**: Docker is an open platform that uses OS-level virtualization to deliver software in packages called containers.
- **DWM-Titus**: DWM is a dynamic window manager for X.
It manages windows in tiled, monocle and floating layouts.
@ -61,41 +56,29 @@ All of the layouts can be applied dynamically, optimising the environment for th
This command installs and configures DWM and a desktop manager.
The list of patches applied can be found in CTT's DWM repository
https://github.com/ChrisTitusTech/dwm-titus
- **Fastfetch**: Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily.
It is written mainly in C, with performance and customizability in mind.
This command installs fastfetch and configures from CTT's mybash repository.
https://github.com/ChrisTitusTech/mybash
- **Flatpak / Flathub**: Flatpak is a universal application sandbox for Linux that uses isolated packages from Flathub to prevent conflicts and system alterations, while alleviating dependency concerns.
This command installs Flatpak and adds the Flathub repository
- **Docker**: Docker is an open platform that uses OS-level virtualization to deliver software in packages called containers.
- **Podman**: Podman is a daemon-less open platform that uses OS-level virtualization to deliver software in packages called containers.
- **Podman-compose**: Podman Compose is a tool for defining and running multi-container applications using Podman.
- **Fastfetch**: Fastfetch is a neofetch-like tool for fetching system information and displaying it prettily. It is written mainly in C, with performance and customizability in mind. This command installs fastfetch and configures from CTT's mybash repository. https://github.com/ChrisTitusTech/mybash
- **Flatpak / Flathub**: Flatpak is a universal application sandbox for Linux that uses isolated packages from Flathub to prevent conflicts and system alterations, while alleviating dependency concerns. This command installs Flatpak and adds the Flathub repository
- **Grub Theme**: Installs ChrisTitusTech's Top 5 Bootloader Themes script to allow for easy customization of GRUB.
- **Kitty**: kitty is a free and open-source GPU-accelerated terminal emulator for Linux, macOS, and some BSD distributions, focused on performance and features.
kitty is written in a mix of C and Python programming languages.
This command installs and configures kitty.
- **Kitty**: kitty is a free and open-source GPU-accelerated terminal emulator for Linux, macOS, and some BSD distributions, focused on performance and features. kitty is written in a mix of C and Python programming languages. This command installs and configures kitty.
- **Linutil Installer**: Installs a distro-specific Linutil package locally.
- **Linutil Updater**: Updates your local Linutil crate installation.
- **Rofi**: Rofi is a window switcher, run dialog, ssh-launcher and dmenu replacement that started as a clone of simpleswitcher, written by Sean Pringle and later expanded by Dave Davenport.
This command installs and configures rofi with configuration from CTT's DWM repo.
https://github.com/ChrisTitusTech/dwm-titus
- **Rofi**: Rofi is a window switcher, run dialog, ssh-launcher and dmenu replacement that started as a clone of simpleswitcher, written by Sean Pringle and later expanded by Dave Davenport. This command installs and configures rofi with configuration from CTT's DWM repo. https://github.com/ChrisTitusTech/dwm-titus
- **Waydroid**: Waydroid is an emulator that allows you to run Android apps and games on Linux.
- **ZSH Prompt**: The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh.
This command installs ZSH prompt and provides basic configuration.
- **ZSH Prompt**: The Z shell is a Unix shell that can be used as an interactive login shell and as a command interpreter for shell scripting. Zsh is an extended Bourne shell with many improvements, including some features of Bash, ksh, and tcsh. This command installs ZSH prompt and provides basic configuration.
## Gaming
### Diablo II Resurrected
- **Loot Filter**: This is a loot filter for Diablo II Resurrected.
It's designed to be a simple, clean, and easy to read loot filter that highlights the most important items.
Works on battle.net and single player.
No frills, no config, just highlights high runes and other valuable items.
For more information visit: https://github.com/ChrisTitusTech/d2r-loot-filter
- **Loot Filter**: This is a loot filter for Diablo II Resurrected. It's designed to be a simple, clean, and easy to read loot filter that highlights the most important items. Works on battle.net and single player. No frills, no config, just highlights high runes and other valuable items. For more information visit: https://github.com/ChrisTitusTech/d2r-loot-filter
## Security
- **Firewall Baselines (CTT)**: Developed to ease iptables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall.
This command installs UFW and configures UFW based on CTT's recommended rules.
For more information visit: https://christitus.com/linux-security-mistakes
- **Firewall Baselines (CTT)**: Developed to ease iptables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall. This command installs UFW and configures UFW based on CTT's recommended rules. For more information visit: https://christitus.com/linux-security-mistakes
## System Setup
@ -103,21 +86,20 @@ For more information visit: https://christitus.com/linux-security-mistakes
### Arch Linux
- **Arch Server Setup**: This command installs a minimal arch server setup under 5 minutes.
- **Paru AUR Helper**: Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction.
To know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers
- **Yay AUR Helper**: Yet Another Yogurt - An AUR Helper Written in Go.
To know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers
- **Linux Neptune for SteamDeck**: Valve's fork of Linux Kernel for the SteamDeck
- **Nvidia Drivers && Hardware Acceleration**: This script installs and configures nvidia drivers with Hardware Acceleration.
- **Paru AUR Helper**: Paru is your standard pacman wrapping AUR helper with lots of features and minimal interaction. To know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers
- **Yay AUR Helper**: Yet Another Yogurt - An AUR Helper Written in Go. To know more about AUR helpers visit: https://wiki.archlinux.org/title/AUR_helpers
### Fedora
- **Configure DNF**: Optimizes DNF for parallel downloads
- **Multimedia Codecs**: This script is designed to install multimedia codecs, and to ensure RPM Fusion repositories are installed.
- **Nvidia Proprietary Drivers**: This script is designed to download the proprietary NVIDIA drivers in Fedora.
- **RPM Fusion**: RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship.
That software is provided as precompiled RPMs for all current Fedora versions and current Red Hat Enterprise Linux or clones versions; you can use the RPM Fusion repositories with tools like yum and PackageKit.
For more information visit: https://rpmfusion.org/
- **RPM Fusion**: RPM Fusion provides software that the Fedora Project or Red Hat doesn't want to ship. That software is provided as precompiled RPMs for all current Fedora versions and current Red Hat Enterprise Linux or clones versions; you can use the RPM Fusion repositories with tools like yum and PackageKit. For more information visit: https://rpmfusion.org/
- **Upgrade to a New Fedora Release**: Upgrades system to the next Fedora release
- **Virtualization**: Enables Virtualization through dnf
- **Btrfs Assistant, Snapper Config, grub-btrfs**: Installs Btrfs Assistant, Snapper, dnf snapper plugin and takes the first root(/) and /home snapshots. Enables snapper-timeline and snapper-cleanup services. Installs Grub-Btrfs. Notice: To perform a system recovery via grub-btrfs, perform a restore operation with Btrfs Assistant GUI after booting into the snapshot. Notice: If you used the default Fedora disk partitioning during OS installation, the /boot configured as an separate EXT4 partition. Therefore, it cannot be included in root snapshots. Backup separately.
- **Build Prerequisites**: This script is designed to handle the installation of various software dependencies across different Linux distributions
- **Full System Cleanup**: This script is designed to remove unnecessary packages, clean old cache files, remove temporary files, and to empty the trash.
- **Full System Update**: This command updates your system to the latest packages available for your distro
@ -148,7 +130,7 @@ For more information visit: https://rpmfusion.org/
- **Auto Mount Drive**: This utility is designed to help with automating the process of mounting a drive on to your system.
- **Bluetooth Manager**: This utility is designed to manage bluetooth in your system
- **Numlock on Startup**: This utility is designed to configure auto enabling of numlock on boot
- **Numlock on Startup**: This utility is designed to enable Num Lock at boot, rather than within desktop environments like KDE or GNOME
- **Ollama**: This utility is designed to manage ollama in your system
- **Service Manager**: This utility is designed to manage services in your system
- **WiFi Manager**: This utility is designed to manage wifi in your system

View File

@ -36,6 +36,10 @@ Defaults to \fIdefault\fR.
\fB\-\-override\-validation\fR
Show all available entries, disregarding compatibility checks. (\fBUNSAFE\fR)
.TP
\fB\-\-size\-bypass\fR
Bypass the terminal size limit
.TP
\fB\-h\fR, \fB\-\-help\fR
Print help.

View File

@ -15,7 +15,6 @@ tips = ["rand"]
[dependencies]
clap = { version = "4.5.20", features = ["derive"] }
crossterm = "0.28.1"
ego-tree = { workspace = true }
oneshot = "0.1.8"
portable-pty = "0.8.1"
@ -27,6 +26,7 @@ rand = { version = "0.8.5", optional = true }
linutil_core = { path = "../core", version = "24.9.28" }
tree-sitter-highlight = "0.24.3"
tree-sitter-bash = "0.23.1"
textwrap = "0.16.1"
anstyle = "1.0.8"
ansi-to-tui = "7.0.0"
zips = "0.1.7"

View File

@ -2,8 +2,8 @@ use std::borrow::Cow;
use crate::{float::FloatContent, hint::Shortcut};
use crossterm::event::{KeyCode, KeyEvent, MouseEvent, MouseEventKind};
use ratatui::{
crossterm::event::{KeyCode, KeyEvent, MouseEvent, MouseEventKind},
layout::Alignment,
prelude::*,
widgets::{Block, Borders, Clear, List},
@ -60,6 +60,7 @@ impl FloatContent for ConfirmPrompt {
fn draw(&mut self, frame: &mut Frame, area: Rect) {
let block = Block::default()
.borders(Borders::ALL)
.border_set(ratatui::symbols::border::ROUNDED)
.title(" Confirm selections ")
.title_bottom(" [y] to continue, [n] to abort ")
.title_alignment(Alignment::Center)

View File

@ -1,8 +1,8 @@
use crate::{state::ListEntry, theme::Theme};
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
use ego_tree::NodeId;
use linutil_core::Tab;
use ratatui::{
crossterm::event::{KeyCode, KeyEvent, KeyModifiers},
layout::{Position, Rect},
style::{Color, Style},
text::Span,
@ -123,7 +123,12 @@ impl Filter {
//Create the search bar widget
let search_bar = Paragraph::new(display_text)
.block(Block::default().borders(Borders::ALL).title(" Search "))
.block(
Block::default()
.borders(Borders::ALL)
.border_set(ratatui::symbols::border::ROUNDED)
.title(" Search "),
)
.style(Style::default().fg(search_color));
//Render the search bar (First chunk of the screen)

View File

@ -1,5 +1,5 @@
use crossterm::event::{KeyCode, KeyEvent, MouseEvent};
use ratatui::{
crossterm::event::{KeyCode, KeyEvent, MouseEvent},
layout::{Constraint, Direction, Layout, Rect},
Frame,
};

View File

@ -8,9 +8,8 @@ use crate::{float::FloatContent, hint::Shortcut};
use linutil_core::Command;
use crossterm::event::{KeyCode, KeyEvent, MouseEvent, MouseEventKind};
use ratatui::{
crossterm::event::{KeyCode, KeyEvent, MouseEvent, MouseEventKind},
layout::Rect,
style::{Style, Stylize},
text::Line,
@ -20,16 +19,19 @@ use ratatui::{
use ansi_to_tui::IntoText;
use textwrap::wrap;
use tree_sitter_bash as hl_bash;
use tree_sitter_highlight::{self as hl, HighlightEvent};
use zips::zip_result;
pub struct FloatingText {
pub src: Vec<String>,
pub src: String,
wrapped_lines: Vec<String>,
max_line_width: usize,
v_scroll: usize,
h_scroll: usize,
mode_title: String,
wrap_words: bool,
frame_height: usize,
}
@ -108,12 +110,6 @@ fn get_highlighted_string(s: &str) -> Option<String> {
Some(output)
}
macro_rules! max_width {
($($lines:tt)+) => {{
$($lines)+.iter().fold(0, |accum, val| accum.max(val.len()))
}}
}
#[inline]
fn get_lines(s: &str) -> Vec<&str> {
s.lines().collect::<Vec<_>>()
@ -125,50 +121,49 @@ fn get_lines_owned(s: &str) -> Vec<String> {
}
impl FloatingText {
pub fn new(text: String, title: &str) -> Self {
let src = get_lines(&text)
.into_iter()
.map(|s| s.to_string())
.collect::<Vec<_>>();
pub fn new(text: String, title: &str, wrap_words: bool) -> Self {
let max_line_width = 80;
let wrapped_lines = if wrap_words {
wrap(&text, max_line_width)
.into_iter()
.map(|cow| cow.into_owned())
.collect()
} else {
get_lines_owned(&text)
};
let max_line_width = max_width!(src);
Self {
src,
src: text,
wrapped_lines,
mode_title: title.to_string(),
max_line_width,
v_scroll: 0,
h_scroll: 0,
wrap_words,
frame_height: 0,
}
}
pub fn from_command(command: &Command, title: String) -> Option<Self> {
let (max_line_width, src) = match command {
Command::Raw(cmd) => {
// just apply highlights directly
(max_width!(get_lines(cmd)), Some(cmd.clone()))
}
Command::LocalFile { file, .. } => {
// have to read from tmp dir to get cmd src
let raw = std::fs::read_to_string(file)
.map_err(|_| format!("File not found: {:?}", file))
.unwrap();
let src = match command {
Command::Raw(cmd) => Some(cmd.clone()),
Command::LocalFile { file, .. } => std::fs::read_to_string(file)
.map_err(|_| format!("File not found: {:?}", file))
.ok(),
Command::None => None,
}?;
(max_width!(get_lines(&raw)), Some(raw))
}
// If command is a folder, we don't display a preview
Command::None => (0usize, None),
};
let src = get_lines_owned(&get_highlighted_string(&src?)?);
let max_line_width = 80;
let wrapped_lines = get_lines_owned(&get_highlighted_string(&src)?);
Some(Self {
src,
wrapped_lines,
mode_title: title,
max_line_width,
h_scroll: 0,
v_scroll: 0,
wrap_words: false,
frame_height: 0,
})
}
@ -197,6 +192,20 @@ impl FloatingText {
self.h_scroll += 1;
}
}
fn update_wrapping(&mut self, width: usize) {
if self.max_line_width != width {
self.max_line_width = width;
self.wrapped_lines = if self.wrap_words {
wrap(&self.src, width)
.into_iter()
.map(|cow| cow.into_owned())
.collect()
} else {
get_lines_owned(&get_highlighted_string(&self.src).unwrap_or(self.src.clone()))
};
}
}
}
impl FloatContent for FloatingText {
@ -206,6 +215,7 @@ impl FloatContent for FloatingText {
// Define the Block with a border and background color
let block = Block::default()
.borders(Borders::ALL)
.border_set(ratatui::symbols::border::ROUNDED)
.title(self.mode_title.clone())
.title_alignment(ratatui::layout::Alignment::Center)
.title_style(Style::default().reversed())
@ -217,13 +227,22 @@ impl FloatContent for FloatingText {
// Calculate the inner area to ensure text is not drawn over the border
let inner_area = block.inner(area);
let Rect { height, .. } = inner_area;
let Rect { width, height, .. } = inner_area;
self.update_wrapping(width as usize);
let lines = self
.src
.wrapped_lines
.iter()
.skip(self.v_scroll)
.take(height as usize)
.flat_map(|l| l.into_text().unwrap())
.flat_map(|l| {
if self.wrap_words {
vec![Line::raw(l.clone())]
} else {
l.into_text().unwrap().lines
}
})
.map(|line| {
let mut skipped = 0;
let mut spans = line

View File

@ -14,13 +14,17 @@ use std::{
use crate::theme::Theme;
use clap::Parser;
use crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyEventKind},
style::ResetColor,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
ExecutableCommand,
use ratatui::{
backend::CrosstermBackend,
crossterm::{
event::{self, DisableMouseCapture, EnableMouseCapture, Event, KeyEventKind},
style::ResetColor,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
ExecutableCommand,
},
Terminal,
};
use ratatui::{backend::CrosstermBackend, Terminal};
use state::AppState;
// Linux utility toolbox
@ -33,12 +37,15 @@ struct Args {
#[arg(long, default_value_t = false)]
#[clap(help = "Show all available options, disregarding compatibility checks (UNSAFE)")]
override_validation: bool,
#[arg(long, default_value_t = false)]
#[clap(help = "Bypass the terminal size limit")]
size_bypass: bool,
}
fn main() -> io::Result<()> {
let args = Args::parse();
let mut state = AppState::new(args.theme, args.override_validation);
let mut state = AppState::new(args.theme, args.override_validation, args.size_bypass);
stdout().execute(EnterAlternateScreen)?;
stdout().execute(EnableMouseCapture)?;

View File

@ -1,11 +1,11 @@
use crate::{float::FloatContent, hint::Shortcut};
use crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind};
use linutil_core::Command;
use oneshot::{channel, Receiver};
use portable_pty::{
ChildKiller, CommandBuilder, ExitStatus, MasterPty, NativePtySystem, PtySize, PtySystem,
};
use ratatui::{
crossterm::event::{KeyCode, KeyEvent, KeyModifiers, MouseEvent, MouseEventKind},
layout::{Rect, Size},
style::{Color, Style, Stylize},
text::{Line, Span},
@ -53,6 +53,7 @@ impl FloatContent for RunningCommand {
// Display a block indicating the command is running
Block::default()
.borders(Borders::ALL)
.border_set(ratatui::symbols::border::ROUNDED)
.title_top(Line::from("Running the command....").centered())
.title_style(Style::default().reversed())
.title_bottom(Line::from("Press Ctrl-C to KILL the command"))
@ -80,6 +81,7 @@ impl FloatContent for RunningCommand {
Block::default()
.borders(Borders::ALL)
.border_set(ratatui::symbols::border::ROUNDED)
.title_top(title_line.centered())
};

View File

@ -7,12 +7,12 @@ use crate::{
running_command::RunningCommand,
theme::Theme,
};
use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers, MouseEvent, MouseEventKind};
use ego_tree::NodeId;
use linutil_core::{ListNode, Tab};
use linutil_core::{ListNode, TabList};
#[cfg(feature = "tips")]
use rand::Rng;
use ratatui::{
crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers, MouseEvent, MouseEventKind},
layout::{Alignment, Constraint, Direction, Flex, Layout, Position, Rect},
style::{Style, Stylize},
text::{Line, Span, Text},
@ -20,7 +20,6 @@ use ratatui::{
Frame,
};
use std::rc::Rc;
use temp_dir::TempDir;
const MIN_WIDTH: u16 = 100;
const MIN_HEIGHT: u16 = 25;
@ -31,6 +30,7 @@ D - disk modifications (ex. partitioning) (privileged)
FI - flatpak installation
FM - file modification
I - installation (privileged)
K - kernel modifications (privileged)
MP - package manager actions
SI - full system installation
SS - systemd actions (privileged)
@ -40,14 +40,14 @@ P* - privileged *
";
pub struct AppState {
/// This must be passed to retain the temp dir until the end of the program
_temp_dir: TempDir,
/// Areas of tabs
areas: Option<Areas>,
/// Selected theme
theme: Theme,
/// Currently focused area
pub focus: Focus,
/// List of tabs
tabs: Vec<Tab>,
tabs: TabList,
/// Current tab
current_tab: ListState,
/// This stack keeps track of our "current directory". You can think of it as `pwd`. but not
@ -62,7 +62,7 @@ pub struct AppState {
drawable: bool,
#[cfg(feature = "tips")]
tip: String,
areas: Option<Areas>,
size_bypass: bool,
}
pub enum Focus {
@ -92,12 +92,12 @@ enum SelectedItem {
}
impl AppState {
pub fn new(theme: Theme, override_validation: bool) -> Self {
let (temp_dir, tabs) = linutil_core::get_tabs(!override_validation);
pub fn new(theme: Theme, override_validation: bool, size_bypass: bool) -> Self {
let tabs = linutil_core::get_tabs(!override_validation);
let root_id = tabs[0].tree.root().id();
let mut state = Self {
_temp_dir: temp_dir,
areas: None,
theme,
focus: Focus::List,
tabs,
@ -110,7 +110,7 @@ impl AppState {
drawable: false,
#[cfg(feature = "tips")]
tip: get_random_tip(),
areas: None,
size_bypass,
};
state.update_items();
@ -160,12 +160,10 @@ impl AppState {
hints.push(Shortcut::new("Select item below", ["j", "Down"]));
hints.push(Shortcut::new("Next theme", ["t"]));
hints.push(Shortcut::new("Previous theme", ["T"]));
if self.is_current_tab_multi_selectable() {
hints.push(Shortcut::new("Toggle multi-selection mode", ["v"]));
hints.push(Shortcut::new("Multi-selection mode", ["v"]));
if self.multi_select {
hints.push(Shortcut::new("Select multiple commands", ["Space"]));
}
hints.push(Shortcut::new("Next tab", ["Tab"]));
hints.push(Shortcut::new("Previous tab", ["Shift-Tab"]));
hints.push(Shortcut::new("Important actions guide", ["g"]));
@ -195,7 +193,9 @@ impl AppState {
pub fn draw(&mut self, frame: &mut Frame) {
let terminal_size = frame.area();
if terminal_size.width < MIN_WIDTH || terminal_size.height < MIN_HEIGHT {
if !self.size_bypass
&& (terminal_size.height < MIN_HEIGHT || terminal_size.width < MIN_WIDTH)
{
let warning = Paragraph::new(format!(
"Terminal size too small:\nWidth = {} Height = {}\n\nMinimum size:\nWidth = {} Height = {}",
terminal_size.width,
@ -222,19 +222,19 @@ impl AppState {
self.drawable = true;
}
let label_block =
Block::default()
.borders(Borders::all())
.border_set(ratatui::symbols::border::Set {
top_left: " ",
top_right: " ",
bottom_left: " ",
bottom_right: " ",
vertical_left: " ",
vertical_right: " ",
horizontal_top: "*",
horizontal_bottom: "*",
});
let label_block = Block::default()
.borders(Borders::ALL)
.border_set(ratatui::symbols::border::ROUNDED)
.border_set(ratatui::symbols::border::Set {
top_left: " ",
top_right: " ",
bottom_left: " ",
bottom_right: " ",
vertical_left: " ",
vertical_right: " ",
horizontal_top: "*",
horizontal_bottom: "*",
});
let str1 = "Linutil ";
let str2 = "by Chris Titus";
let label = Paragraph::new(Line::from(vec![
@ -258,7 +258,8 @@ impl AppState {
let keybinds_block = Block::default()
.title(format!(" {} ", keybind_scope))
.borders(Borders::all());
.borders(Borders::ALL)
.border_set(ratatui::symbols::border::ROUNDED);
let keybinds = create_shortcut_list(shortcuts, keybind_render_width);
let n_lines = keybinds.len() as u16;
@ -307,7 +308,11 @@ impl AppState {
};
let list = List::new(tabs)
.block(Block::default().borders(Borders::ALL))
.block(
Block::default()
.borders(Borders::ALL)
.border_set(ratatui::symbols::border::ROUNDED),
)
.highlight_style(tab_hl_style)
.highlight_symbol(self.theme.tab_icon());
frame.render_stateful_widget(list, left_chunks[1], &mut self.current_tab);
@ -342,7 +347,12 @@ impl AppState {
let (indicator, style) = if is_selected {
(self.theme.multi_select_icon(), Style::default().bold())
} else {
("", Style::new())
let ms_style = if self.multi_select && !node.multi_select {
Style::default().fg(self.theme.multi_select_disabled_color())
} else {
Style::new()
};
("", ms_style)
};
if *has_children {
Line::from(format!(
@ -352,6 +362,7 @@ impl AppState {
indicator
))
.style(self.theme.dir_color())
.patch_style(style)
} else {
Line::from(format!(
"{} {} {}",
@ -369,13 +380,21 @@ impl AppState {
|ListEntry {
node, has_children, ..
}| {
let ms_style = if self.multi_select && !node.multi_select {
Style::default().fg(self.theme.multi_select_disabled_color())
} else {
Style::new()
};
if *has_children {
Line::from(" ").style(self.theme.dir_color())
Line::from(" ")
.style(self.theme.dir_color())
.patch_style(ms_style)
} else {
Line::from(format!("{} ", node.task_list))
.alignment(Alignment::Right)
.style(self.theme.cmd_color())
.bold()
.patch_style(ms_style)
}
},
));
@ -405,6 +424,7 @@ impl AppState {
.block(
Block::default()
.borders(Borders::ALL & !Borders::RIGHT)
.border_set(ratatui::symbols::border::ROUNDED)
.title(title)
.title_bottom(bottom_title),
)
@ -414,6 +434,7 @@ impl AppState {
let disclaimer_list = List::new(task_items).highlight_style(style).block(
Block::default()
.borders(Borders::ALL & !Borders::LEFT)
.border_set(ratatui::symbols::border::ROUNDED)
.title(task_list_title),
);
@ -544,6 +565,13 @@ impl AppState {
// enabled, need to clear it to prevent state corruption
if !self.multi_select {
self.selected_commands.clear()
} else {
// Prevents non multi_selectable cmd from being pushed into the selected list
if let Some(node) = self.get_selected_node() {
if !node.multi_select {
self.selected_commands.retain(|cmd| cmd.name != node.name);
}
}
}
}
ConfirmStatus::Confirm => self.handle_confirm_command(),
@ -621,41 +649,31 @@ impl AppState {
}
fn toggle_multi_select(&mut self) {
if self.is_current_tab_multi_selectable() {
self.multi_select = !self.multi_select;
if !self.multi_select {
self.selected_commands.clear();
}
self.multi_select = !self.multi_select;
if !self.multi_select {
self.selected_commands.clear();
}
}
fn toggle_selection(&mut self) {
if let Some(command) = self.get_selected_node() {
if self.selected_commands.contains(&command) {
self.selected_commands.retain(|c| c != &command);
} else {
self.selected_commands.push(command);
if let Some(node) = self.get_selected_node() {
if node.multi_select {
if self.selected_commands.contains(&node) {
self.selected_commands.retain(|c| c != &node);
} else {
self.selected_commands.push(node);
}
}
}
}
pub fn is_current_tab_multi_selectable(&self) -> bool {
let index = self.current_tab.selected().unwrap_or(0);
self.tabs
.get(index)
.map_or(false, |tab| tab.multi_selectable)
}
fn update_items(&mut self) {
self.filter.update_items(
&self.tabs,
self.current_tab.selected().unwrap(),
self.visit_stack.last().unwrap().0,
);
if !self.is_current_tab_multi_selectable() {
self.multi_select = false;
self.selected_commands.clear();
}
let len = self.filter.item_list().len();
if len > 0 {
let current = self.selection.selected().unwrap_or(0);
@ -774,7 +792,8 @@ impl AppState {
fn enable_description(&mut self) {
if let Some(command_description) = self.get_selected_description() {
if !command_description.is_empty() {
let description = FloatingText::new(command_description, "Command Description");
let description =
FloatingText::new(command_description, "Command Description", true);
self.spawn_float(description, 80, 80);
}
}
@ -860,7 +879,7 @@ impl AppState {
fn toggle_task_list_guide(&mut self) {
self.spawn_float(
FloatingText::new(ACTIONS_GUIDE.to_string(), "Important Actions Guide"),
FloatingText::new(ACTIONS_GUIDE.to_string(), "Important Actions Guide", true),
80,
80,
);

View File

@ -28,6 +28,13 @@ impl Theme {
}
}
pub fn multi_select_disabled_color(&self) -> Color {
match self {
Theme::Default => Color::DarkGray,
Theme::Compatible => Color::DarkGray,
}
}
pub fn tab_color(&self) -> Color {
match self {
Theme::Default => Color::Rgb(255, 255, 85),

View File

@ -11,7 +11,7 @@ pub fn userguide() -> Result<String, DynError> {
let mut md = String::new();
md.push_str("<!-- THIS FILE IS GENERATED BY cargo xtask docgen -->\n# Walkthrough\n");
let tabs = linutil_core::get_tabs(false).1;
let tabs = linutil_core::get_tabs(false);
for tab in tabs {
#[cfg(debug_assertions)]
@ -24,7 +24,7 @@ pub fn userguide() -> Result<String, DynError> {
#[cfg(debug_assertions)]
println!(" Directory: {}", entry.name);
if entry.name != "root".to_string() {
if entry.name != "root" {
md.push_str(&format!("\n### {}\n\n", entry.name));
}
@ -36,18 +36,16 @@ pub fn userguide() -> Result<String, DynError> {
current_dir
));
} */ // Commenting this for now, might be a good idea later
} else {
if !entry.description.is_empty() {
#[cfg(debug_assertions)]
println!(" Entry: {}", entry.name);
#[cfg(debug_assertions)]
println!(" Description: {}", entry.description);
} else if !entry.description.is_empty() {
#[cfg(debug_assertions)]
println!(" Entry: {}", entry.name);
#[cfg(debug_assertions)]
println!(" Description: {}", entry.description);
md.push_str(&format!("- **{}**: {}\n", entry.name, entry.description));
} /* else {
md.push_str(&format!("- **{}**\n", entry.name));
} */ // https://github.com/ChrisTitusTech/linutil/pull/753
}
md.push_str(&format!("- **{}**: {}\n", entry.name, entry.description));
} /* else {
md.push_str(&format!("- **{}**\n", entry.name));
} */ // https://github.com/ChrisTitusTech/linutil/pull/753
}
}