Compare commits

...

12 Commits

Author SHA1 Message Date
Dhruv Mistry
adb57fcaeb
Merge e3397f832929881c1282e5e22fda0094c954178e into e88020cff09f271af6361c43e60dbfdeaafb975a 2025-03-04 08:58:56 -05:00
Jaredy899
e88020cff0
fix nala remove (#1038) 2025-02-28 15:21:15 -06:00
Jaredy899
24eb977fd4
fix(dwm-titus): Multiple fixes (#1032)
* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update core/tabs/applications-setup/dwmtitus-setup.sh

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* Update dwmtitus-setup.sh

* add apk

* Update dwmtitus-setup.sh

---------

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>
2025-02-28 15:20:20 -06:00
Jaredy899
0fc8f07750
fix(compile-setup): dnf compile (#1028)
* fix compile for fedora, rocky, old fedoras

* Update compile-setup.sh

* Update compile-setup.sh

* Update compile-setup.sh

* Update compile-setup.sh

* Update core/tabs/system-setup/compile-setup.sh

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>

* Update core/tabs/system-setup/compile-setup.sh

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>

* Update compile-setup.sh

---------

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>
2025-02-28 15:15:41 -06:00
Andrii
95e6c357d7
perf: increase rendering efficiency (#1017)
* Efficient rendering

* fix unused import

---------

Co-authored-by: Chris Titus <contact@christitus.com>
2025-02-28 15:11:50 -06:00
Sayeed Mahmood Evrenos
5f6e18b2cc
fix: remove redundant AVX2 check for Zen Browser installation (#1014)
This update removes the AVX2-specific logic from the installZenBrowser function. The Zen Browser team discontinued AVX2-optimized releases due to recurring build issues in GitHub workflows, so we now only install zen-browser-bin from AUR. This change streamlines the installation process.
2025-02-28 14:56:39 -06:00
Adam Perkowski
f2f997eb7f
ui: "unselect" the current tab when in search mode (#1003) 2025-02-28 14:53:23 -06:00
mateuszkozako
009c8b079a
feat(fastfetch-setup): shell integration setup (#1002)
* feat: add shell integration setup for fastfetch

* Update fastfetch-setup.sh - improved logic

* Update core/tabs/applications-setup/fastfetch-setup.sh

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>

* Update core/tabs/applications-setup/fastfetch-setup.sh

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>

* Update core/tabs/applications-setup/fastfetch-setup.sh

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>

* Update core/tabs/applications-setup/fastfetch-setup.sh

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>

* Update core/tabs/applications-setup/fastfetch-setup.sh

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>

* Update fastfetch-setup.sh - added support for other shells

* Update fastfetch-setup.sh - fmt

* Refactor fastfetch-setup.sh for consistent indentation and formatting

---------

Co-authored-by: Adam Perkowski <adas1per@protonmail.com>
2025-02-28 14:50:57 -06:00
Angaddeep Singh
7f82c66475
refact(brave-install): simplify script (#980)
* simplifying Brave install

* Update brave.sh

---------

Co-authored-by: Angaddeep Singh <deepangad14@gmail.com>
2025-02-28 14:47:14 -06:00
Adam Perkowski
e3397f8329
use newgrp
Co-authored-by: Jeevitha Kannan K S <ksjeevithakannan123@gmail.com>
2024-11-17 02:40:09 +01:00
Dhruv Mistry
15e3a10009
Update docker-setup.sh 2024-11-13 10:19:51 +05:30
Dhruv Mistry
aa392abaf8
Adding current user to DOCKER group
When i used the docker setup in LINUTIL it didn't add the user to the docker group so this is the edited file
2024-11-12 18:09:03 +05:30
10 changed files with 201 additions and 115 deletions

View File

@ -5,44 +5,7 @@
installBrave() {
if ! command_exists com.brave.Browser && ! command_exists brave; then
printf "%b\n" "${YELLOW}Installing Brave...${RC}"
case "$PACKAGER" in
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y curl
"$ESCALATION_TOOL" curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/brave-browser-archive-keyring.gpg] https://brave-browser-apt-release.s3.brave.com/ stable main" | "$ESCALATION_TOOL" tee /etc/apt/sources.list.d/brave-browser-release.list
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" install -y brave-browser
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -y curl
"$ESCALATION_TOOL" rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
"$ESCALATION_TOOL" "$PACKAGER" addrepo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
"$ESCALATION_TOOL" "$PACKAGER" refresh
"$ESCALATION_TOOL" "$PACKAGER" --non-interactive install brave-browser
;;
pacman)
"$AUR_HELPER" -S --needed --noconfirm brave-bin
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y dnf-plugins-core
dnf_version=$(dnf --version | head -n 1 | cut -d '.' -f 1)
if [ "$dnf_version" -eq 4 ]; then
"$ESCALATION_TOOL" "$PACKAGER" config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
else
"$ESCALATION_TOOL" "$PACKAGER" config-manager addrepo --from-repofile=https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
fi
"$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
;;
esac
curl -fsS https://dl.brave.com/install.sh | sh
else
printf "%b\n" "${GREEN}Brave Browser is already installed.${RC}"
fi
@ -50,5 +13,4 @@ installBrave() {
checkEnv
checkEscalationTool
checkAURHelper
installBrave

View File

@ -7,11 +7,7 @@ installZenBrowser() {
printf "%b\n" "${YELLOW}Installing Zen Browser...${RC}"
case "$PACKAGER" in
pacman)
if grep -q avx2 /proc/cpuinfo; then
"$AUR_HELPER" -S --needed --noconfirm zen-browser-avx2-bin
else
"$AUR_HELPER" -S --needed --noconfirm zen-browser-bin
fi
"$AUR_HELPER" -S --needed --noconfirm zen-browser-bin
;;
*)
checkFlatpak

View File

@ -53,6 +53,11 @@ install_docker() {
esac
startAndEnableService docker
printf "%b\n" "${YELLOW}Adding current user to the docker group...${RC}"
"$ESCALATION_TOOL" usermod -aG docker "$USER"
newgrp docker
printf "%b\n" "${GREEN}Current user added to the docker group successfully.${RC}"
}
install_docker_compose() {
@ -109,4 +114,4 @@ install_components() {
checkEnv
checkEscalationTool
install_components
install_components

View File

@ -1,20 +1,27 @@
#!/bin/sh -e
#!/bin/sh
. ../common-script.sh
. ../common-service-script.sh
setupDWM() {
printf "%b\n" "${YELLOW}Installing DWM-Titus...${RC}"
case "$PACKAGER" in # Install pre-Requisites
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 libxcb git unzip flameshot lxappearance feh mate-polkit meson libev uthash libconfig
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 git unzip flameshot lxappearance feh mate-polkit
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add build-base libxinerama-dev libxft-dev imlib2-dev font-dejavu dbus-x11 git unzip flameshot feh polkit
;;
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y build-essential libx11-dev libxinerama-dev libxft-dev libimlib2-dev libx11-xcb-dev libfontconfig1 libx11-6 libxft2 libxinerama1 libxcb-res0-dev git unzip flameshot lxappearance feh mate-polkit
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" groupinstall -y "Development Tools"
"$ESCALATION_TOOL" "$PACKAGER" install -y "@development-tools" || "$ESCALATION_TOOL" "$PACKAGER" group install -y "Development Tools"
"$ESCALATION_TOOL" "$PACKAGER" install -y libX11-devel libXinerama-devel libXft-devel imlib2-devel libxcb-devel unzip flameshot lxappearance feh mate-polkit # no need to include git here as it should be already installed via "Development Tools"
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -y make libX11-devel libXinerama-devel libXft-devel imlib2-devel gcc
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
exit 1
@ -22,6 +29,34 @@ setupDWM() {
esac
}
setupPicomDependencies() {
printf "%b\n" "${YELLOW}Installing Picom dependencies if not already installed${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm libxcb meson libev uthash libconfig
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add libxcb-dev meson libev-dev uthash-dev libconfig-dev pixman-dev xcb-util-image-dev xcb-util-renderutil-dev pcre2-dev libepoxy-dev dbus-dev xcb-util-dev
;;
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y libxcb1-dev libxcb-res0-dev libconfig-dev libdbus-1-dev libegl-dev libev-dev libgl-dev libepoxy-dev libpcre2-dev libpixman-1-dev libx11-xcb-dev libxcb1-dev libxcb-composite0-dev libxcb-damage0-dev libxcb-dpms0-dev libxcb-glx0-dev libxcb-image0-dev libxcb-present-dev libxcb-randr0-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-shape0-dev libxcb-util-dev libxcb-xfixes0-dev libxext-dev meson ninja-build uthash-dev
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y libxcb-devel dbus-devel gcc git libconfig-devel libdrm-devel libev-devel libX11-devel libX11-xcb libXext-devel libxcb-devel libGL-devel libEGL-devel libepoxy-devel meson pcre2-devel pixman-devel uthash-devel xcb-util-image-devel xcb-util-renderutil-devel xorg-x11-proto-devel xcb-util-devel
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -y libxcb-devel libxcb-devel dbus-1-devel gcc git libconfig-devel libdrm-devel libev-devel libX11-devel libX11-xcb1 libXext-devel libxcb-devel Mesa-libGL-devel Mesa-libEGL-devel libepoxy-devel meson pcre2-devel uthash-devel xcb-util-image-devel libpixman-1-0-devel xcb-util-renderutil-devel xcb-util-devel
;;
*)
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
printf "%b\n" "${GREEN}Picom dependencies installed successfully${RC}"
}
makeDWM() {
cd "$HOME" && git clone https://github.com/ChrisTitusTech/dwm-titus.git # CD to Home directory to install dwm-titus
# This path can be changed (e.g. to linux-toolbox directory)
@ -35,8 +70,7 @@ install_nerd_font() {
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip"
FONT_INSTALLED=$(fc-list | grep -i "Meslo")
# Replace -n test with standard test
if [ ! -z "$FONT_INSTALLED" ]; then
if [ -n "$FONT_INSTALLED" ]; then
printf "%b\n" "${GREEN}Meslo Nerd-fonts are already installed.${RC}"
return 0
fi
@ -185,12 +219,18 @@ setupDisplayManager() {
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm xorg-xinit xorg-server
;;
apk)
"$ESCALATION_TOOL" setup-xorg-base
;;
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y xorg xinit
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -y xinit xorg-x11-server
;;
*)
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
@ -200,44 +240,40 @@ setupDisplayManager() {
printf "%b\n" "${YELLOW}Setting up Display Manager${RC}"
currentdm="none"
for dm in gdm sddm lightdm; do
if systemctl is-active --quiet "$dm.service"; then
if command -v "$dm" >/dev/null 2>&1 || isServiceActive "$dm"; then
currentdm="$dm"
break
fi
done
printf "%b\n" "${GREEN}Current display manager: $currentdm${RC}"
if [ "$currentdm" = "none" ]; then
while : ; do
printf "%b\n" "${YELLOW}--------------------------${RC}"
printf "%b\n" "${YELLOW}Pick your Display Manager ${RC}"
printf "%b\n" "${YELLOW}1. SDDM ${RC}"
printf "%b\n" "${YELLOW}2. LightDM ${RC}"
printf "%b\n" "${YELLOW}3. GDM ${RC}"
printf "%b\n" "${YELLOW}4. None ${RC}"
printf "%b" "${YELLOW}Please select one: ${RC}"
read -r choice
case "$choice" in
1)
DM="sddm"
break
;;
2)
DM="lightdm"
break
;;
3)
DM="gdm"
break
;;
4)
printf "%b\n" "${GREEN}No display manager will be installed${RC}"
return 0
;;
*)
printf "%b\n" "${RED}Invalid selection! Please choose 1, 2, 3, or 4.${RC}"
;;
esac
done
printf "%b\n" "${YELLOW}--------------------------${RC}"
printf "%b\n" "${YELLOW}Pick your Display Manager ${RC}"
printf "%b\n" "${YELLOW}1. SDDM ${RC}"
printf "%b\n" "${YELLOW}2. LightDM ${RC}"
printf "%b\n" "${YELLOW}3. GDM ${RC}"
printf "%b\n" "${YELLOW}4. None ${RC}"
printf "%b" "${YELLOW}Please select one: ${RC}"
read -r choice
case "$choice" in
1)
DM="sddm"
;;
2)
DM="lightdm"
;;
3)
DM="gdm"
;;
4)
printf "%b\n" "${GREEN}No display manager will be installed${RC}"
return 0
;;
*)
printf "%b\n" "${RED}Invalid selection! Please choose 1, 2, 3, or 4.${RC}"
return 1
;;
esac
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm "$DM"
@ -245,29 +281,41 @@ setupDisplayManager() {
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm lightdm-gtk-greeter
fi
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add "$DM"
if [ "$DM" = "lightdm" ]; then
"$ESCALATION_TOOL" "$PACKAGER" add lightdm-gtk-greeter
fi
;;
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DM"
;;
dnf)
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DM"
;;
zypper)
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DM"
;;
*)
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
printf "%b\n" "${GREEN}$DM installed successfully${RC}"
systemctl enable "$DM"
enableService "$DM"
fi
}
install_slstatus() {
printf "Do you want to install slstatus? (y/N): " # using printf instead of 'echo' to avoid newline, -n flag for 'echo' is not supported in POSIX
read -r response # -r flag to prevent backslashes from being interpreted
printf "Do you want to install slstatus? (y/N): "
read -r response
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
printf "%b\n" "${YELLOW}Installing slstatus${RC}"
cd "$HOME/dwm-titus/slstatus" || { printf "%b\n" "${RED}Failed to change directory to slstatus${RC}"; return 1; }
cd "$HOME/dwm-titus/slstatus" || {
printf "%b\n" "${RED}Failed to change directory to slstatus${RC}"
return 1
}
if "$ESCALATION_TOOL" make clean install; then
printf "%b\n" "${GREEN}slstatus installed successfully${RC}"
else
@ -284,6 +332,7 @@ checkEnv
checkEscalationTool
setupDisplayManager
setupDWM
setupPicomDependencies
makeDWM
install_slstatus
install_nerd_font

View File

@ -6,20 +6,20 @@ installFastfetch() {
if ! command_exists fastfetch; then
printf "%b\n" "${YELLOW}Installing Fastfetch...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch
;;
apt-get|nala)
curl -sSLo /tmp/fastfetch.deb https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb
"$ESCALATION_TOOL" "$PACKAGER" install -y /tmp/fastfetch.deb
rm /tmp/fastfetch.deb
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add fastfetch
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y fastfetch
;;
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm fastfetch
;;
apt-get | nala)
curl -sSLo /tmp/fastfetch.deb https://github.com/fastfetch-cli/fastfetch/releases/latest/download/fastfetch-linux-amd64.deb
"$ESCALATION_TOOL" "$PACKAGER" install -y /tmp/fastfetch.deb
rm /tmp/fastfetch.deb
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add fastfetch
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y fastfetch
;;
esac
else
printf "%b\n" "${GREEN}Fastfetch is already installed.${RC}"
@ -35,7 +35,52 @@ setupFastfetchConfig() {
curl -sSLo "${HOME}/.config/fastfetch/config.jsonc" https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/config.jsonc
}
setupFastfetchShell() {
printf "%b\n" "${YELLOW}Configuring shell integration...${RC}"
current_shell=$(basename "$SHELL")
rc_file=""
case "$current_shell" in
"bash")
rc_file="$HOME/.bashrc"
;;
"zsh")
rc_file="$HOME/.zshrc"
;;
"fish")
rc_file="$HOME/.config/fish/config.fish"
;;
"nu")
rc_file="$HOME/.config/nushell/config.nu"
;;
*)
printf "%b\n" "${RED}$current_shell is not supported. Update your shell configuration manually.${RC}"
;;
esac
if [ ! -f "$rc_file" ]; then
printf "%b\n" "${RED}Shell config file $rc_file not found${RC}"
else
if grep -q "fastfetch" "$rc_file"; then
printf "%b\n" "${YELLOW}Fastfetch is already configured in $rc_file${RC}"
return 0
else
printf "%b" "${GREEN}Would you like to add fastfetch to $rc_file? [y/N] ${RC}"
read -r response
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
printf "\n# Run fastfetch on shell initialization\nfastfetch\n" >>"$rc_file"
printf "%b\n" "${GREEN}Added fastfetch to $rc_file${RC}"
else
printf "%b\n" "${YELLOW}Skipped adding fastfetch to shell config${RC}"
fi
fi
fi
}
checkEnv
checkEscalationTool
installFastfetch
setupFastfetchConfig
setupFastfetchConfig
setupFastfetchShell

View File

@ -25,11 +25,16 @@ installDepend() {
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS"
;;
dnf)
COMPILEDEPS='@development-tools'
"$ESCALATION_TOOL" "$PACKAGER" update
"$ESCALATION_TOOL" "$PACKAGER" config-manager --set-enabled powertools
"$ESCALATION_TOOL" "$PACKAGER" install -y "$DEPENDENCIES" "$COMPILEDEPS"
"$ESCALATION_TOOL" "$PACKAGER" install -y glibc-devel.i686 libgcc.i686
"$ESCALATION_TOOL" "$PACKAGER" update -y
if ! "$ESCALATION_TOOL" "$PACKAGER" config-manager --enable powertools 2>/dev/null; then
"$ESCALATION_TOOL" "$PACKAGER" config-manager --enable crb 2>/dev/null || true
fi
# shellcheck disable=SC2086
"$ESCALATION_TOOL" "$PACKAGER" -y install $DEPENDENCIES
if ! "$ESCALATION_TOOL" "$PACKAGER" -y group install "Development Tools" 2>/dev/null; then
"$ESCALATION_TOOL" "$PACKAGER" -y group install development-tools
fi
"$ESCALATION_TOOL" "$PACKAGER" -y install glibc-devel.i686 libgcc.i686
;;
zypper)
COMPILEDEPS='patterns-devel-base-devel_basis'

View File

@ -6,16 +6,17 @@ removeSnaps() {
if command_exists snap; then
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -Rns snapd
"$ESCALATION_TOOL" "$PACKAGER" -Rns snapd --noconfirm
;;
apt-get|nala)
"$ESCALATION_TOOL" "$PACKAGER" autoremove --purge snapd
"$ESCALATION_TOOL" "$PACKAGER" remove --purge -y snapd
"$ESCALATION_TOOL" "$PACKAGER" autoremove -y
if [ "$ID" = ubuntu ]; then
"$ESCALATION_TOOL" apt-mark hold snapd
fi
;;
dnf|zypper)
"$ESCALATION_TOOL" "$PACKAGER" remove snapd
"$ESCALATION_TOOL" "$PACKAGER" remove -y snapd
;;
*)
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"

View File

@ -24,9 +24,11 @@ use ratatui::{
},
Terminal,
};
use running_command::TERMINAL_UPDATED;
use state::AppState;
use std::{
io::{stdout, Result, Stdout},
sync::atomic::Ordering,
time::Duration,
};
@ -59,9 +61,14 @@ fn main() -> Result<()> {
fn run(terminal: &mut Terminal<CrosstermBackend<Stdout>>, state: &mut AppState) -> Result<()> {
loop {
terminal.draw(|frame| state.draw(frame)).unwrap();
// Wait for an event
if !event::poll(Duration::from_millis(10))? {
if TERMINAL_UPDATED
.compare_exchange(true, false, Ordering::AcqRel, Ordering::Acquire)
.is_ok()
{
terminal.draw(|frame| state.draw(frame)).unwrap();
}
continue;
}
@ -84,5 +91,6 @@ fn run(terminal: &mut Terminal<CrosstermBackend<Stdout>>, state: &mut AppState)
}
_ => {}
}
terminal.draw(|frame| state.draw(frame)).unwrap();
}
}

View File

@ -13,7 +13,10 @@ use ratatui::{
use std::{
fs::File,
io::{Result, Write},
sync::{Arc, Mutex},
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
},
thread::JoinHandle,
};
use time::{macros::format_description, OffsetDateTime};
@ -158,6 +161,7 @@ impl FloatContent for RunningCommand {
}
}
}
pub static TERMINAL_UPDATED: AtomicBool = AtomicBool::new(true);
impl RunningCommand {
pub fn new(commands: &[&Command]) -> Self {
@ -217,6 +221,7 @@ impl RunningCommand {
// A buffer, shared between the thread that reads the command output, and the main tread.
// The main thread only reads the contents
let command_buffer: Arc<Mutex<Vec<u8>>> = Arc::new(Mutex::new(Vec::new()));
TERMINAL_UPDATED.store(true, Ordering::Release);
let reader_handle = {
// Arc is just a reference, so we can create an owned copy without any problem
let command_buffer = command_buffer.clone();
@ -233,8 +238,10 @@ impl RunningCommand {
// done, to minimise the time it is opened
let command_buffer = mutex.as_mut().unwrap();
command_buffer.extend_from_slice(&buf[0..size]);
TERMINAL_UPDATED.store(true, Ordering::Release);
// The mutex is closed here automatically
}
TERMINAL_UPDATED.store(true, Ordering::Release);
})
};

View File

@ -345,16 +345,24 @@ impl AppState {
.map(|tab| tab.name.as_str())
.collect::<Vec<_>>();
let tab_hl_style = if let Focus::TabList = self.focus {
Style::default().reversed().fg(self.theme.tab_color())
let (tab_hl_style, highlight_symbol) = if let Focus::TabList = self.focus {
(
Style::default().reversed().fg(self.theme.tab_color()),
self.theme.tab_icon(),
)
} else if let Focus::Search = self.focus {
(Style::reset(), " ")
} else {
Style::new().fg(self.theme.tab_color())
(
Style::new().fg(self.theme.tab_color()),
self.theme.tab_icon(),
)
};
let tab_list = List::new(tabs)
.block(Block::bordered().border_set(border::ROUNDED))
.highlight_style(tab_hl_style)
.highlight_symbol(self.theme.tab_icon());
.highlight_symbol(highlight_symbol);
frame.render_stateful_widget(tab_list, left_chunks[1], &mut self.current_tab);
let chunks =