Merge branch 'main' into testing-9

This commit is contained in:
Chris Titus 2024-09-18 13:02:19 -05:00 committed by GitHub
commit 0eafa7b54c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
65 changed files with 2469 additions and 573 deletions

128
.github/CODE_OF_CONDUCT.md vendored Normal file
View File

@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
contact@christitus.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.

View File

@ -1,8 +1,3 @@
# Pull Request
## Title
<!--[Provide a succinct and descriptive title for the pull request.]-->
## Type of Change
- [ ] New feature
- [ ] Bug fix

4
.github/mkdocs.yml vendored
View File

@ -5,7 +5,9 @@ docs_dir: '../docs'
nav:
- Introduction: 'index.md'
- User Guide: 'userguide.md'
- Contributing Guide: 'contribute.md'
- Contributing:
- Contributing Guide: 'contribute.md'
- Roadmap: 'roadmap.md'
- Documentation:
- Known Issues: 'KnownIssues.md'
- FAQ: 'faq.md'

View File

@ -1,5 +1,3 @@
name-template: '$RESOLVED_VERSION'
tag-template: '$RESOLVED_VERSION'
tag-prefix: ""
categories:
- title: '🚀 Features'
@ -21,10 +19,6 @@ template: |
$CHANGES
## Contributors
$CONTRIBUTORS
change-title-escapes: '\<*_&"'''
autolabeler:
- label: 'documentation'
@ -57,4 +51,6 @@ replacers:
- search: /`/g
replace: ''
exclude-labels:
- 'skip-changelog'
- 'skip-changelog'
filter-by-commitish: true

View File

@ -1,25 +0,0 @@
name: Remove Cargo.lock changes
on:
pull_request:
types: [opened, synchronize]
paths:
- 'Cargo.lock'
jobs:
remove-cargo-lock:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Remove Cargo.lock changes
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git checkout ${{ github.head_ref }}
git reset origin/${{ github.base_ref }} -- Cargo.lock
git commit -m "Remove changes to Cargo.lock" || echo "No changes to commit"
git push origin ${{ github.head_ref }} --force

View File

@ -3,10 +3,11 @@ name: GitHub Pages Deploy
on:
push:
paths:
- 'mkdocs.yml'
- '.github/mkdocs.yml'
- '.github/requirements.txt'
- 'docs/**'
- 'overrides/**'
- 'CONTRIBUTING.md'
- '.github/CONTRIBUTING.md'
workflow_dispatch:
jobs:
@ -29,4 +30,6 @@ jobs:
run: pip install -r .github/requirements.txt
- name: Build & Deploy using mkdocs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mkdocs gh-deploy --force -f .github/mkdocs.yml

View File

@ -3,6 +3,7 @@ name: LinUtil Release
on:
push:
branches: ["main"]
workflow_dispatch:
permissions:
contents: write
@ -59,3 +60,39 @@ jobs:
file_pattern: "build/linutil"
add_options: '--force'
if: success()
- name: Extract Version
id: extract_version
run: |
version=$(date +"%Y.%m.%d")
echo "version=$version" >> $GITHUB_ENV
shell: bash
- name: Generate Release Notes
id: generate_notes
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config-name: release-drafter.yml
version: ${{ env.version }}
- name: Create and Upload Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.version }}
name: Pre-Release ${{ env.version }}
body: |
${{ steps.generate_notes.outputs.body }}
![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/linutil/${{ env.version }}/linutil)
append_body: false
files: |
./build/linutil
./start.sh
./startdev.sh
prerelease: true
env:
version: ${{ env.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

56
.github/workflows/pr-labels.yaml vendored Normal file
View File

@ -0,0 +1,56 @@
name: Manage labels based on PR body
on:
pull_request_target:
types: [opened, edited, reopened, synchronize]
jobs:
manage-labels:
runs-on: ubuntu-latest
steps:
- name: Analyze PR Body and manage labels
shell: bash
run: |
body=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH")
labels_to_add=()
labels_to_remove=()
declare -A label_checks=(
["New feature"]="enhancement"
["Bug fix|Hotfix|Security patch"]="bug"
["Documentation update"]="documentation"
["Refactoring"]="refactor"
["UI/UX improvement"]="UI/UX"
)
for pattern in "${!label_checks[@]}"; do
label="${label_checks[$pattern]}"
if echo "$body" | grep -Eq "\- \[x\] ($pattern)"; then
labels_to_add+=("$label")
else
labels_to_remove+=("$label")
fi
done
echo "LABELS_TO_ADD=$(IFS=,; echo "${labels_to_add[*]}")" >> $GITHUB_ENV
echo "LABELS_TO_REMOVE=$(IFS=,; echo "${labels_to_remove[*]}")" >> $GITHUB_ENV
- name: Add labels if necessary
if: env.LABELS_TO_ADD != ''
run: |
IFS=',' read -ra labels <<< "${LABELS_TO_ADD}"
for label in "${labels[@]}"; do
curl -s -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d "{\"labels\": [\"$label\"]}" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels
done
- name: Remove labels if necessary
if: env.LABELS_TO_REMOVE != ''
run: |
IFS=',' read -ra labels <<< "${LABELS_TO_REMOVE}"
for label in "${labels[@]}"; do
curl -s -X DELETE \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels/$label
done

View File

@ -1,55 +0,0 @@
name: Pre-Release LinUtil
permissions:
contents: write # Grant write permissions to contents
packages: write # Grant write permissions to packages
on:
workflow_dispatch: # Manual trigger added
workflow_run:
workflows: ["LinUtil Release"]
types:
- completed
jobs:
build-runspace:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Extract Version
id: extract_version
run: |
version=$(date +"%Y.%m.%d")
echo "version=$version" >> $GITHUB_ENV
shell: bash
- name: Generate Release Notes
id: generate_notes
uses: release-drafter/release-drafter@v6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
config-name: release-drafter.yml
version: ${{ env.version }}
- name: Create and Upload Release
id: create_release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ env.version }}
name: Pre-Release ${{ env.version }}
body: |
${{ steps.generate_notes.outputs.body }}
![GitHub Downloads (specific asset, specific tag)](https://img.shields.io/github/downloads/ChrisTitusTech/linutil/${{ env.version }}/linutil)
append_body: false
files: |
./build/linutil
./start.sh
./startdev.sh
prerelease: true
env:
version: ${{ env.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/build
rust/target
rust/build
/build/linutil

View File

@ -31,7 +31,9 @@ For comprehensive information on how to use Linutil, visit the [Linutil Official
## 🛠 Contributing
We welcome contributions from the community! Before you start, please review our [Contributing Guidelines](CONTRIBUTING.md) to understand how to make the most effective and efficient contributions.
We welcome contributions from the community! Before you start, please review our [Contributing Guidelines](.github/CONTRIBUTING.md) to understand how to make the most effective and efficient contributions.
[Official LinUtil Roadmap](https://christitustech.github.io/linutil/roadmap)
## 🏅 Thanks to All Contributors

Binary file not shown.

View File

@ -16,15 +16,19 @@ setupAlacritty() {
else
echo "alacritty is already installed."
fi
}
setupAlacrittyConfig() {
echo "Copy alacritty config files"
if [ -d "${HOME}/.config/alacritty" ]; then
if [ -d "${HOME}/.config/alacritty" ] && [ ! -d "${HOME}/.config/alacritty-bak" ]; then
cp -r "${HOME}/.config/alacritty" "${HOME}/.config/alacritty-bak"
fi
mkdir -p "${HOME}/.config/alacritty/"
wget -O "${HOME}/.config/alacritty/alacritty.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/alacritty.toml"
wget -O "${HOME}/.config/alacritty/nordic.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/nordic.toml"
curl -sSLo "${HOME}/.config/alacritty/alacritty.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/alacritty.toml"
curl -sSLo "${HOME}/.config/alacritty/nordic.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/nordic.toml"
}
checkEnv
checkEscalationTool
setupAlacritty
setupAlacrittyConfig

166
tabs/applications-setup/dwmtitus-setup.sh Normal file → Executable file
View File

@ -1,4 +1,5 @@
#!/bin/sh -e
. ../common-script.sh
makeDWM() {
@ -14,8 +15,8 @@ setupDWM() {
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 libxcb
;;
apt)
$ESCALATION_TOOL "$PACKAGER" install -y build-essential libx11-dev libxinerama-dev libxft-dev libimlib2-dev libxcb1-dev libx11-xcb1
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
;;
dnf)
$ESCALATION_TOOL "$PACKAGER" groupinstall -y "Development Tools"
@ -55,7 +56,7 @@ install_nerd_font() {
# Check if the font zip file already exists
if [ ! -f "$FONT_ZIP" ]; then
# Download the font zip file
wget -P "$FONT_DIR" "$FONT_URL" || {
curl -sSLo "$FONT_ZIP" "$FONT_URL" || {
echo "Failed to download Meslo Nerd-fonts from $FONT_URL"
return 1
}
@ -114,7 +115,7 @@ picom_animations() {
fi
# Install the built binary
if ! sudo ninja -C build install; then
if ! $ESCALATION_TOOL ninja -C build install; then
echo "Failed to install the built binary"
return 1
fi
@ -142,29 +143,32 @@ clone_config_folders() {
}
configure_backgrounds() {
# Set the variable PIC_DIR which stores the path for images
PIC_DIR="$HOME/Pictures"
# Set the variable BG_DIR to the path where backgrounds will be stored
BG_DIR="$HOME/Pictures/backgrounds"
BG_DIR="$PIC_DIR/backgrounds"
# Check if the ~/Pictures directory exists
if [ ! -d "~/Pictures" ]; then
if [ ! -d "$PIC_DIR" ]; then
# If it doesn't exist, print an error message and return with a status of 1 (indicating failure)
echo "Pictures directory does not exist"
mkdir ~/Pictures
mkdir "$PIC_DIR"
echo "Directory was created in Home folder"
fi
# Check if the backgrounds directory (BG_DIR) exists
if [ ! -d "$BG_DIR" ]; then
# If the backgrounds directory doesn't exist, attempt to clone a repository containing backgrounds
if ! git clone https://github.com/ChrisTitusTech/nord-background.git ~/Pictures; then
if ! git clone https://github.com/ChrisTitusTech/nord-background.git "$PIC_DIR/nord-background"; then
# If the git clone command fails, print an error message and return with a status of 1
echo "Failed to clone the repository"
return 1
fi
# Rename the cloned directory to 'backgrounds'
mv ~/Pictures/nord-background ~/Pictures/backgrounds
mv "$PIC_DIR/nord-background" "$PIC_DIR/backgrounds"
# Print a success message indicating that the backgrounds have been downloaded
echo "Downloaded desktop backgrounds to $BG_DIR"
echo "Downloaded desktop backgrounds to $BG_DIR"
else
# If the backgrounds directory already exists, print a message indicating that the download is being skipped
echo "Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds"
@ -177,7 +181,7 @@ setupDisplayManager() {
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm xorg-xinit xorg-server
;;
apt)
apt-get|nala)
$ESCALATION_TOOL "$PACKAGER" install -y xorg xinit
;;
dnf)
@ -192,8 +196,8 @@ setupDisplayManager() {
echo "Setting up Display Manager"
currentdm="none"
for dm in gdm sddm lightdm; do
if systemctl is-active --quiet $dm.service; then
currentdm=$dm
if systemctl is-active --quiet "$dm.service"; then
currentdm="$dm"
break
fi
done
@ -203,13 +207,13 @@ setupDisplayManager() {
echo "No display manager found, installing $DM"
case "$PACKAGER" in
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm $DM
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm "$DM"
;;
apt)
$ESCALATION_TOOL "$PACKAGER" install -y $DM
apt-get|nala)
$ESCALATION_TOOL "$PACKAGER" install -y "$DM"
;;
dnf)
$ESCALATION_TOOL "$PACKAGER" install -y $DM
$ESCALATION_TOOL "$PACKAGER" install -y "$DM"
;;
*)
echo "Unsupported package manager: $PACKAGER"
@ -217,82 +221,67 @@ setupDisplayManager() {
;;
esac
echo "$DM installed successfully"
systemctl enable $DM
# Clear the screen
clear
systemctl enable "$DM"
# Prompt user for auto-login
echo "Do you want to enable auto-login?"
echo "Use arrow keys or j/k to navigate, Enter to select"
options=("Yes" "No")
selected=0
# Function to print menu
print_menu() {
for i in "${!options[@]}"; do
if [ $i -eq $selected ]; then
echo "> ${options[$i]}"
# Using printf instead of echo -n as It's more posix-compliant.
printf "Do you want to enable auto-login? (Y/n) "
read -r answer
case "$answer" in
[Yy]*)
echo "Configuring SDDM for autologin"
SDDM_CONF="/etc/sddm.conf"
if [ ! -f "$SDDM_CONF" ]; then
echo "[Autologin]" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
echo "User=$USER" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
echo "Session=dwm" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
else
echo " ${options[$i]}"
$ESCALATION_TOOL sed -i '/^\[Autologin\]/d' "$SDDM_CONF"
$ESCALATION_TOOL sed -i '/^User=/d' "$SDDM_CONF"
$ESCALATION_TOOL sed -i '/^Session=/d' "$SDDM_CONF"
echo "[Autologin]" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
echo "User=$USER" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
echo "Session=dwm" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
fi
done
}
# Handle user input
while true; do
print_menu
read -rsn1 key
case "$key" in
$'\x1B') # ESC sequence for arrow keys
read -rsn2 key
case "$key" in
'[A' | 'k') ((selected > 0)) && ((selected--));; # Up arrow or k
'[B' | 'j') ((selected < ${#options[@]}-1)) && ((selected++));; # Down arrow or j
esac
;;
'') break;; # Enter key
esac
clear
done
if [ "${options[$selected]}" = "Yes" ]; then
echo "Configuring SDDM for autologin"
SDDM_CONF="/etc/sddm.conf"
if [ ! -f "$SDDM_CONF" ]; then
echo "[Autologin]" | sudo tee -a "$SDDM_CONF"
echo "User=$USER" | sudo tee -a "$SDDM_CONF"
echo "Session=dwm" | sudo tee -a "$SDDM_CONF"
else
sudo sed -i '/^\[Autologin\]/d' "$SDDM_CONF"
sudo sed -i '/^User=/d' "$SDDM_CONF"
sudo sed -i '/^Session=/d' "$SDDM_CONF"
echo "[Autologin]" | sudo tee -a "$SDDM_CONF"
echo "User=$USER" | sudo tee -a "$SDDM_CONF"
echo "Session=dwm" | sudo tee -a "$SDDM_CONF"
fi
echo "Checking if autologin group exists"
if ! getent group autologin > /dev/null; then
echo "Creating autologin group"
sudo groupadd autologin
else
echo "Autologin group already exists"
fi
echo "Adding user with UID 1000 to autologin group"
USER_UID_1000=$(getent passwd 1000 | cut -d: -f1)
if [ -n "$USER_UID_1000" ]; then
sudo usermod -aG autologin "$USER_UID_1000"
echo "User $USER_UID_1000 added to autologin group"
else
echo "No user with UID 1000 found - Auto login not possible"
fi
else
echo "Auto-login configuration skipped"
fi
echo "Checking if autologin group exists"
if ! getent group autologin > /dev/null; then
echo "Creating autologin group"
$ESCALATION_TOOL groupadd autologin
else
echo "Autologin group already exists"
fi
echo "Adding user with UID 1000 to autologin group"
USER_UID_1000=$(getent passwd 1000 | cut -d: -f1)
if [ -n "$USER_UID_1000" ]; then
$ESCALATION_TOOL usermod -aG autologin "$USER_UID_1000"
echo "User $USER_UID_1000 added to autologin group"
else
echo "No user with UID 1000 found - Auto login not possible"
fi
;;
*)
echo "Auto-login configuration skipped"
;;
esac
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
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
echo "Installing slstatus"
cd "$HOME/dwm-titus/slstatus" || { echo "Failed to change directory to slstatus"; return 1; }
if $ESCALATION_TOOL make clean install; then
echo "slstatus installed successfully"
else
echo "Failed to install slstatus"
return 1
fi
else
echo "Skipping slstatus installation"
fi
cd "$HOME"
}
checkEnv
@ -300,6 +289,7 @@ checkEscalationTool
setupDisplayManager
setupDWM
makeDWM
install_slstatus
install_nerd_font
clone_config_folders
configure_backgrounds

View File

@ -0,0 +1,33 @@
#!/bin/sh -e
. ../common-script.sh
setupFastfetch() {
echo "Installing Fastfetch if not already installed..."
if ! command_exists fastfetch; then
case ${PACKAGER} in
pacman)
$ESCALATION_TOOL "${PACKAGER}" -S --needed --noconfirm fastfetch
;;
*)
$ESCALATION_TOOL "${PACKAGER}" install -y fastfetch
;;
esac
else
echo "Fastfetch is already installed."
fi
}
setupFastfetchConfig() {
echo "Copying Fastfetch config files..."
if [ -d "${HOME}/.config/fastfetch" ] && [ ! -d "${HOME}/.config/fastfetch-bak" ]; then
cp -r "${HOME}/.config/fastfetch" "${HOME}/.config/fastfetch-bak"
fi
mkdir -p "${HOME}/.config/fastfetch/"
curl -sSLo "${HOME}/.config/fastfetch/config.jsonc" https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/config.jsonc
}
checkEnv
checkEscalationTool
setupFastfetch
setupFastfetchConfig

View File

@ -16,15 +16,19 @@ setupKitty() {
else
echo "Kitty is already installed."
fi
}
setupKittyConfig() {
echo "Copy Kitty config files"
if [ -d "${HOME}/.config/kitty" ]; then
if [ -d "${HOME}/.config/kitty" ] && [ ! -d "${HOME}/.config/kitty-bak" ]; then
cp -r "${HOME}/.config/kitty" "${HOME}/.config/kitty-bak"
fi
mkdir -p "${HOME}/.config/kitty/"
wget -O "${HOME}/.config/kitty/kitty.conf" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf
wget -O "${HOME}/.config/kitty/nord.conf" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf
curl -sSLo "${HOME}/.config/kitty/kitty.conf" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf
curl -sSLo "${HOME}/.config/kitty/nord.conf" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf
}
checkEnv
checkEscalationTool
setupKitty
setupKittyConfig

View File

@ -0,0 +1,118 @@
#!/bin/sh -e
. ../common-script.sh
gitpath="$HOME/.local/share/mybash"
cloneMyBash() {
# Check if the dir exists before attempting to clone into it.
if [ -d "$gitpath" ]; then
rm -rf "$gitpath"
fi
mkdir -p "$HOME/.local/share" # Only create the dir if it doesn't exist.
cd "$HOME" && git clone https://github.com/ChrisTitusTech/mybash.git "$gitpath"
}
installDepend() {
echo "Install mybash if not already installed"
case "$PACKAGER" in
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig
;;
apt)
$ESCALATION_TOOL "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig
;;
dnf)
$ESCALATION_TOOL "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig
;;
zypper)
$ESCALATION_TOOL "$PACKAGER" install -y bash bash-completion tar bat tree unzip fontconfig
;;
*)
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" # The packages above were grabbed out of the original mybash-setup-script.
exit 1
;;
esac
}
installFont() {
# Check to see if the MesloLGS Nerd Font is installed (Change this to whatever font you would like)
FONT_NAME="MesloLGS Nerd Font Mono"
if fc-list :family | grep -iq "$FONT_NAME"; then
echo "Font '$FONT_NAME' is installed."
else
echo "Installing font '$FONT_NAME'"
# Change this URL to correspond with the correct font
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip"
FONT_DIR="$HOME/.local/share/fonts"
TEMP_DIR=$(mktemp -d)
curl -sSLo "$TEMP_DIR"/"${FONT_NAME}".zip "$FONT_URL"
unzip "$TEMP_DIR"/"${FONT_NAME}".zip -d "$TEMP_DIR"
mkdir -p "$FONT_DIR"/"$FONT_NAME"
mv "${TEMP_DIR}"/*.ttf "$FONT_DIR"/"$FONT_NAME"
fc-cache -fv
rm -rf "${TEMP_DIR}"
echo "'$FONT_NAME' installed successfully."
fi
}
installStarshipAndFzf() {
if command_exists starship; then
echo "Starship already installed"
return
fi
if ! curl -sSL https://starship.rs/install.sh | sh; then
printf "%b\n" "${RED}Something went wrong during starship install!${RC}"
exit 1
fi
if command_exists fzf; then
echo "Fzf already installed"
else
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
$ESCALATION_TOOL ~/.fzf/install
fi
}
installZoxide() {
if command_exists zoxide; then
echo "Zoxide already installed"
return
fi
if ! curl -sSL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh; then
printf "%b\n" "${RED}Something went wrong during zoxide install!${RC}"
exit 1
fi
}
linkConfig() {
OLD_BASHRC="$HOME/.bashrc"
if [ -e "$OLD_BASHRC" ] && [ ! -e "$HOME/.bashrc.bak" ]; then
printf "%b\n" "${YELLOW}Moving old bash config file to $HOME/.bashrc.bak${RC}"
if ! mv "$OLD_BASHRC" "$HOME/.bashrc.bak"; then
printf "%b\n" "${RED}Can't move the old bash config file!${RC}"
exit 1
fi
fi
printf "%b\n" "${YELLOW}Linking new bash config file...${RC}"
ln -svf "$gitpath/.bashrc" "$HOME/.bashrc" || {
printf "%b\n" "${RED}Failed to create symbolic link for .bashrc${RC}"
exit 1
}
ln -svf "$gitpath/starship.toml" "$HOME/.config/starship.toml" || {
printf "%b\n" "${RED}Failed to create symbolic link for starship.toml${RC}"
exit 1
}
printf "%b\n" "${GREEN}Done! restart your shell to see the changes.${RC}"
}
checkEnv
checkEscalationTool
cloneMyBash
installDepend
installFont
installStarshipAndFzf
installZoxide
linkConfig

View File

@ -0,0 +1,55 @@
#!/bin/sh -e
. ../common-script.sh
gitpath="$HOME/.local/share/neovim"
cloneNeovim() {
# Check if the dir exists before attempting to clone into it.
if [ -d "$gitpath" ]; then
rm -rf "$gitpath"
fi
mkdir -p "$HOME/.local/share" # Only create the dir if it doesn't exist.
cd "$HOME" && git clone https://github.com/ChrisTitusTech/neovim.git "$HOME/.local/share/neovim"
}
setupNeovim() {
echo "Install Neovim if not already installed"
case "$PACKAGER" in
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm neovim ripgrep fzf python-virtualenv luarocks go shellcheck
;;
apt)
$ESCALATION_TOOL "$PACKAGER" install -y neovim ripgrep fd-find python3-venv luarocks golang-go shellcheck
;;
dnf)
$ESCALATION_TOOL "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck
;;
zypper)
$ESCALATION_TOOL "$PACKAGER" install -y neovim ripgrep fzf python3-virtualenv luarocks golang ShellCheck
;;
*)
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}" # The packages above were grabbed out of the original nvim-setup-script.
exit 1
;;
esac
}
backupNeovimConfig() {
if [ -d "$HOME/.config/nvim" ] && [ ! -d "$HOME/.config/nvim-backup" ]; then
cp -r "$HOME/.config/nvim" "$HOME/.config/nvim-backup"
fi
rm -rf "$HOME/.config/nvim"
}
linkNeovimConfig() {
mkdir -p "$HOME/.config/nvim"
ln -s "$gitpath/titus-kickstart/"* "$HOME/.config/nvim/" # Wild card is used here to link all contents of titus-kickstart.
}
checkEnv
checkEscalationTool
cloneNeovim
setupNeovim
backupNeovimConfig
linkNeovimConfig

View File

@ -16,20 +16,24 @@ setupRofi() {
else
echo "Rofi is already installed."
fi
}
setupRofiConfig() {
echo "Copy Rofi config files"
if [ -d "$HOME/.config/rofi" ]; then
cp -r "$HOME/.config/rofi" "$HOME/.config/rofi.bak"
if [ -d "$HOME/.config/rofi" ] && [ ! -d "$HOME/.config/rofi-bak" ]; then
cp -r "$HOME/.config/rofi" "$HOME/.config/rofi-bak"
fi
mkdir -p "$HOME/.config/rofi"
wget -O "$HOME/.config/rofi/powermenu.sh" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/powermenu.sh
curl -sSLo "$HOME/.config/rofi/powermenu.sh" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/powermenu.sh
chmod +x "$HOME/.config/rofi/powermenu.sh"
wget -O "$HOME/.config/rofi/config.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/config.rasi
curl -sSLo "$HOME/.config/rofi/config.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/config.rasi
mkdir -p "$HOME/.config/rofi/themes"
wget -O "$HOME/.config/rofi/themes/nord.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/nord.rasi
wget -O "$HOME/.config/rofi/themes/sidetab-nord.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/sidetab-nord.rasi
wget -O "$HOME/.config/rofi/themes/powermenu.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/powermenu.rasi
curl -sSLo "$HOME/.config/rofi/themes/nord.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/nord.rasi
curl -sSLo "$HOME/.config/rofi/themes/sidetab-nord.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/sidetab-nord.rasi
curl -sSLo "$HOME/.config/rofi/themes/powermenu.rasi" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/rofi/themes/powermenu.rasi
}
checkEnv
checkEscalationTool
setupRofi
setupRofiConfig

View File

@ -6,7 +6,7 @@ script = "alacritty-setup.sh"
[[data]]
name = "Bash Prompt"
command = "bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/mybash/main/setup.sh)\""
script = "mybash-setup.sh"
[[data]]
name = "DWM-Titus"
@ -18,7 +18,7 @@ script = "kitty-setup.sh"
[[data]]
name = "Neovim"
command = "bash -c \"$(curl -s https://raw.githubusercontent.com/ChrisTitusTech/neovim/main/setup.sh)\""
script = "neovim-setup.sh"
[[data]]
name = "Rofi"
@ -27,3 +27,7 @@ script = "rofi-setup.sh"
[[data]]
name = "ZSH Prompt"
script = "zsh-setup.sh"
[[data]]
name = "Fastfetch"
script = "fastfetch-setup.sh"

View File

@ -5,6 +5,7 @@
RC='\033[0m'
RED='\033[31m'
YELLOW='\033[33m'
CYAN='\033[36m'
GREEN='\033[32m'
command_exists() {
@ -54,7 +55,7 @@ checkEscalationTool() {
fi
done
echo -e "${RED}Can't find a supported escalation tool${RC}"
printf "%b\n" "${RED}Can't find a supported escalation tool${RC}"
exit 1
fi
}
@ -82,7 +83,7 @@ checkPackageManager() {
done
if [ -z "${PACKAGER}" ]; then
echo -e "${RED}Can't find a supported package manager${RC}"
printf "%b\n" "${RED}Can't find a supported package manager${RC}"
exit 1
fi
}

View File

@ -85,7 +85,7 @@ mkdir -p "$mods_path"
# Download the latest release
echo "Downloading the latest loot filter..."
wget -q --show-progress https://github.com/ChrisTitusTech/d2r-loot-filter/releases/latest/download/lootfilter.zip -O /tmp/lootfilter.zip
curl -sSLo /tmp/lootfilter.zip https://github.com/ChrisTitusTech/d2r-loot-filter/releases/latest/download/lootfilter.zip
# Extract the contents to the mods folder
echo "Extracting loot filter to $mods_path..."

View File

@ -1,7 +1,7 @@
name = "Gaming"
[[data]]
name = "Diablo II Ressurected"
name = "Diablo II Resurrected"
[[data.entries]]
name = "Loot Filter Install"

View File

@ -19,7 +19,7 @@ installPkg() {
}
configureUFW() {
echo -e "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}"
printf "%b\n" "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}"
echo "Disabling UFW"
$ESCALATION_TOOL ufw disable
@ -40,7 +40,7 @@ configureUFW() {
$ESCALATION_TOOL ufw default allow outgoing
$ESCALATION_TOOL ufw enable
echo -e "${GREEN}Enabled Firewall with Baselines!${RC}"
printf "%b\n" "${GREEN}Enabled Firewall with Baselines!${RC}"
}
checkEnv

View File

@ -5,7 +5,7 @@
installDepend() {
## Check for dependencies.
DEPENDENCIES='tar tree multitail tldr trash-cli unzip cmake make jq'
echo -e "${YELLOW}Installing dependencies...${RC}"
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
case $PACKAGER in
pacman)
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then

View File

@ -4,7 +4,7 @@
installDepend() {
## Check for dependencies.
echo -e "${YELLOW}Installing dependencies...${RC}"
printf "%b\n" "${YELLOW}Installing dependencies...${RC}"
if [ "$PACKAGER" = "pacman" ]; then
if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then
echo "[multilib]" | $ESCALATION_TOOL tee -a /etc/pacman.conf
@ -38,8 +38,7 @@ install_additional_dependencies() {
cut -d '/' --fields=3)
version_no_v=$(echo "$version" | tr -d v)
wget "https://github.com/lutris/lutris/releases/download/${version}/lutris_${version_no_v}_all.deb"
curl -sSLo "lutris_${version_no_v}_all.deb" "https://github.com/lutris/lutris/releases/download/${version}/lutris_${version_no_v}_all.deb"
# Install the downloaded .deb package using apt-get
echo "Installing lutris_${version_no_v}_all.deb"
$ESCALATION_TOOL apt-get update

View File

@ -3,7 +3,7 @@
. ../common-script.sh
install_theme_tools() {
printf "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}\n"
printf "%b\n" "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}\n"
case $PACKAGER in
apt-get)
$ESCALATION_TOOL apt-get update
@ -21,14 +21,14 @@ install_theme_tools() {
$ESCALATION_TOOL pacman -S --needed --noconfirm qt6ct kvantum
;;
*)
printf "${RED}Unsupported package manager. Please install qt6ct and kvantum manually.${RC}\n"
printf "%b\n" "${RED}Unsupported package manager. Please install qt6ct and kvantum manually.${RC}\n"
exit 1
;;
esac
}
configure_qt6ct() {
printf "${YELLOW}Configuring qt6ct...${RC}\n"
printf "%b\n" "${YELLOW}Configuring qt6ct...${RC}\n"
mkdir -p "$HOME/.config/qt6ct"
cat <<EOF > "$HOME/.config/qt6ct/qt6ct.conf"
[Appearance]
@ -36,26 +36,26 @@ style=kvantum
color_scheme=default
icon_theme=breeze
EOF
printf "${GREEN}qt6ct configured successfully.${RC}\n"
printf "%b\n" "${GREEN}qt6ct configured successfully.${RC}\n"
# Add QT_QPA_PLATFORMTHEME to /etc/environment
if ! grep -q "QT_QPA_PLATFORMTHEME=qt6ct" /etc/environment; then
printf "${YELLOW}Adding QT_QPA_PLATFORMTHEME to /etc/environment...${RC}\n"
printf "%b\n" "${YELLOW}Adding QT_QPA_PLATFORMTHEME to /etc/environment...${RC}\n"
echo "QT_QPA_PLATFORMTHEME=qt6ct" | $ESCALATION_TOOL tee -a /etc/environment > /dev/null
printf "${GREEN}QT_QPA_PLATFORMTHEME added to /etc/environment.${RC}\n"
printf "%b\n" "${GREEN}QT_QPA_PLATFORMTHEME added to /etc/environment.${RC}\n"
else
printf "${GREEN}QT_QPA_PLATFORMTHEME already set in /etc/environment.${RC}\n"
printf "%b\n" "${GREEN}QT_QPA_PLATFORMTHEME already set in /etc/environment.${RC}\n"
fi
}
configure_kvantum() {
printf "${YELLOW}Configuring Kvantum...${RC}\n"
printf "%b\n" "${YELLOW}Configuring Kvantum...${RC}\n"
mkdir -p "$HOME/.config/Kvantum"
cat <<EOF > "$HOME/.config/Kvantum/kvantum.kvconfig"
[General]
theme=Breeze
EOF
printf "${GREEN}Kvantum configured successfully.${RC}\n"
printf "%b\n" "${GREEN}Kvantum configured successfully.${RC}\n"
}
checkEnv

View File

@ -0,0 +1,205 @@
#!/bin/sh -e
# Load common script functions
. ../common-script.sh
# Function to install packages based on the package manager
install_package() {
PACKAGE=$1
if ! command_exists "$PACKAGE"; then
case "$PACKAGER" in
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --noconfirm "$PACKAGE"
;;
*)
$ESCALATION_TOOL "$PACKAGER" install -y "$PACKAGE"
;;
esac
else
echo "$PACKAGE is already installed."
fi
}
# Function to setup and configure SSH
setup_ssh() {
printf "%b\n" "${YELLOW}Setting up SSH...${RC}"
# Detect package manager and install appropriate SSH package
case "$PACKAGER" in
"apt-get")
install_package openssh-server
SSH_SERVICE="ssh"
;;
"pacman")
install_package openssh
SSH_SERVICE="sshd"
;;
*)
install_package openssh-server
SSH_SERVICE="sshd"
;;
esac
# Enable and start the appropriate SSH service
$ESCALATION_TOOL systemctl enable "$SSH_SERVICE"
$ESCALATION_TOOL systemctl start "$SSH_SERVICE"
# Get the local IP address
LOCAL_IP=$(ip -4 addr show | awk '/inet / {print $2}' | tail -n 1)
printf "%b\n" "${GREEN}Your local IP address is: $LOCAL_IP${RC}"
# Check if SSH is running
if systemctl is-active --quiet "$SSH_SERVICE"; then
printf "%b\n" "${GREEN}SSH is up and running.${RC}"
else
printf "%b\n" "${RED}Failed to start SSH.${RC}"
fi
}
# Function to setup and configure Samba
setup_samba() {
printf "%b\n" "${YELLOW}Setting up Samba...${RC}"
# Install Samba if not installed
install_package samba
SAMBA_CONFIG="/etc/samba/smb.conf"
if [ -f "$SAMBA_CONFIG" ]; then
printf "%b\n" "${YELLOW}Samba configuration file already exists in $SAMBA_CONFIG.${RC}"
printf "Do you want to modify the existing Samba configuration? (yes/no): "
read -r MODIFY_SAMBA
if [ "$MODIFY_SAMBA" = "yes" ]; then
"$ESCALATION_TOOL" "$EDITOR" "$SAMBA_CONFIG"
fi
else
printf "%b\n" "${YELLOW}No existing Samba configuration found. Setting up a new one...${RC}"
# Prompt user for shared directory path
printf "Enter the path for the Samba share (default: /srv/samba/share): "
read -r SHARED_DIR
SHARED_DIR=${SHARED_DIR:-/srv/samba/share}
# Create the shared directory if it doesn't exist
$ESCALATION_TOOL mkdir -p "$SHARED_DIR"
$ESCALATION_TOOL chmod -R 0777 "$SHARED_DIR"
# Add a new Samba user
echo "Enter Samba username: "
read -r SAMBA_USER
# Loop until the passwords match
while true; do
echo "Enter Samba password: "
stty -echo
read -r SAMBA_PASSWORD
stty echo
echo "Confirm Samba password: "
stty -echo
read SAMBA_PASSWORD_CONFIRM
stty echo
echo ""
if [ "$SAMBA_PASSWORD" = "$SAMBA_PASSWORD_CONFIRM" ]; then
printf "%b\n" "${GREEN}Passwords match.${RC}"
break
else
printf "%b\n" "${RED}Passwords do not match. Please try again.${RC}"
fi
done
# Add the user and set the password
$ESCALATION_TOOL smbpasswd -a "$SAMBA_USER"
# Configure Samba settings
$ESCALATION_TOOL sh -c "cat > $SAMBA_CONFIG" <<EOL
[global]
workgroup = WORKGROUP
server string = Samba Server
security = user
map to guest = bad user
dns proxy = no
[Share]
path = $SHARED_DIR
browsable = yes
writable = yes
guest ok = no
read only = no
EOL
fi
# Enable and start Samba services
$ESCALATION_TOOL systemctl enable smb nmb
$ESCALATION_TOOL systemctl start smb nmb
# Check if Samba is running
if systemctl is-active --quiet smb && systemctl is-active --quiet nmb; then
printf "%b\n" "${GREEN}Samba is up and running.${RC}"
printf "%b\n" "${YELLOW}Samba share available at: $SHARED_DIR${RC}"
else
printf "%b\n" "${RED}Failed to start Samba.${RC}"
fi
}
# Function to configure firewall (optional)
configure_firewall() {
printf "%b\n" "${BLUE}Configuring firewall...${RC}"
if command_exists ufw; then
$ESCALATION_TOOL ufw allow OpenSSH
$ESCALATION_TOOL ufw allow Samba
$ESCALATION_TOOL ufw enable
printf "%b\n" "${GREEN}Firewall configured for SSH and Samba.${RC}"
else
printf "%b\n" "${YELLOW}UFW is not installed. Skipping firewall configuration.${RC}"
fi
}
setup_ssh_samba(){
printf "Samba and SSH Setup Script\n"
printf "----------------------------\n"
clear
# Display menu
printf "Select an option:\n"
printf "1. Setup SSH\n"
printf "2. Setup Samba\n"
printf "3. Configure Firewall\n"
printf "4. Setup All\n"
printf "5. Exit\n"
printf "Enter your choice [1-5]: "
read CHOICE
case "$CHOICE" in
1)
setup_ssh
;;
2)
setup_samba
;;
3)
configure_firewall
;;
4)
setup_ssh
setup_samba
configure_firewall
;;
5)
printf "%b\n" "${GREEN}Exiting.${RC}"
exit 0
;;
*)
printf "%b\n" "${RED}Invalid choice. Please enter a number between 1 and 5.${RC}"
exit 1
;;
esac
printf "%b\n" "${GREEN}Setup completed.${RC}"
}
checkEnv
checkEscalationTool
setup_ssh_samba

View File

@ -0,0 +1,87 @@
#!/bin/sh -e
. ../common-script.sh
# Function to prompt the user for installation choice
choose_installation() {
clear
printf "%b\n" "${YELLOW}Choose what to install:${RC}"
printf "%b\n" "1. ${YELLOW}Docker${RC}"
printf "%b\n" "2. ${YELLOW}Docker Compose${RC}"
printf "%b\n" "3. ${YELLOW}Both${RC}"
read -p "Enter your choice [1-3]: " CHOICE
case "$CHOICE" in
1) INSTALL_DOCKER=1; INSTALL_COMPOSE=0 ;;
2) INSTALL_DOCKER=0; INSTALL_COMPOSE=1 ;;
3) INSTALL_DOCKER=1; INSTALL_COMPOSE=1 ;;
*) echo "Invalid choice. Exiting."; exit 1 ;;
esac
}
install_docker() {
printf "%b\n" "${YELLOW}Installing Docker...${RC}"
case $PACKAGER in
apt-get | yum)
curl -fsSL https://get.docker.com | sh
;;
zypper)
$ESCALATION_TOOL ${PACKAGER} --non-interactive install docker
$ESCALATION_TOOL systemctl enable docker
$ESCALATION_TOOL systemctl start docker
;;
pacman)
$ESCALATION_TOOL ${PACKAGER} -S --noconfirm docker
$ESCALATION_TOOL systemctl enable docker
$ESCALATION_TOOL systemctl start docker
;;
*)
printf "${RED}Unsupported package manager. Please install Docker manually.${RC}\n"
exit 1
;;
esac
}
install_docker_compose() {
printf "%b\n" "${YELLOW}Installing Docker Compose...${RC}"
case $PACKAGER in
apt-get | yum)
$ESCALATION_TOOL ${PACKAGER} update
$ESCALATION_TOOL ${PACKAGER} install -y docker-compose-plugin
;;
zypper)
$ESCALATION_TOOL ${PACKAGER} --non-interactive install docker-compose
;;
pacman)
$ESCALATION_TOOL ${PACKAGER} -S --noconfirm docker-compose
;;
*)
printf "${RED}Unsupported package manager. Please install Docker Compose manually.${RC}\n"
exit 1
;;
esac
}
install_components() {
choose_installation
if [ "$INSTALL_DOCKER" -eq 1 ]; then
if ! command_exists docker; then
install_docker
else
printf "%b\n" "${GREEN}Docker is already installed.${RC}"
fi
fi
if [ "$INSTALL_COMPOSE" -eq 1 ]; then
if ! command_exists docker-compose || ! command_exists docker compose version; then
install_docker_compose
else
printf "%b\n" "${GREEN}Docker Compose is already installed.${RC}"
fi
fi
}
checkEnv
checkEscalationTool
install_components

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. "$(dirname "$0")/../../common-script.sh"
. ../../common-script.sh
installDepend() {
case $PACKAGER in

View File

@ -336,7 +336,7 @@ sgdisk -a 2048 -o ${DISK} # new gpt disk 2048 alignment
# create partitions
sgdisk -n 1::+1M --typecode=1:ef02 --change-name=1:'BIOSBOOT' ${DISK} # partition 1 (BIOS Boot Partition)
sgdisk -n 2::+300M --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition)
sgdisk -n 2::+1GiB --typecode=2:ef00 --change-name=2:'EFIBOOT' ${DISK} # partition 2 (UEFI Boot Partition)
sgdisk -n 3::-0 --typecode=3:8300 --change-name=3:'ROOT' ${DISK} # partition 3 (Root), default start, remaining
if [[ ! -d "/sys/firmware/efi" ]]; then # Checking for bios system
sgdisk -A 1:set:2 ${DISK}

View File

@ -1,6 +1,6 @@
#!/bin/sh -e
. "$(dirname "$0")/../../common-script.sh"
. ../../common-script.sh
installDepend() {
case $PACKAGER in

View File

@ -1,13 +1,13 @@
#!/bin/sh -e
. "$(dirname "$0")/../../common-script.sh"
. ../../common-script.sh
# https://rpmfusion.org/Configuration
installRPMFusion() {
case $PACKAGER in
dnf)
if [[ ! -e /etc/yum.repos.d/rpmfusion-free.repo || ! -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]]; then
if [ ! -e /etc/yum.repos.d/rpmfusion-free.repo ] || [ ! -e /etc/yum.repos.d/rpmfusion-nonfree.repo ]; then
echo "Installing RPM Fusion..."
$ESCALATION_TOOL "$PACKAGER" install https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
$ESCALATION_TOOL "$PACKAGER" config-manager --enable fedora-cisco-openh264

View File

@ -20,7 +20,7 @@ fastUpdate() {
$ESCALATION_TOOL rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local}
if [ $? -ne 0 ] || [ ! -s /etc/pacman.d/mirrorlist ]; then
echo -e "${RED}Rate-mirrors failed, restoring backup.${RC}"
printf "%b\n" "${RED}Rate-mirrors failed, restoring backup.${RC}"
$ESCALATION_TOOL cp /etc/pacman.d/mirrorlist.bak /etc/pacman.d/mirrorlist
fi
;;
@ -28,7 +28,7 @@ fastUpdate() {
apt-get|nala)
$ESCALATION_TOOL apt-get update
if ! command_exists nala; then
$ESCALATION_TOOL apt-get install -y nala || { echo -e "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; }
$ESCALATION_TOOL apt-get install -y nala || { printf "%b\n" "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; }
fi
if [ "${PACKAGER}" = "nala" ]; then
@ -54,14 +54,14 @@ fastUpdate() {
$ESCALATION_TOOL ${PACKAGER} -Syu
;;
*)
echo -e "${RED}Unsupported package manager: $PACKAGER${RC}"
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
}
updateSystem() {
echo -e "${GREEN}Updating system${RC}"
printf "%b\n" "${GREEN}Updating system${RC}"
case ${PACKAGER} in
nala|apt-get)
$ESCALATION_TOOL "${PACKAGER}" update -y
@ -83,7 +83,7 @@ updateSystem() {
$ESCALATION_TOOL ${PACKAGER} -Syu
;;
*)
echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}"
printf "%b\n" "${RED}Unsupported package manager: ${PACKAGER}${RC}"
exit 1
;;
esac

View File

@ -51,3 +51,11 @@ script = "3-global-theme.sh"
[[data]]
name = "Remove Snaps"
script = "4-remove-snaps.sh"
[[data]]
name = "SSH-Samba Setup"
script = "5-samba-ssh-setup.sh"
[[data]]
name = "Docker Setup"
script = "6-docker-setup.sh"

View File

@ -1,5 +0,0 @@
#!/bin/sh
say_hello () {
echo Hi
}

View File

@ -1,6 +0,0 @@
#!/bin/sh
# The current working directory will always be inside "commands"
. test/lib.sh
say_hello

179
tabs/utils/auto-login.sh Normal file
View File

@ -0,0 +1,179 @@
#!/bin/sh -e
. ../common-script.sh
# Function to list common session options
list_sessions() {
echo "Select the session:"
echo "1) GNOME (gnome.desktop)"
echo "2) KDE Plasma (plasma.desktop)"
echo "3) XFCE (xfce.desktop)"
echo "4) LXDE (LXDE.desktop)"
echo "5) LXQt (lxqt.desktop)"
echo "6) Cinnamon (cinnamon.desktop)"
echo "7) MATE (mate.desktop)"
echo "8) Openbox (openbox.desktop)"
echo "9) i3 (i3.desktop)"
echo "10) Custom session"
echo "Enter your choice [1-10]: "
read session_choice
case "$session_choice" in
1) session="gnome.desktop" ;;
2) session="plasma.desktop" ;;
3) session="xfce.desktop" ;;
4) session="LXDE.desktop" ;;
5) session="lxqt.desktop" ;;
6) session="cinnamon.desktop" ;;
7) session="mate.desktop" ;;
8) session="openbox.desktop" ;;
9) session="i3.desktop" ;;
10)
echo "Enter custom session name (e.g., mysession.desktop): "
read -r session ;;
*)
echo "Invalid option selected."
exit 1 ;;
esac
}
# Function to configure LightDM
configure_lightdm() {
echo "Configuring LightDM for autologin..."
echo "Enter username for LightDM autologin: "
read -r user
$ESCALATION_TOOL "echo '[Seat:*]' > /etc/lightdm/lightdm.conf.d/50-autologin.conf"
$ESCALATION_TOOL "echo 'autologin-user=$user' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf"
$ESCALATION_TOOL "echo 'autologin-user-timeout=0' >> /etc/lightdm/lightdm.conf.d/50-autologin.conf"
echo "LightDM has been configured for autologin."
}
# Function to remove LightDM autologin
remove_lightdm_autologin() {
echo "Removing LightDM autologin configuration..."
$ESCALATION_TOOL rm -f /etc/lightdm/lightdm.conf.d/50-autologin.conf
echo "LightDM autologin configuration has been removed."
}
# Function to configure GDM
configure_gdm() {
echo "Configuring GDM for autologin..."
echo "Enter username for GDM autologin: "
read -r user
$ESCALATION_TOOL "echo '[daemon]' > /etc/gdm/custom.conf"
$ESCALATION_TOOL "echo 'AutomaticLoginEnable = true' >> /etc/gdm/custom.conf"
$ESCALATION_TOOL "echo 'AutomaticLogin = $user' >> /etc/gdm/custom.conf"
echo "GDM has been configured for autologin."
}
# Function to remove GDM autologin
remove_gdm_autologin() {
echo "Removing GDM autologin configuration..."
$ESCALATION_TOOL sed -i '/AutomaticLoginEnable/d' /etc/gdm/custom.conf
$ESCALATION_TOOL sed -i '/AutomaticLogin/d' /etc/gdm/custom.conf
echo "GDM autologin configuration has been removed."
}
# Function to configure SDDM
configure_sddm() {
echo "Configuring SDDM for autologin..."
echo "Enter username for SDDM autologin: "
read -r user
list_sessions # Show session options
$ESCALATION_TOOL "echo '[Autologin]' > /etc/sddm.conf"
$ESCALATION_TOOL "echo 'User=$user' >> /etc/sddm.conf"
$ESCALATION_TOOL "echo 'Session=$session' >> /etc/sddm.conf"
echo "SDDM has been configured for autologin."
}
# Function to remove SDDM autologin
remove_sddm_autologin() {
echo "Removing SDDM autologin configuration..."
$ESCALATION_TOOL sed -i '/\[Autologin\]/,+2d' /etc/sddm.conf
echo "SDDM autologin configuration has been removed."
}
# Function to configure LXDM
configure_lxdm() {
echo "Configuring LXDM for autologin..."
echo "Enter username for LXDM autologin: "
read -r user
list_sessions # Show session options
$ESCALATION_TOOL sed -i "s/^#.*autologin=.*$/autologin=${user}/" /etc/lxdm/lxdm.conf
$ESCALATION_TOOL sed -i "s|^#.*session=.*$|session=/usr/bin/${session}|; s|^session=.*$|session=/usr/bin/${session}|" /etc/lxdm/lxdm.conf
echo "LXDM has been configured for autologin."
}
# Function to remove LXDM autologin
remove_lxdm_autologin() {
echo "Removing LXDM autologin configuration..."
$ESCALATION_TOOL sed -i "s/^autologin=.*$/#autologin=/" /etc/lxdm/lxdm.conf
$ESCALATION_TOOL sed -i "s/^session=.*$/#session=/" /etc/lxdm/lxdm.conf
echo "LXDM autologin configuration has been removed."
}
# Function to configure or remove autologin based on user choice
configure_or_remove_autologin() {
echo "Do you want to add or remove autologin?"
echo "1) Add autologin"
echo "2) Remove autologin"
echo "Enter your choice [1-2]: "
read action_choice
if [ "$action_choice" = "1" ]; then
echo "Choose the display manager to configure:"
echo "1) LightDM"
echo "2) GDM"
echo "3) SDDM"
echo "4) LXDM"
echo "Enter your choice [1-4]: "
read choice
case "$choice" in
1) configure_lightdm ;;
2) configure_gdm ;;
3) configure_sddm ;;
4) configure_lxdm ;;
*) echo "Invalid option selected." ;;
esac
elif [ "$action_choice" = "2" ]; then
echo "Choose the display manager to remove autologin:"
echo "1) LightDM"
echo "2) GDM"
echo "3) SDDM"
echo "4) LXDM"
echo "Enter your choice [1-4]: "
read choice
case "$choice" in
1) remove_lightdm_autologin ;;
2) remove_gdm_autologin ;;
3) remove_sddm_autologin ;;
4) remove_lxdm_autologin ;;
*) echo "Invalid option selected." ;;
esac
else
echo "Invalid choice. Exiting..."
exit 1
fi
echo "Action completed. Exiting..."
exit 0
}
checkEnv
checkEscalationTool
configure_or_remove_autologin

View File

@ -2,9 +2,9 @@
. ../common-script.sh
# Function to check bluetoothctl is installed
# Function to check Bluez is installed
setupBluetooth() {
echo "Install bluetoothctl if not already installed..."
printf "%b\n" "${YELLOW}Installing Bluez...${RC}"
if ! command_exists bluetoothctl; then
case ${PACKAGER} in
pacman)
@ -15,39 +15,26 @@ setupBluetooth() {
;;
esac
else
echo "Bluetoothctl is already installed."
printf "%b\n" "${GREEN}Bluez is already installed.${RC}"
fi
# Check if bluetooth service is running
if ! systemctl is-active --quiet bluetooth; then
echo "Bluetooth service is not running. Starting it now..."
printf "%b\n" "${YELLOW}Bluetooth service is not running. Starting it now...${RC}"
$ESCALATION_TOOL systemctl start bluetooth
if systemctl is-active --quiet bluetooth; then
echo "bluetooth service started successfully."
printf "%b\n" "${GREEN}Bluetooth service started successfully.${RC}"
fi
fi
}
# Function to display colored text
colored_echo() {
local color=$1
local text=$2
case $color in
red) echo -e "\033[31m$text\033[0m" ;;
green) echo -e "\033[32m$text\033[0m" ;;
yellow) echo -e "\033[33m$text\033[0m" ;;
blue) echo -e "\033[34m$text\033[0m" ;;
*) echo "$text" ;;
esac
}
# Function to display the main menu
main_menu() {
while true; do
clear
colored_echo blue "Bluetooth Manager"
colored_echo blue "================="
printf "%b\n" "${YELLOW}Bluetooth Manager${RC}"
printf "%b\n" "${YELLOW}=================${RC}"
echo "1. Scan for devices"
echo "2. Pair with a device"
echo "3. Connect to a device"
@ -55,7 +42,7 @@ main_menu() {
echo "5. Remove a device"
echo "0. Exit"
echo -n "Choose an option: "
read -e choice
read choice
case $choice in
1) scan_devices ;;
@ -64,7 +51,7 @@ main_menu() {
4) disconnect_device ;;
5) remove_device ;;
0) exit 0 ;;
*) colored_echo red "Invalid option. Please try again." ;;
*) printf "%b\n" "${RED}Invalid option. Please try again.${RC}" ;;
esac
done
}
@ -72,13 +59,13 @@ main_menu() {
# Function to scan for devices
scan_devices() {
clear
colored_echo yellow "Scanning for devices..."
printf "%b\n" "${YELLOW}Scanning for devices...${RC}"
bluetoothctl --timeout 10 scan on
devices=$(bluetoothctl devices)
if [ -z "$devices" ]; then
colored_echo red "No devices found."
printf "%b\n" "${RED}No devices found.${RC}"
else
colored_echo green "Devices found:"
printf "%b\n" "${GREEN}Devices found:${RC}"
echo "$devices"
fi
echo "Press any key to return to the main menu..."
@ -87,49 +74,51 @@ scan_devices() {
# Function to prompt for MAC address using numbers
prompt_for_mac() {
local action=$1
local command=$2
local prompt_msg=$3
local success_msg=$4
local failure_msg=$5
action=$1
command=$2
prompt_msg=$3
success_msg=$4
failure_msg=$5
while true; do
clear
devices=$(bluetoothctl devices)
if [ -z "$devices" ]; then
colored_echo red "No devices available. Please scan for devices first."
printf "%b\n" "${RED}No devices available. Please scan for devices first.${RC}"
echo "Press any key to return to the main menu..."
read -n 1
return
fi
# Display devices with numbers
IFS=$'\n' read -r -a device_list <<<"$devices"
for i in "${!device_list[@]}"; do
echo "$((i+1)). ${device_list[$i]}"
device_list=$(echo "$devices" | tr '\n' '\n')
i=1
echo "$device_list" | while IFS= read -r device; do
echo "$i. $device"
i=$((i + 1))
done
echo "0. Exit to main menu"
echo -n "$prompt_msg"
read -e choice
read choice
# Validate the choice
if [[ $choice =~ ^[0-9]+$ ]] && [ "$choice" -le "${#device_list[@]}" ] && [ "$choice" -gt 0 ]; then
device=${device_list[$((choice-1))]}
if echo "$choice" | grep -qE '^[0-9]+$' && [ "$choice" -le "$((i - 1))" ] && [ "$choice" -gt 0 ]; then
device=$(echo "$device_list" | sed -n "${choice}p")
mac=$(echo "$device" | awk '{print $2}')
if bluetoothctl info "$mac" > /dev/null 2>&1; then
bluetoothctl $command "$mac" && {
colored_echo green "$success_msg"
printf "%b\n" "${GREEN}$success_msg${RC}"
break
} || {
colored_echo red "$failure_msg"
printf "%b\n" "${RED}$failure_msg${RC}"
}
else
colored_echo red "Invalid MAC address. Please try again."
printf "%b\n" "${RED}Invalid MAC address. Please try again.${RC}"
fi
elif [ "$choice" -eq 0 ]; then
return
else
colored_echo red "Invalid choice. Please try again."
printf "%b\n" "${RED}Invalid choice. Please try again.${RC}"
fi
done
echo "Press any key to return to the main menu..."

View File

@ -0,0 +1,193 @@
#!/bin/sh -e
. ../common-script.sh
# Function to display usage instructions
usage() {
printf "%b\n" "${RED} Usage: $0 ${RC}"
echo "No arguments needed. The script will prompt for ISO path and USB device."
exit 1
}
# Function to display all available block devices
list_devices() {
printf "%b\n" "${YELLOW} Available devices and partitions: ${RC}"
echo ""
$ESCALATION_TOOL lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
echo ""
}
# Function to fetch the latest Arch Linux ISO
fetch_arch_latest_iso() {
ARCH_BASE_URL="https://archive.archlinux.org/iso/"
ARCH_LATEST=$(curl -s "$ARCH_BASE_URL" | grep -oP '(?<=href=")[0-9]{4}\.[0-9]{2}\.[0-9]{2}(?=/)' | sort -V | tail -1)
ARCH_URL="${ARCH_BASE_URL}${ARCH_LATEST}/archlinux-${ARCH_LATEST}-x86_64.iso"
printf "%b\n" "${GREEN} Selected Arch Linux (latest) ISO URL: ${RC} $ARCH_URL"
}
# Function to fetch older Arch Linux ISOs and display in a table format
fetch_arch_older_isos() {
ARCH_BASE_URL="https://archive.archlinux.org/iso/"
ARCH_VERSIONS=$(curl -s "$ARCH_BASE_URL" | grep -oP '(?<=href=")[0-9]{4}\.[0-9]{2}\.[0-9]{2}(?=/)' | sort -V)
# Filter versions to include only those from 2017-04-01 and later
MIN_DATE="2017.04.01"
ARCH_VERSIONS=$(echo "$ARCH_VERSIONS" | awk -v min_date="$MIN_DATE" '$0 >= min_date')
if [ -z "$ARCH_VERSIONS" ]; then
printf "%b\n" "${RED}No Arch Linux versions found from ${MIN_DATE} onwards.${RC}"
exit 1
fi
printf "%b\n" "${YELLOW}Available Arch Linux versions from ${MIN_DATE} onwards:${RC}"
COUNTER=1
ROW_ITEMS=6 # Number of versions to show per row
for VERSION in $ARCH_VERSIONS; do
printf "%-5s${YELLOW}%-15s ${RC}" "$COUNTER)" "$VERSION"
if [ $(( COUNTER % ROW_ITEMS )) -eq 0 ]; then
echo "" # New line after every 6 versions
fi
COUNTER=$((COUNTER + 1))
done
printf "\n" # New line after the last row
printf "Select an Arch Linux version (1-%d): " "$((COUNTER - 1))"
read -r ARCH_OPTION
ARCH_DIR=$(echo "$ARCH_VERSIONS" | sed -n "${ARCH_OPTION}p")
ARCH_URL="${ARCH_BASE_URL}${ARCH_DIR}/archlinux-${ARCH_DIR}-x86_64.iso"
printf "%b\n" "${GREEN}Selected Arch Linux (older) ISO URL: $ARCH_URL${RC}"
}
# Function to fetch the latest Debian Linux ISO
fetch_debian_latest_iso() {
DEBIAN_URL=$(curl -s https://www.debian.org/distrib/netinst | grep -oP '(?<=href=")[^"]+debian-[0-9.]+-amd64-netinst.iso(?=")' | head -1)
printf "%b\n" "${GREEN} Selected Debian Linux (latest) ISO URL: ${RC} $DEBIAN_URL"
}
# Function to ask whether to use local or online ISO
choose_iso_source() {
printf "%b\n" "${YELLOW} Do you want to use a local ISO or download online? ${RC}"
printf "1) Download online\n"
printf "2) Use local ISO\n"
printf "\n"
printf "Select option (1-2): "
read -r ISO_SOURCE_OPTION
case $ISO_SOURCE_OPTION in
1)
fetch_iso_urls # Call the function to fetch online ISO URLs
;;
2)
printf "Enter the path to the already downloaded ISO file: "
read -r ISO_PATH
if [ ! -f "$ISO_PATH" ]; then
printf "%b\n" "${RED} ISO file not found: $ISO_PATH ${RC}"
exit 1
fi
;;
*)
printf "%b\n" "${RED}Invalid option selected. ${RC}"
exit 1
;;
esac
}
# Function to fetch ISO URLs
fetch_iso_urls() {
clear
printf "%b\n" "${YELLOW}Available ISOs for download:${RC}"
echo "1) Arch Linux (latest)"
echo "2) Arch Linux (older versions)"
echo "3) Debian Linux (latest)"
echo ""
read -p "Select the ISO you want to download (1-3): " ISO_OPTION
case $ISO_OPTION in
1)
fetch_arch_latest_iso
ISO_URL=$ARCH_URL
;;
2)
fetch_arch_older_isos
ISO_URL=$ARCH_URL
;;
3)
fetch_debian_latest_iso
ISO_URL=$DEBIAN_URL
;;
*)
printf "%b\n" "${RED}Invalid option selected.${RC}"
exit 1
;;
esac
ISO_PATH=$(basename "$ISO_URL")
printf "%b\n" "${YELLOW}Downloading ISO...${RC}"
curl -L -o "$ISO_PATH" "$ISO_URL"
if [ $? -ne 0 ]; then
printf "%b\n" "${RED}Failed to download the ISO file.${RC}"
exit 1
fi
}
write_iso(){
clear
# Ask whether to use a local or online ISO
choose_iso_source
clear
# Display all available devices
list_devices
# Prompt user for USB device
read -p "Enter the USB device (e.g., /dev/sdX): " USB_DEVICE
# Verify that the USB device exists
if [ ! -b "$USB_DEVICE" ]; then
printf "%b\n" "${RED}USB device not found: $USB_DEVICE${RC}"
exit 1
fi
# Confirm the device selection with the user
printf "%b\n" "${RED}WARNING: This will erase all data on ${USB_DEVICE}. Are you sure you want to continue? (yes/no)${RC}"
read -r CONFIRMATION
if [ "$CONFIRMATION" != "yes" ]; then
printf "%b\n" "${YELLOW}Operation cancelled.${RC}"
exit 1
fi
# Display progress and create the bootable USB drive
printf "%b\n" "${YELLOW}Creating bootable USB drive...${RC}"
if ! $ESCALATION_TOOL dd if="$ISO_PATH" of="$USB_DEVICE" bs=4M status=progress oflag=sync; then
printf "%b\n" "${RED}Failed to create bootable USB drive${RC}"
exit 1
fi
# Sync to ensure all data is written
if ! $ESCALATION_TOOL sync; then
printf "%b\n" "${RED}Failed to sync data${RC}"
exit 1
fi
printf "%b\n" "${GREEN}Bootable USB drive created successfully!${RC}"
# Eject the USB device
printf "%b\n" "${YELLOW}Ejecting ${USB_DEVICE}...${RC}"
if ! $ESCALATION_TOOL umount "${USB_DEVICE}"* 2>/dev/null; then
printf "%b\n" "${RED}Failed to unmount ${USB_DEVICE}${RC}"
fi
if ! $ESCALATION_TOOL eject "$USB_DEVICE"; then
printf "%b\n" "${RED}Failed to eject ${USB_DEVICE}${RC}"
fi
printf "%b\n" "${GREEN}You can safely remove your USB drive. Reinsert the drive to be detected.${RC}"
}
checkEnv
checkEscalationTool
write_iso

View File

@ -2,6 +2,8 @@
. ./utility_functions.sh
. ../../common-script.sh
# Function to auto-detect displays and set common resolution
auto_detect_displays() {
if confirm_action "Auto-detect displays and set common resolution?"; then
@ -13,11 +15,19 @@ auto_detect_displays() {
for monitor in $monitors; do
resolutions=$(get_unique_resolutions "$monitor")
common_resolutions=$(comm -12 <(echo "$common_resolutions") <(echo "$resolutions"))
temp_common_resolutions=$(mktemp)
temp_resolutions=$(mktemp)
echo "$common_resolutions" > "$temp_common_resolutions"
echo "$resolutions" > "$temp_resolutions"
common_resolutions=$(comm -12 "$temp_common_resolutions" "$temp_resolutions")
rm -f "$temp_common_resolutions" "$temp_resolutions"
done
if [ -z "$common_resolutions" ]; then
dialog --msgbox "No common resolution found among connected monitors." 10 60
echo "No common resolution found among connected monitors."
return
fi

View File

@ -2,38 +2,42 @@
. ./utility_functions.sh
. ../../common-script.sh
# Function to change monitor orientation
change_orientation() {
monitor_list=$(detect_connected_monitors)
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
clear
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Change Monitor Orientation${RESET}"
echo -e "${BLUE}=========================================${RESET}"
echo -e "${YELLOW}Choose a monitor to configure:${RESET}"
for i in "${!monitor_array[@]}"; do
echo -e "$((i + 1)). ${CYAN}${monitor_array[i]}${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Change Monitor Orientation${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW}Choose a monitor to configure:${RC}"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
i=$((i + 1))
done
read -p "Enter the number of the monitor: " monitor_choice
if ! [[ "$monitor_choice" =~ ^[0-9]+$ ]] || (( monitor_choice < 1 )) || (( monitor_choice > ${#monitor_array[@]} )); then
echo -e "${RED}Invalid selection.${RESET}"
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then
printf "%b\n" "${RED}Invalid selection.${RC}"
return
fi
monitor_name="${monitor_array[monitor_choice - 1]}"
monitor_name=$(echo "$monitor_array" | cut -d' ' -f"$monitor_choice")
clear
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Set Orientation for $monitor_name${RESET}"
echo -e "${BLUE}=========================================${RESET}"
echo -e "${YELLOW}Choose orientation:${RESET}"
echo -e "1. ${CYAN}Normal${RESET}"
echo -e "2. ${CYAN}Left${RESET}"
echo -e "3. ${CYAN}Right${RESET}"
echo -e "4. ${CYAN}Inverted${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Set Orientation for $monitor_name${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW}Choose orientation:${RC}"
printf "%b\n" "1. ${GREEN}Normal${RC}"
printf "%b\n" "2. ${GREEN}Left${RC}"
printf "%b\n" "3. ${GREEN}Right${RC}"
printf "%b\n" "4. ${GREEN}Inverted${RC}"
read -p "Enter the number of the orientation: " orientation_choice
@ -42,15 +46,15 @@ change_orientation() {
2) orientation="left" ;;
3) orientation="right" ;;
4) orientation="inverted" ;;
*) echo -e "${RED}Invalid selection.${RESET}"; return ;;
*) printf "%b\n" "${RED}Invalid selection.${RC}"; return ;;
esac
if confirm_action "Change orientation of ${CYAN}$monitor_name${RESET} to ${CYAN}$orientation${RESET}?"; then
echo -e "${GREEN}Changing orientation of $monitor_name to $orientation${RESET}"
if confirm_action "Change orientation of $monitor_name to $orientation?"; then
printf "%b\n" "${GREEN}Changing orientation of $monitor_name to $orientation${RC}"
execute_command "xrandr --output $monitor_name --rotate $orientation"
echo -e "${GREEN}Orientation changed successfully.${RESET}"
printf "%b\n" "${GREEN}Orientation changed successfully.${RC}"
else
echo -e "${RED}Action canceled.${RESET}"
printf "%b\n" "${RED}Action canceled.${RC}"
fi
}

View File

@ -2,54 +2,50 @@
. ./utility_functions.sh
RESET='\033[0m'
BOLD='\033[1m'
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
CYAN='\033[36m'
. ../../common-script.sh
# Function to disable a monitor
disable_monitor() {
monitor_list=$(detect_connected_monitors)
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
clear
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Disable Monitor${RESET}"
echo -e "${BLUE}=========================================${RESET}"
echo -e "${YELLOW}Choose a monitor to disable:${RESET}"
for i in "${!monitor_array[@]}"; do
echo -e "$((i + 1)). ${CYAN}${monitor_array[i]}${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Disable Monitor${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "Choose a monitor to disable:"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
i=$((i + 1))
done
read -p "Enter the number of the monitor: " monitor_choice
if ! [[ "$monitor_choice" =~ ^[0-9]+$ ]] || (( monitor_choice < 1 )) || (( monitor_choice > ${#monitor_array[@]} )); then
echo -e "${RED}Invalid selection.${RESET}"
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then
printf "%b\n" "${RED}Invalid selection.${RC}"
return
fi
monitor_name="${monitor_array[monitor_choice - 1]}"
monitor_name=$(echo "$monitor_array" | cut -d' ' -f"$monitor_choice")
echo -e "${RED}Warning: Disabling the monitor will turn it off and may affect your display setup.${RESET}"
printf "%b\n" "${RED}Warning: Disabling the monitor will turn it off and may affect your display setup.${RC}"
if confirm_action "Do you really want to disable ${CYAN}$monitor_name${RESET}?"; then
echo -e "${GREEN}Disabling $monitor_name${RESET}"
if confirm_action "Do you really want to disable ${GREEN}$monitor_name${RC}?"; then
printf "%b\n" "${GREEN}Disabling $monitor_name${RC}"
execute_command "xrandr --output $monitor_name --off"
echo -e "${GREEN}Monitor $monitor_name disabled successfully.${RESET}"
printf "%b\n" "${GREEN}Monitor $monitor_name disabled successfully.${RC}"
else
echo -e "${RED}Action canceled.${RESET}"
printf "%b\n" "${RED}Action canceled.${RC}"
fi
}
# Function to prompt for confirmation
confirm_action() {
local action="$1"
echo -e "${BOLD}${YELLOW}$action${RESET}"
action="$1"
printf "%b\n" "${YELLOW}$action${RC}"
read -p "Are you sure? (y/n): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
if echo "$confirm" | grep -qE '^[Yy]$'; then
return 0
else
return 1

View File

@ -2,15 +2,17 @@
. ./utility_functions.sh
. ../../common-script.sh
# Function to duplicate displays
duplicate_displays() {
primary=$(detect_connected_monitors | head -n 1)
for monitor in $(detect_connected_monitors | tail -n +2); do
if confirm_action "Duplicate $monitor to $primary?"; then
echo "Duplicating $monitor to $primary"
execute_command "xrandr --output $monitor --same-as $primary"
fi
done
primary=$(detect_connected_monitors | head -n 1)
for monitor in $(detect_connected_monitors | tail -n +2); do
if confirm_action "Duplicate $monitor to $primary?"; then
printf "%b\n" "${GREEN}Duplicating $monitor to $primary${RC}"
execute_command "xrandr --output $monitor --same-as $primary"
fi
done
}
duplicate_displays

View File

@ -2,55 +2,40 @@
. ./utility_functions.sh
RESET='\033[0m'
BOLD='\033[1m'
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
CYAN='\033[36m'
. ../../common-script.sh
# Function to enable a monitor
enable_monitor() {
monitor_list=$(detect_connected_monitors)
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
clear
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Enable Monitor${RESET}"
echo -e "${BLUE}=========================================${RESET}"
echo -e "${YELLOW}Choose a monitor to enable:${RESET}"
for i in "${!monitor_array[@]}"; do
echo -e "$((i + 1)). ${CYAN}${monitor_array[i]}${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Enable Monitor${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW}Choose a monitor to enable:${RC}"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${GREEN}$monitor${RC}"
i=$((i + 1))
done
read -p "Enter the number of the monitor: " monitor_choice
if ! [[ "$monitor_choice" =~ ^[0-9]+$ ]] || (( monitor_choice < 1 )) || (( monitor_choice > ${#monitor_array[@]} )); then
echo -e "${RED}Invalid selection.${RESET}"
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then
printf "%b\n" "${RED}Invalid selection.${RC}"
return
fi
monitor_name="${monitor_array[monitor_choice - 1]}"
monitor_name=$(echo "$monitor_array" | cut -d' ' -f"$monitor_choice")
if confirm_action "Enable ${CYAN}$monitor_name${RESET}?"; then
echo -e "${GREEN}Enabling $monitor_name${RESET}"
if confirm_action "Enable $monitor_name?"; then
printf "%b\n" "${GREEN}Enabling $monitor_name${RC}"
execute_command "xrandr --output $monitor_name --auto"
echo -e "${GREEN}Monitor $monitor_name enabled successfully.${RESET}"
printf "%b\n" "${GREEN}Monitor $monitor_name enabled successfully.${RC}"
else
echo -e "${RED}Action canceled.${RESET}"
fi
}
# Function to prompt for confirmation
confirm_action() {
local action="$1"
echo -e "${BOLD}${YELLOW}$action${RESET}"
read -p "Are you sure? (y/n): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
return 0
else
return 1
printf "%b\n" "${RED}Action canceled.${RC}"
fi
}

View File

@ -2,14 +2,22 @@
. ./utility_functions.sh
. ../../common-script.sh
# Function to extend displays
extend_displays() {
monitors=($(detect_connected_monitors))
for ((i=1; i<${#monitors[@]}; i++)); do
if confirm_action "Extend ${monitors[$i]} to the right of ${monitors[$((i-1))]}?"; then
echo "Extending ${monitors[$i]} to the right of ${monitors[$((i-1))]}"
execute_command "xrandr --output ${monitors[$i]} --right-of ${monitors[$((i-1))]}"
monitors=$(detect_connected_monitors)
monitor_array=$(echo "$monitors" | tr '\n' ' ')
i=1
for monitor in $monitor_array; do
if [ "$i" -gt 1 ]; then
prev_monitor=$(echo "$monitor_array" | cut -d' ' -f$((i-1)))
if confirm_action "Extend $monitor to the right of $prev_monitor?"; then
printf "%b\n" "${GREEN}Extending $monitor to the right of $prev_monitor${RC}"
execute_command "xrandr --output $monitor --right-of $prev_monitor"
fi
fi
i=$((i + 1))
done
}

View File

@ -2,35 +2,39 @@
. ./utility_functions.sh
. ../../common-script.sh
# Function to manage monitor arrangement
manage_arrangement() {
monitor_list=$(detect_connected_monitors)
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
clear
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Manage Monitor Arrangement${RESET}"
echo -e "${BLUE}=========================================${RESET}"
echo -e "${YELLOW}Choose the monitor to arrange:${RESET}"
for i in "${!monitor_array[@]}"; do
echo -e "$((i + 1)). ${CYAN}${monitor_array[i]}${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Manage Monitor Arrangement${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW}Choose the monitor to arrange:${RC}"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${YELLOW}$monitor${RC}"
i=$((i + 1))
done
read -p "Enter the number of the monitor to arrange: " monitor_choice
if ! [[ "$monitor_choice" =~ ^[0-9]+$ ]] || (( monitor_choice < 1 )) || (( monitor_choice > ${#monitor_array[@]} )); then
echo -e "${RED}Invalid selection.${RESET}"
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then
printf "%b\n" "${RED}Invalid selection.${RC}"
return
fi
monitor_name="${monitor_array[monitor_choice - 1]}"
monitor_name=$(echo "$monitor_array" | cut -d' ' -f"$monitor_choice")
clear
echo -e "${YELLOW}Choose position relative to other monitors:${RESET}"
echo -e "1. ${CYAN}Left of${RESET}"
echo -e "2. ${CYAN}Right of${RESET}"
echo -e "3. ${CYAN}Above${RESET}"
echo -e "4. ${CYAN}Below${RESET}"
printf "%b\n" "${YELLOW}Choose position relative to other monitors:${RC}"
printf "%b\n" "1. ${YELLOW}Left of${RC}"
printf "%b\n" "2. ${YELLOW}Right of${RC}"
printf "%b\n" "3. ${YELLOW}Above${RC}"
printf "%b\n" "4. ${YELLOW}Below${RC}"
read -p "Enter the number of the position: " position_choice
@ -39,31 +43,31 @@ manage_arrangement() {
2) position="--right-of" ;;
3) position="--above" ;;
4) position="--below" ;;
*) echo -e "${RED}Invalid selection.${RESET}"; return ;;
*) printf "%b\n" "${RED}Invalid selection.${RC}"; return ;;
esac
echo -e "${YELLOW}Choose the reference monitor:${RESET}"
for i in "${!monitor_array[@]}"; do
if [[ "${monitor_array[i]}" != "$monitor_name" ]]; then
echo -e "$((i + 1)). ${CYAN}${monitor_array[i]}${RESET}"
printf "%b\n" "${YELLOW}Choose the reference monitor:${RC}"
for i in $monitor_array; do
if [ "$i" != "$monitor_name" ]; then
printf "%b\n" "$((i + 1)). ${YELLOW}$i${RC}"
fi
done
read -p "Enter the number of the reference monitor: " ref_choice
if ! [[ "$ref_choice" =~ ^[0-9]+$ ]] || (( ref_choice < 1 )) || (( ref_choice > ${#monitor_array[@]} )) || (( ref_choice == monitor_choice )); then
echo -e "${RED}Invalid selection.${RESET}"
if ! echo "$ref_choice" | grep -qE '^[0-9]+$' || [ "$ref_choice" -lt 1 ] || [ "$ref_choice" -gt "$((i - 1))" ] || [ "$ref_choice" -eq "$monitor_choice" ]; then
printf "%b\n" "${RED}Invalid selection.${RC}"
return
fi
ref_monitor="${monitor_array[ref_choice - 1]}"
ref_monitor=$(echo "$monitor_array" | cut -d' ' -f"$ref_choice")
if confirm_action "Arrange ${CYAN}$monitor_name${RESET} ${position} ${CYAN}$ref_monitor${RESET}?"; then
echo -e "${GREEN}Arranging $monitor_name ${position} $ref_monitor${RESET}"
if confirm_action "Arrange ${YELLOW}$monitor_name${RC} ${position} ${YELLOW}$ref_monitor${RC}?"; then
printf "%b\n" "${GREEN}Arranging $monitor_name ${position} $ref_monitor${RC}"
execute_command "xrandr --output $monitor_name $position $ref_monitor"
echo -e "${GREEN}Arrangement updated successfully.${RESET}"
printf "%b\n" "${GREEN}Arrangement updated successfully.${RC}"
else
echo -e "${RED}Action canceled.${RESET}"
printf "%b\n" "${RED}Action canceled.${RC}"
fi
}

View File

@ -2,22 +2,24 @@
. ./utility_functions.sh
# Function to reset scaling back to 1 (native resolution) for all monitors
reset_scaling() {
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Reset Monitor Scaling to Native Resolution${RESET}"
echo -e "${BLUE}=========================================${RESET}"
. ../../common-script.sh
# Function to Reset scaling back to 1 (native resolution) for all monitors
Reset_scaling() {
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Reset Monitor Scaling to Native Resolution${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
monitor_list=$(detect_connected_monitors)
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
for monitor in "${monitor_array[@]}"; do
echo -e "${CYAN}Resetting scaling for $monitor to 1x1 (native resolution)${RESET}"
for monitor in $monitor_array; do
printf "%b\n" "${CYAN}Resetting scaling for $monitor to 1x1 (native resolution)${RC}"
execute_command "xrandr --output $monitor --scale 1x1"
done
echo -e "${GREEN}All monitor scalings have been reset to 1x1.${RESET}"
printf "%b\n" "${GREEN}All monitor scalings have been Reset to 1x1.${RC}"
}
# Call the reset_scaling function
reset_scaling
# Call the Reset_scaling function
Reset_scaling

View File

@ -2,42 +2,42 @@
. ./utility_functions.sh
. ../../common-script.sh
# Function to scale smaller monitors to the highest resolution of a bigger monitor
scale_monitors() {
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Scale Monitors to Highest Resolution${RESET}"
echo -e "${BLUE}=========================================${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Scale Monitors to Highest Resolution${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
monitor_list=$(detect_connected_monitors)
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
# Get the highest resolution among all monitors
max_width=0
max_height=0
for monitor in "${monitor_array[@]}"; do
for monitor in $monitor_array; do
res=$(xrandr | grep -A1 "^$monitor connected" | tail -1 | awk '{print $1}')
width=$(echo $res | awk -Fx '{print $1}')
height=$(echo $res | awk -Fx '{print $2}')
width=$(echo "$res" | awk -Fx '{print $1}')
height=$(echo "$res" | awk -Fx '{print $2}')
if (( width > max_width )); then
if [ "$width" -gt "$max_width" ]; then
max_width=$width
fi
if (( height > max_height )); then
if [ "$height" -gt "$max_height" ]; then
max_height=$height
fi
done
echo -e "${CYAN}Highest resolution found: ${max_width}x${max_height}${RESET}"
printf "%b\n" "${YELLOW}Highest resolution found: ${max_width}x${max_height}${RC}"
# Scale all monitors to the maximum resolution
for monitor in "${monitor_array[@]}"; do
echo -e "${CYAN}Scaling $monitor to ${max_width}x${max_height}${RESET}"
for monitor in $monitor_array; do
printf "%b\n" "${YELLOW}Scaling $monitor to ${max_width}x${max_height}${RC}"
execute_command "xrandr --output $monitor --scale-from ${max_width}x${max_height}"
done
echo -e "${GREEN}Scaling complete. All monitors are now scaled to ${max_width}x${max_height}.${RESET}"
printf "%b\n" "${GREEN}Scaling complete. All monitors are now scaled to ${max_width}x${max_height}.${RC}"
}
# Call the scale_monitors function

View File

@ -0,0 +1,85 @@
#!/bin/sh -e
. ./utility_functions.sh
# Function to adjust brightness for a selected monitor
adjust_monitor_brightness() {
while true; do
monitor_list=$(detect_connected_monitors)
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
set -- $monitor_array
count=1
clear
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Adjust Monitor Brightness${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW}Choose a monitor to adjust brightness:${RC}"
for monitor in "$@"; do
echo "$count. $monitor"
count=$((count + 1))
done
echo "Enter the number of the monitor (or 'q' to quit): "
read monitor_choice
if [ "$monitor_choice" = "q" ]; then
printf "%b\n" "${RED}Exiting...${RC}"
return
fi
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$'; then
echo "Invalid selection. Please try again."
echo "Press [Enter] to continue..."
read dummy
continue
fi
if [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$#" ]; then
printf "%b\n" "${RED}Invalid selection. Please try again.${RC}"
echo "Press [Enter] to continue..."
read dummy
continue
fi
monitor_name=$(eval echo "\${$monitor_choice}")
current_brightness=$(get_current_brightness "$monitor_name")
# Correctly calculate the brightness percentage
current_brightness_percentage=$(awk "BEGIN {printf \"%.0f\", $current_brightness * 100}")
printf "%b\n" "${YELLOW}Current brightness for $monitor_name${RC}: ${GREEN}$current_brightness_percentage%${RC}"
while true; do
echo "Enter the new brightness value as a percentage (10 to 100, or 'q' to quit): "
read new_brightness_percentage
if [ "$new_brightness_percentage" = "q" ]; then
printf "%b\n" "${RED}Exiting...${RC}"
return
fi
# Validate brightness input: accept only values above 10
if ! echo "$new_brightness_percentage" | grep -qE '^[0-9]+$' || [ "$new_brightness_percentage" -lt 10 ] || [ "$new_brightness_percentage" -gt 100 ]; then
printf "%b\n" "${RED}Invalid brightness value. Please enter a value between 10 and 100.${RC}"
continue
fi
# Convert percentage to xrandr brightness value (10% to 0.10)
new_brightness=$(awk "BEGIN {printf \"%.2f\", $new_brightness_percentage / 100}")
echo "Set brightness for $monitor_name to $new_brightness_percentage%? (y/n): "
read confirm
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
printf "%b\n" "${GREEN}Setting brightness for $monitor_name to $new_brightness_percentage%${RC}"
execute_command "xrandr --output $monitor_name --brightness $new_brightness"
printf "%b\n" "${GREEN}Brightness for $monitor_name set to $new_brightness_percentage% successfully.${RC}"
break
else
printf "%b\n" "${RED}Action canceled. Please choose a different brightness value.${RC}"
fi
done
done
}
# Call the adjust_monitor_brightness function
adjust_monitor_brightness

View File

@ -2,35 +2,39 @@
. ./utility_functions.sh
. ../../common-script.sh
# Function to set a monitor as primary
set_primary_monitor() {
monitor_list=$(detect_connected_monitors)
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
clear
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Set Primary Monitor${RESET}"
echo -e "${BLUE}=========================================${RESET}"
echo -e "${YELLOW}Choose a monitor to set as primary:${RESET}"
for i in "${!monitor_array[@]}"; do
echo -e "$((i + 1)). ${CYAN}${monitor_array[i]}${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Set Primary Monitor${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW}Choose a monitor to set as primary:${RC}"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${YELLOW}$monitor${RC}"
i=$((i + 1))
done
read -p "Enter the number of the monitor: " monitor_choice
if ! [[ "$monitor_choice" =~ ^[0-9]+$ ]] || (( monitor_choice < 1 )) || (( monitor_choice > ${#monitor_array[@]} )); then
echo -e "${RED}Invalid selection.${RESET}"
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then
printf "%b\n" "${RED}Invalid selection.${RC}"
return
fi
monitor_name="${monitor_array[monitor_choice - 1]}"
monitor_name=$(echo "$monitor_array" | cut -d' ' -f"$monitor_choice")
if confirm_action "Set ${CYAN}$monitor_name${RESET} as the primary monitor?"; then
echo -e "${GREEN}Setting $monitor_name as primary monitor${RESET}"
if confirm_action "Set $monitor_name as the primary monitor?"; then
printf "%b\n" "${GREEN}Setting $monitor_name as primary monitor${RC}"
execute_command "xrandr --output $monitor_name --primary"
echo -e "${GREEN}Monitor $monitor_name set as primary successfully.${RESET}"
printf "%b\n" "${GREEN}Monitor $monitor_name set as primary successfully.${RC}"
else
echo -e "${RED}Action canceled.${RESET}"
printf "%b\n" "${RED}Action canceled.${RC}"
fi
}

View File

@ -2,73 +2,68 @@
. ./utility_functions.sh
RESET='\033[0m'
BOLD='\033[1m'
RED='\033[31m'
GREEN='\033[32m'
YELLOW='\033[33m'
BLUE='\033[34m'
CYAN='\033[36m'
. ../../common-script.sh
# Function to set resolutions
set_resolutions() {
monitor_list=$(detect_connected_monitors)
IFS=$'\n' read -r -a monitor_array <<<"$monitor_list"
monitor_array=$(echo "$monitor_list" | tr '\n' ' ')
while true; do
clear
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Monitor Configuration${RESET}"
echo -e "${BLUE}=========================================${RESET}"
echo -e "${YELLOW}Choose a monitor to configure:${RESET}"
for i in "${!monitor_array[@]}"; do
echo -e "$((i + 1)). ${CYAN}${monitor_array[i]}${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Monitor Configuration${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW}Choose a monitor to configure:${RC}"
i=1
for monitor in $monitor_array; do
printf "%b\n" "$i. ${YELLOW}$monitor${RC}"
i=$((i + 1))
done
read -p "Enter the choice (or 'q' to quit): " monitor_choice
if [[ "$monitor_choice" == "q" ]]; then
echo -e "${RED}Exiting...${RESET}"
if [ "$monitor_choice" = "q" ]; then
printf "%b\n" "${RED}Exiting...${RC}"
return
fi
if ! [[ "$monitor_choice" =~ ^[0-9]+$ ]] || (( monitor_choice < 1 )) || (( monitor_choice > ${#monitor_array[@]} )); then
echo -e "${RED}Invalid selection. Please try again.${RESET}"
if ! echo "$monitor_choice" | grep -qE '^[0-9]+$' || [ "$monitor_choice" -lt 1 ] || [ "$monitor_choice" -gt "$((i - 1))" ]; then
printf "%b\n" "${RED}Invalid selection. Please try again.${RC}"
read -p "Press [Enter] to continue..."
continue
fi
monitor_name="${monitor_array[monitor_choice - 1]}"
monitor_name=$(echo "$monitor_array" | cut -d' ' -f"$monitor_choice")
resolutions=$(get_unique_resolutions "$monitor_name" | sort -rn -t'x' -k1,1 -k2,2)
# Create a temporary file with resolutions and indices
temp_res_file=$(mktemp)
echo "$resolutions" | awk '{print NR " " $0}' > "$temp_res_file"
# Read the resolutions into an associative array
declare -A resolution_map
while read -r index resolution; do
resolution_map[$index]="$resolution"
i=1
while read -r resolution; do
resolution_map[$i]="$resolution"
i=$((i + 1))
done < "$temp_res_file"
clear
echo -e "${BLUE}=========================================${RESET}"
echo -e "${BLUE} Resolution Configuration for ${CYAN}$monitor_name${RESET}"
echo -e "${BLUE}=========================================${RESET}"
echo -e "${YELLOW}Choose resolution for $monitor_name:${RESET}"
printf "%b\n" "${YELLOW}=========================================${RC}"
printf "%b\n" "${YELLOW} Resolution Configuration for ${YELLOW}$monitor_name${RC}"
printf "%b\n" "${YELLOW}=========================================${RC}"
awk '{print $1 ". " $2}' "$temp_res_file"
while true; do
read -p "Enter the choice (or 'q' to quit): " resolution_choice
if [[ "$resolution_choice" == "q" ]]; then
echo -e "${RED}Exiting...${RESET}"
if [ "$resolution_choice" = "q" ]; then
printf "%b\n" "${RED}Exiting...${RC}"
rm "$temp_res_file"
return
fi
if ! [[ "$resolution_choice" =~ ^[0-9]+$ ]] || (( resolution_choice < 1 )) || (( resolution_choice > ${#resolution_map[@]} )); then
echo -e "${RED}Invalid selection. Please try again.${RESET}"
if ! echo "$resolution_choice" | grep -qE '^[0-9]+$' || [ "$resolution_choice" -lt 1 ] || [ "$resolution_choice" -gt "$((i - 1))" ]; then
printf "%b\n" "${RED}Invalid selection. Please try again.${RC}"
continue
fi
@ -76,16 +71,15 @@ set_resolutions() {
selected_resolution=${resolution_map[$resolution_choice]}
read -p "Set resolution for $monitor_name to $selected_resolution? (y/n): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
echo -e "${GREEN}Setting resolution for $monitor_name to $selected_resolution${RESET}"
if echo "$confirm" | grep -qE '^[Yy]$'; then
printf "%b\n" "${GREEN}Setting resolution for $monitor_name to $selected_resolution${RC}"
execute_command "xrandr --output $monitor_name --mode $selected_resolution"
break
else
echo -e "${RED}Action canceled. Please choose a different resolution.${RESET}"
printf "%b\n" "${RED}Action canceled. Please choose a different resolution.${RC}"
fi
done
# Clean up the temporary file
rm "$temp_res_file"
done
}

View File

@ -2,42 +2,29 @@
. ../../common-script.sh
# Function to check bluetoothctl is installed
# Function to check xrandr is installed
setup_xrandr() {
echo "Install xrandr if not already installed..."
if ! command_exists xrandr; then
case ${PACKAGER} in
pacman)
$ESCALATION_TOOL "${PACKAGER}" -S --noconfirm xorg-xrandr
;;
apt-get)
$ESCALATION_TOOL "${PACKAGER}" install -y x11-xserver-utils
;;
*)
$ESCALATION_TOOL "${PACKAGER}" install -y xorg-x11-server-utils
;;
pacman)
$ESCALATION_TOOL "${PACKAGER}" -S --noconfirm xorg-xrandr
;;
apt-get)
$ESCALATION_TOOL "${PACKAGER}" install -y x11-xserver-utils
;;
*)
$ESCALATION_TOOL "${PACKAGER}" install -y xorg-x11-server-utils
;;
esac
else
echo "xrandr is already installed."
fi
}
# Function to display colored text
colored_echo() {
local color=$1
local text=$2
case $color in
red) echo -e "\033[31m$text\033[0m" ;;
green) echo -e "\033[32m$text\033[0m" ;;
yellow) echo -e "\033[33m$text\033[0m" ;;
blue) echo -e "\033[34m$text\033[0m" ;;
*) echo "$text" ;;
esac
}
# Function to execute xrandr commands and handle errors
execute_command() {
local command="$1"
command="$1"
echo "Executing: $command"
eval "$command" 2>&1 | tee /tmp/xrandr.log | tail -n 20
if [ $? -ne 0 ]; then
@ -51,9 +38,15 @@ detect_connected_monitors() {
echo "$xrandr_output" | grep " connected" | awk '{print $1}'
}
# Function to get the current brightness for a monitor
get_current_brightness() {
monitor="$1"
xrandr --verbose | grep -A 10 "^$monitor connected" | grep "Brightness:" | awk '{print $2}'
}
# Function to get resolutions for a monitor
get_unique_resolutions() {
local monitor="$1"
monitor="$1"
xrandr_output=$(xrandr)
# Get available resolutions from xrandr without line limit
available_resolutions=$(echo "$xrandr_output" | sed -n "/$monitor connected/,/^[^ ]/p" | grep -oP '\d+x\d+' | sort -u)
@ -61,22 +54,35 @@ get_unique_resolutions() {
# Define standard resolutions
standard_resolutions="1920x1080 1280x720 1600x900 2560x1440 3840x2160"
temp_file=$(mktemp)
echo "$available_resolutions" > "$temp_file"
# Filter standard resolutions to include only those available for the monitor
filtered_standard_resolutions=$(echo "$standard_resolutions" | tr ' ' '\n' | grep -xF -f <(echo "$available_resolutions"))
filtered_standard_resolutions=$(echo "$standard_resolutions" | tr ' ' '\n' | grep -xF -f "$temp_file")
rm "$temp_file"
available_res_file=$(mktemp)
filtered_standard_res_file=$(mktemp)
echo "$available_resolutions" | sort > "$available_res_file"
echo "$filtered_standard_resolutions" | sort > "$filtered_standard_res_file"
# Get remaining available resolutions (excluding standard ones)
remaining_resolutions=$(comm -23 <(echo "$available_resolutions" | sort) <(echo "$filtered_standard_resolutions" | sort))
remaining_resolutions=$(comm -23 "$available_res_file" "$filtered_standard_res_file")
rm "$available_res_file" "$filtered_standard_res_file"
# Combine filtered standard resolutions and remaining resolutions, and limit to 10 results
echo -e "$filtered_standard_resolutions\n$remaining_resolutions" | head -n 10
printf "%b\n" "$filtered_standard_resolutions\n$remaining_resolutions" | head -n 10
}
# Function to prompt for confirmation
confirm_action() {
local action="$1"
echo "$action"
read -p "Are you sure? (y/n): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
action="$1"
printf "%b\n" "${CYAN}$action${RC}"
printf "%b" "${CYAN}Are you sure? (y/n): ${RC}"
read -r confirm
if echo "$confirm" | grep -qE '^[Yy]$'; then
return 0
else
return 1

209
tabs/utils/ollama.sh Normal file
View File

@ -0,0 +1,209 @@
#!/bin/sh -e
. ../common-script.sh
installollama() {
clear
printf "%b\n" "${YELLOW}Checking if ollama is already installed...${RC}"
# Check if ollama is already installed
if command_exists ollama; then
printf "%b\n" "${GREEN}ollama is already installed.${RC}"
else
printf "%b\n" "${YELLOW}Installing ollama...${RC}"
curl -fsSL https://ollama.com/install.sh | sh
$ESCALATION_TOOL systemctl start ollama
fi
}
list_models() {
clear
printf "%b\n" "${YELLOW}Listing all models available on your system...${RC}"
ollama list
}
show_model_info() {
clear
list_models
printf "%b\n" "${YELLOW}Enter the name of the model you want to show information for (e.g., llama3.1):${RC}"
read -r model_name
printf "%b\n" "${YELLOW}Showing information for model '$model_name'...${RC}"
ollama show "$model_name"
}
# Function to display available models
display_models() {
clear
printf "%b\n" "${RED}Available Models${RC}"
printf "1. Llama 3.1 - 8B (4.7GB)\n"
printf "2. Llama 3.1 - 70B (40GB)\n"
printf "3. Llama 3.1 - 405B (231GB)\n"
printf "4. Phi 3 Mini - 3.8B (2.3GB)\n"
printf "5. Phi 3 Medium - 14B (7.9GB)\n"
printf "6. Gemma 2 - 2B (1.6GB)\n"
printf "7. Gemma 2 - 9B (5.5GB)\n"
printf "8. Gemma 2 - 27B (16GB)\n"
printf "9. Mistral - 7B (4.1GB)\n"
printf "10. Moondream 2 - 1.4B (829MB)\n"
printf "11. Neural Chat - 7B (4.1GB)\n"
printf "12. Starling - 7B (4.1GB)\n"
printf "13. Code Llama - 7B (3.8GB)\n"
printf "14. Llama 2 Uncensored - 7B (3.8GB)\n"
printf "15. LLaVA - 7B (4.5GB)\n"
printf "16. Solar - 10.7B (6.1GB)\n"
}
# Function to select model based on user input
select_model() {
local choice="$1"
case $choice in
1) echo "llama3.1";;
2) echo "llama3.1:70b";;
3) echo "llama3.1:405b";;
4) echo "phi3";;
5) echo "phi3:medium";;
6) echo "gemma2:2b";;
7) echo "gemma2";;
8) echo "gemma2:27b";;
9) echo "mistral";;
10) echo "moondream";;
11) echo "neural-chat";;
12) echo "starling-lm";;
13) echo "codellama";;
14) echo "llama2-uncensored";;
15) echo "llava";;
16) echo "solar";;
*) echo "$choice";; # Treat any other input as a custom model name
esac
}
run_model() {
clear
display_models
printf "%b\n" "${GREEN}Installed Models${RC}"
installed_models=$(ollama list)
printf "%b\n" "${installed_models}"
printf "%b\n" "${YELLOW}Custom Models${RC}"
custom_models=$(ollama list | grep 'custom-model-prefix')
printf "%b\n" "${YELLOW}Please select a model to run:${RC}"
printf "%b\n" "${YELLOW}Enter the number corresponding to the model or enter the name of a custom model:${RC}"
read -r model_choice
model=$(select_model "$model_choice")
printf "%b\n" "${YELLOW}Running the model: $model...${RC}"
ollama run "$model"
}
create_model() {
clear
printf "%b\n" "${YELLOW}Let's create a new model in Ollama!${RC}"
display_models
# Prompt for base model
printf "%b\n" "${YELLOW}Enter the base model (e.g. '13' for codellama):${RC}"
read -r base_model
model=$(select_model "$base_model")
printf "%b\n" "${YELLOW}Running the model: $model...${RC}"
ollama pull "$model"
# Prompt for custom model name
printf "%b\n" "${YELLOW}Enter a name for the new customized model:${RC}"
read -r custom_model_name
# Prompt for temperature setting
printf "%b\n" "${YELLOW}Enter the desired temperature (higher values are more creative, lower values are more coherent, e.g., 1):${RC}"
read -r temperature
if [ -z "$temperature" ]; then
temperature=${temperature:-1}
fi
# Prompt for system message
printf "%b\n" "${YELLOW}Enter the system message for the model customization (e.g., 'You are Mario from Super Mario Bros. Answer as Mario, the assistant, only.'):${RC}"
read -r system_message
# Create the Modelfile
printf "%b\n" "${YELLOW}Creating the Modelfile...${RC}"
cat << EOF > Modelfile
FROM $base_model
# set the temperature to $temperature
PARAMETER temperature $temperature
# set the system message
SYSTEM """
$system_message
"""
EOF
# Create the model in Ollama
printf "%b\n" "${YELLOW}Creating the model in Ollama...${RC}"
ollama create "$custom_model_name" -f Modelfile
printf "%b\n" "${GREEN}Model '$custom_model_name' created successfully.${RC}"
}
# Function to remove a model
remove_model() {
clear
printf "%b\n" "${GREEN}Installed Models${RC}"
installed_models=$(ollama list)
printf "%b\n" "${installed_models}"
printf "%b\n" "${YELLOW}Please select a model to remove:${RC}"
printf "%b\n" "${YELLOW}Enter the name of the model you want to remove:${RC}"
read -r model_to_remove
if echo "$installed_models" | grep -q "$model_to_remove"; then
printf "%b\n" "${YELLOW}Removing the model: $model_to_remove...${RC}"
ollama rm "$model_to_remove"
printf "%b\n" "${GREEN}Model '$model_to_remove' has been removed.${RC}"
else
printf "%b\n" "${RED}Model '$model_to_remove' is not installed. Exiting.${RC}"
exit 1
fi
}
menu() {
while true; do
clear
printf "%b\n" "${YELLOW}Please select an option:${RC}"
printf "1) List all models\n"
printf "2) Show model information\n"
printf "3) Create a new model\n"
printf "4) Run a model\n"
printf "5) Remove a model\n"
printf "6) Exit\n"
printf "%b" "${YELLOW}Enter your choice (1-5): ${RC}"
read -r choice
case $choice in
1) list_models ;;
2) show_model_info ;;
3) create_model ;;
4) run_model ;;
5) remove_model;;
6) printf "%b\n" "${GREEN}Exiting...${RC}"; exit 0 ;;
*) printf "%b\n" "${RED}Invalid choice. Please try again.${RC}" ;;
esac
printf "%b\n" "${YELLOW}Press Enter to continue...${RC}"
read -r dummy
done
}
checkEnv
checkEscalationTool
installollama
menu

100
tabs/utils/power-profile.sh Normal file
View File

@ -0,0 +1,100 @@
#!/bin/sh -e
. ../common-script.sh
installAutoCpufreq() {
clear
printf "%b\n" "${YELLOW}Checking if auto-cpufreq is already installed...${RC}"
# Check if auto-cpufreq is already installed
if command_exists auto-cpufreq; then
printf "%b\n" "${GREEN}auto-cpufreq is already installed.${RC}"
else
printf "%b\n" "${YELLOW}Installing auto-cpufreq...${RC}"
# Install git if not already installed
if ! command_exists git; then
printf "%b\n" "${YELLOW}git not found. Installing git...${RC}"
case ${PACKAGER} in
pacman)
$ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm git
;;
*)
$ESCALATION_TOOL ${PACKAGER} install -y git
;;
esac
fi
# Clone the auto-cpufreq repository and run the installer
if [ ! -d "auto-cpufreq" ]; then
printf "%b\n" "${YELLOW}Cloning auto-cpufreq repository...${RC}"
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
fi
case ${PACKAGER} in
*)
cd auto-cpufreq
printf "%b\n" "${YELLOW}Running auto-cpufreq installer...${RC}"
$ESCALATION_TOOL ./auto-cpufreq-installer
;;
esac
cd ..
fi
}
configureAutoCpufreq() {
printf "%b\n" "${YELLOW}Configuring auto-cpufreq...${RC}"
if command_exists auto-cpufreq; then
# Check if the system has a battery to determine if it's a laptop
if [ -d /sys/class/power_supply/BAT0 ]; then
printf "%b\n" "${GREEN}System detected as laptop. Updating auto-cpufreq for laptop...${RC}"
$ESCALATION_TOOL auto-cpufreq --force powersave
else
printf "%b\n" "${GREEN}System detected as desktop. Updating auto-cpufreq for desktop...${RC}"
$ESCALATION_TOOL auto-cpufreq --force performance
fi
else
printf "%b\n" "${RED}auto-cpufreq is not installed, skipping configuration.${RC}"
fi
}
removeAutoCpufreqTweak() {
printf "%b\n" "${YELLOW}Removing auto-cpufreq tweak...${RC}"
if command_exists auto-cpufreq; then
printf "%b\n" "${YELLOW}Resetting auto-cpufreq configuration...${RC}"
$ESCALATION_TOOL auto-cpufreq --force reset
else
printf "%b\n" "${RED}auto-cpufreq is not installed, skipping removal.${RC}"
fi
}
apply_or_remove_auto_cpufreq() {
# Prompt user for action
printf "%b\n" "${YELLOW}Do you want to apply the auto-cpufreq tweak or remove it?${RC}"
printf "%b\n" "${YELLOW}1) Apply tweak${RC}"
printf "%b\n" "${YELLOW}2) Remove tweak${RC}"
printf "%b" "Enter your choice [1/2]: "
read -r choice
case $choice in
1)
configureAutoCpufreq
;;
2)
removeAutoCpufreqTweak
;;
*)
printf "%b\n" "${RED}Invalid choice. Exiting.${RC}"
exit 1
;;
esac
printf "%b\n" "${GREEN}auto-cpufreq setup complete.${RC}"
}
checkEnv
checkEscalationTool
installAutoCpufreq
apply_or_remove_auto_cpufreq

View File

@ -0,0 +1,278 @@
#!/bin/sh -e
# Load common script functions
. ../common-script.sh
#external services directory
SCRIPT_DIR="./services"
# Function to show the main menu
show_menu() {
clear
echo "============================"
echo " Service Management Menu"
echo "============================"
echo "1. View all services"
echo "2. View enabled services"
echo "3. View disabled services"
echo "4. Add a new service"
echo "5. Remove a service"
echo "6. Start a service"
echo "7. Stop a service"
echo "8. Enable a service"
echo "9. Disable a service"
echo "10. Create a service from external scripts"
echo "11. Exit"
echo "============================"
}
# Function to view all services
view_all_services() {
echo "Listing all services..."
$ESCALATION_TOOL systemctl list-units --type=service --all --no-legend | awk '{print $1}' | sed 's/\.service//' | more
}
# Function to view enabled services
view_enabled_services() {
echo "Listing enabled services..."
$ESCALATION_TOOL systemctl list-unit-files --type=service --state=enabled --no-legend | awk '{print $1}' | sed 's/\.service//' | more
}
# Function to view disabled services
view_disabled_services() {
echo "Listing disabled services..."
$ESCALATION_TOOL systemctl list-unit-files --type=service --state=disabled --no-legend | awk '{print $1}' | sed 's/\.service//' | more
}
# Function to view started services
view_started_services() {
echo "Listing started services:"
$ESCALATION_TOOL systemctl list-units --type=service --state=running --no-pager | head -n -6 | awk 'NR>1 {print $1}' | more
}
# Function to add a new service
add_service() {
while [ -z "$SERVICE_NAME" ]; do
echo "Enter the name of the new service (e.g., my_service):"
read -r SERVICE_NAME
if $ESCALATION_TOOL systemctl list-units --type=service --all --no-legend | grep -q "$SERVICE_NAME.service"; then
echo "Service already exists!"
SERVICE_NAME=""
fi
done
echo "Enter the description of the service:"
read -r SERVICE_DESCRIPTION
echo "Enter the command to execute the service (e.g., /usr/local/bin/my_service.sh):"
read -r EXEC_START
echo "Enter the user to run the service as (leave empty for default):"
read -r SERVICE_USER
echo "Enter the working directory for the service (leave empty for default):"
read -r WORKING_DIRECTORY
echo "Enter the restart policy (e.g., always, on-failure; leave empty for no restart):"
read -r RESTART_POLICY
# Create the service unit file
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
# Create the service file with conditionals for optional fields
{
echo "[Unit]"
echo "Description=$SERVICE_DESCRIPTION"
echo ""
echo "[Service]"
echo "ExecStart=$EXEC_START"
[ -n "$SERVICE_USER" ] && echo "User=$SERVICE_USER"
[ -n "$WORKING_DIRECTORY" ] && echo "WorkingDirectory=$WORKING_DIRECTORY"
[ -n "$RESTART_POLICY" ] && echo "Restart=$RESTART_POLICY"
echo ""
echo "[Install]"
echo "WantedBy=multi-user.target"
} | $ESCALATION_TOOL tee "$SERVICE_FILE" > /dev/null
# Set permissions and reload systemd
$ESCALATION_TOOL chmod 644 "$SERVICE_FILE"
$ESCALATION_TOOL systemctl daemon-reload
echo "Service $SERVICE_NAME has been created and is ready to be started."
# Optionally, enable and start the service
echo "Do you want to start and enable the service now? (y/n)"
read -r START_ENABLE
if [ "$START_ENABLE" = "y" ]; then
$ESCALATION_TOOL systemctl start "$SERVICE_NAME"
$ESCALATION_TOOL systemctl enable "$SERVICE_NAME"
echo "Service $SERVICE_NAME has been started and enabled."
else
echo "Service $SERVICE_NAME has been created but not started."
fi
}
# Function to remove a service
remove_service() {
echo "Enter the name of the service to remove (e.g., my_service):"
read -r SERVICE_NAME
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
if [ -f "$SERVICE_FILE" ]; then
echo "Stopping and disabling the service..."
$ESCALATION_TOOL systemctl stop "$SERVICE_NAME"
$ESCALATION_TOOL systemctl disable "$SERVICE_NAME"
echo "Removing the service file..."
$ESCALATION_TOOL rm -f "$SERVICE_FILE"
$ESCALATION_TOOL systemctl daemon-reload
echo "Service $SERVICE_NAME has been removed."
else
echo "Service $SERVICE_NAME does not exist."
fi
}
# Function to start a service
start_service() {
view_disabled_services
echo "Enter the name of the service to start (e.g., my_service):"
read -r SERVICE_NAME
if $ESCALATION_TOOL systemctl start "$SERVICE_NAME"; then
echo "Service $SERVICE_NAME has been started."
else
echo "Failed to start service: $SERVICE_NAME."
fi
}
# Function to stop a service
stop_service() {
view_started_services
echo "Enter the name of the service to stop (e.g., my_service):"
read -r SERVICE_NAME
if $ESCALATION_TOOL systemctl stop "$SERVICE_NAME"; then
echo "Service $SERVICE_NAME has been stopped."
else
echo "Failed to stop service: $SERVICE_NAME."
fi
}
# Function to enable a service
enable_service() {
view_disabled_services
echo "Enter the name of the service to enable (e.g., my_service):"
read -r SERVICE_NAME
if $ESCALATION_TOOL systemctl enable "$SERVICE_NAME"; then
echo "Service $SERVICE_NAME has been enabled."
else
echo "Failed to enable service: $SERVICE_NAME."
fi
}
# Function to enable a service
disable_service() {
view_enabled_services
echo "Enter the name of the service to disable (e.g., my_service):"
read -r SERVICE_NAME
if $ESCALATION_TOOL systemctl disable "$SERVICE_NAME"; then
echo "Service $SERVICE_NAME has been enabled."
else
echo "Failed to enable service: $SERVICE_NAME."
fi
}
# Function to create, start, and enable a service from an external service file
create_service_from_external() {
# List all .service files in the SCRIPT_DIR
echo "============================"
echo "Listing available service files"
echo "============================"
for FILE in "$SCRIPT_DIR"/*.service; do
echo "$(basename "$FILE")"
done
echo "Enter the filename (without the .service extension) of the service to create:"
read -r SERVICE_NAME
SERVICE_FILE="$SCRIPT_DIR/$SERVICE_NAME.service"
if [ ! -f "$SERVICE_FILE" ]; then
echo "Service file $SERVICE_FILE does not exist."
return
fi
echo "Enter the username to run the service as (leave empty for no specific user):"
read -r SERVICE_USER
# Create the systemd service file path
SYSTEMD_SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME.service"
# Add or update the User= line in the service file
if [ -n "$SERVICE_USER" ]; then
# Check if User= exists and append username if needed
if grep -q '^User=' "$SERVICE_FILE"; then
# Update the existing User= line with the new username
sed -i "s/^User=.*/User=$SERVICE_USER/" "$SERVICE_FILE"
else
# Add the User= line if it doesn't exist
sed -i '/^\[Service\]/a User='"$SERVICE_USER" "$SERVICE_FILE"
fi
fi
# Copy the modified service file to /etc/systemd/system/
$ESCALATION_TOOL cp "$SERVICE_FILE" "$SYSTEMD_SERVICE_FILE"
# Set permissions and reload systemd
$ESCALATION_TOOL chmod 644 "$SYSTEMD_SERVICE_FILE"
$ESCALATION_TOOL systemctl daemon-reload
echo "Service $SERVICE_NAME has been created and is ready to be started."
# Optionally, enable and start the service
echo "Do you want to start and enable the service now? (y/n)"
read -r START_ENABLE
if [ "$START_ENABLE" = "y" ]; then
$ESCALATION_TOOL systemctl start "$SERVICE_NAME"
$ESCALATION_TOOL systemctl enable "$SERVICE_NAME"
echo "Service $SERVICE_NAME has been started and enabled."
else
echo "Service $SERVICE_NAME has been created but not started."
fi
}
main() {
while true; do
show_menu
echo "Enter your choice:"
read -r CHOICE
case $CHOICE in
1) view_all_services ;;
2) view_enabled_services ;;
3) view_disabled_services ;;
4) add_service ;;
5) remove_service ;;
6) start_service ;;
7) stop_service ;;
8) enable_service ;;
9) disable_service ;;
10) create_service_from_external ;;
11) echo "Exiting..."; exit 0 ;;
*) echo "Invalid choice. Please try again." ;;
esac
echo "Press [Enter] to continue..."
read -r dummy
done
}
checkEnv
checkEscalationTool
main

View File

@ -0,0 +1,14 @@
/etc/systemd/system/
[Unit]
Description=i3lock on Lid Close
Before=sleep.target
[Service]
User=
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock
[Install]
WantedBy=sleep.target

View File

@ -12,6 +12,30 @@ script = "bluetooth-control.sh"
name = "Numlock on Startup"
script = "numlock.sh"
[[data]]
name = "Ollama"
script = "ollama.sh"
[[data]]
name = "Service Manager"
script = "service-control.sh"
[[data]]
name = "Auto Login"
script = "auto-login.sh"
[[data]]
name = "Bootable USB Creator"
script = "create-bootable-usb.sh"
[[data]]
name = "Auto Power Profiling"
script = "power-profile.sh"
[[data]]
name = "Timeshift Backup"
script = "timeshift.sh"
[[data]]
name = "Monitor Control"
@ -65,3 +89,8 @@ script = "monitor-control/scale_monitor.sh"
name = "Reset Scaling"
script = "monitor-control/reset_scaling.sh"
matches = true
[[data.entries]]
name = "Set Brightness"
script = "monitor-control/set_brightness.sh"
matches = true

162
tabs/utils/timeshift.sh Normal file
View File

@ -0,0 +1,162 @@
#!/bin/sh -e
. ../common-script.sh
# Function to install Timeshift
install_timeshift() {
clear
printf "%b\n" "${YELLOW}Checking if Timeshift is installed...${RC}"
if ! command_exists timeshift; then
case ${PACKAGER} in
pacman)
$ESCALATION_TOOL "${PACKAGER}" -S --noconfirm timeshift
;;
*)
$ESCALATION_TOOL "${PACKAGER}" install -y timeshift
;;
esac
else
echo "Timeshift is already installed."
fi
}
# Function to display the menu
display_menu() {
clear
printf "%b\n" "${CYAN}Timeshift CLI Automation${RC}"
printf "%b\n" "${CYAN}\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-"
printf "%b\n" "${CYAN}1) List Snapshots${RC}"
printf "%b\n" "${CYAN}2) List Devices${RC}"
printf "%b\n" "${CYAN}3) Create Snapshot${RC}"
printf "%b\n" "${CYAN}4) Restore Snapshot${RC}"
printf "%b\n" "${CYAN}5) Delete Snapshot${RC}"
printf "%b\n" "${CYAN}6) Delete All Snapshots${RC}"
printf "%b\n" "${CYAN}7) Exit${RC}"
printf "%b\n" "${CYAN}\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-"
}
# Function to list snapshots
list_snapshots() {
printf "%b\n" "${CYAN}Listing snapshots...${RC}"
$ESCALATION_TOOL timeshift --list-snapshots
}
# Function to list devices
list_devices() {
printf "%b\n" "${CYAN}Listing available devices...${RC}"
$ESCALATION_TOOL timeshift --list-devices
}
# Function to create a new snapshot
create_snapshot() {
printf "%b" "${CYAN}Enter a comment for the snapshot (optional): ${RC}"
read -r COMMENT
printf "%b" "${CYAN}Enter snapshot tag (O,B,H,D,W,M) (leave empty for no tag): ${RC}"
read -r TAG
if [ -z "$COMMENT" ] && [ -z "$TAG" ]; then
echo "Creating snapshot with no comment or tag..."
$ESCALATION_TOOL timeshift --create
elif [ -z "$TAG" ]; then
echo "Creating snapshot with no tag..."
$ESCALATION_TOOL timeshift --create --comments "$COMMENT"
else
echo "Creating snapshot with tag: $TAG..."
$ESCALATION_TOOL timeshift --create --comments "$COMMENT" --tags "$TAG"
fi
if [ $? -eq 0 ]; then
echo "Snapshot created successfully."
else
echo "Snapshot creation failed."
fi
}
# Function to restore a snapshot
restore_snapshot() {
list_snapshots
printf "%b" "${CYAN}Enter the snapshot name you want to restore: ${RC}"
read -r SNAPSHOT
printf "%b" "${CYAN}Enter the target device (e.g., /dev/sda1): ${RC}"
read -r TARGET_DEVICE
printf "%b" "${CYAN}Do you want to skip GRUB reinstall? (yes/no): ${RC}"
read -r SKIP_GRUB
if [ "$SKIP_GRUB" = "yes" ]; then
$ESCALATION_TOOL timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --skip-grub --yes
else
printf "%b" "${CYAN}Enter GRUB device (e.g., /dev/sda): ${RC}"
read -r GRUB_DEVICE
$ESCALATION_TOOL timeshift --restore --snapshot "$SNAPSHOT" --target-device "$TARGET_DEVICE" --grub-device "$GRUB_DEVICE" --yes
fi
if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}Snapshot restored successfully.${RC}"
else
printf "%b\n" "${RED}Snapshot restore failed.${RC}"
fi
}
# Function to delete a snapshot
delete_snapshot() {
list_snapshots
printf "%b" "${CYAN}Enter the snapshot name you want to delete: ${RC}"
read -r SNAPSHOT
printf "%b\n" "${YELLOW}Deleting snapshot $SNAPSHOT...${RC}"
$ESCALATION_TOOL timeshift --delete --snapshot "$SNAPSHOT" --yes
if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}Snapshot deleted successfully.${RC}"
else
printf "%b\n" "${RED}Snapshot deletion failed.${RC}"
fi
}
# Function to delete all snapshots
delete_all_snapshots() {
printf "%b\n" "${RED}WARNING: This will delete all snapshots!${RC}"
printf "%b" "${CYAN}Are you sure? (yes/no): ${RC}"
read -r CONFIRMATION
if [ "$CONFIRMATION" = "yes" ]; then
echo "Deleting all snapshots..."
$ESCALATION_TOOL timeshift --delete-all --yes
if [ $? -eq 0 ]; then
printf "%b\n" "${GREEN}All snapshots deleted successfully.${RC}"
else
printf "%b\n" "${RED}Failed to delete snapshots.${RC}"
fi
else
printf "%b\n" "${RED}Operation cancelled.${RC}"
fi
}
main_menu() {
while true; do
display_menu
printf "%b" "${CYAN}Select an option (1-7): ${RC}"
read -r OPTION
case $OPTION in
1) list_snapshots ;;
2) list_devices ;;
3) create_snapshot ;;
4) restore_snapshot ;;
5) delete_snapshot ;;
6) delete_all_snapshots ;;
7) printf "%b\n" "${GREEN}Exiting...${RC}"; exit 0 ;;
*) printf "%b\n" "${RED}Invalid option. Please try again.${RC}" ;;
esac
printf "%b" "${CYAN}Press Enter to continue...${RC}"
read -r dummy
done
}
checkEnv
checkEscalationTool
install_timeshift
main_menu

View File

@ -4,7 +4,7 @@
# Function to check if NetworkManager is installed
setupNetworkManager() {
echo "Install NetworkManger if not already installed..."
printf "%b\n" "${YELLOW}Installing NetworkManager...${RC}"
if ! command_exists nmcli; then
case ${PACKAGER} in
pacman)
@ -18,39 +18,26 @@ setupNetworkManager() {
;;
esac
else
echo "NetworkManager is already installed."
printf "%b\n" "${YELLOW}NetworkManager is already installed.${RC}"
fi
# Check if NetworkManager service is running
if ! systemctl is-active --quiet NetworkManager; then
echo "NetworkManager service is not running. Starting it now..."
printf "%b\n" "${YELLOW}NetworkManager service is not running. Starting it now...${RC}"
$ESCALATION_TOOL systemctl start NetworkManager
if systemctl is-active --quiet NetworkManager; then
echo "NetworkManager service started successfully."
printf "%b\n" "${GREEN}NetworkManager service started successfully.${RC}"
fi
fi
}
# Function to display colored text
colored_echo() {
local color=$1
local text=$2
case $color in
red) echo -e "\033[31m$text\033[0m" ;;
green) echo -e "\033[32m$text\033[0m" ;;
yellow) echo -e "\033[33m$text\033[0m" ;;
blue) echo -e "\033[34m$text\033[0m" ;;
*) echo "$text" ;;
esac
}
# Function to display the main menu
main_menu() {
while true; do
clear
colored_echo blue "WiFi Manager"
colored_echo blue "============"
printf "%b\n" "${YELLOW}WiFi Manager${RC}"
printf "%b\n" "${YELLOW}============${RC}"
echo "1. Turn WiFi On"
echo "2. Turn WiFi Off"
echo "3. Scan for WiFi networks"
@ -59,7 +46,7 @@ main_menu() {
echo "6. Remove a WiFi connection"
echo "0. Exit"
echo -n "Choose an option: "
read -e choice
read choice
case $choice in
1) wifi_on ;;
@ -69,7 +56,7 @@ main_menu() {
5) disconnect_network ;;
6) remove_network ;;
0) exit 0 ;;
*) colored_echo red "Invalid option. Please try again." ;;
*) printf "%b\n" "${RED}Invalid option. Please try again.${RC}" ;;
esac
done
}
@ -77,12 +64,12 @@ main_menu() {
# Function to scan for WiFi networks
scan_networks() {
clear
colored_echo yellow "Scanning for WiFi networks..."
printf "%b\n" "${YELLOW}Scanning for WiFi networks...${RC}"
networks=$(nmcli -t -f SSID,BSSID,SIGNAL dev wifi list | head -n 10)
if [ -z "$networks" ]; then
colored_echo red "No networks found."
printf "%b\n" "${RED}No networks found.${RC}"
else
colored_echo green "Top 10 Networks found:"
printf "%b\n" "${GREEN}Top 10 Networks found:${RC}"
echo "$networks" | sed 's/\\//g' | awk -F: '{printf("%d. SSID: %-25s \n", NR, $1)}'
fi
echo "Press any key to return to the main menu..."
@ -92,11 +79,11 @@ scan_networks() {
# Function to turn WiFi on
wifi_on() {
clear
colored_echo yellow "Turning WiFi on..."
printf "%b\n" "${YELLOW}Turning WiFi on...${RC}"
nmcli radio wifi on && {
colored_echo green "WiFi is now turned on."
printf "%b\n" "${GREEN}WiFi is now turned on.${RC}"
} || {
colored_echo red "Failed to turn on WiFi."
printf "%b\n" "${RED}Failed to turn on WiFi.${RC}"
}
echo "Press any key to return to the main menu..."
read -n 1
@ -105,11 +92,11 @@ wifi_on() {
# Function to turn WiFi off
wifi_off() {
clear
colored_echo yellow "Turning WiFi off..."
printf "%b\n" "${YELLOW}Turning WiFi off...${RC}"
nmcli radio wifi off && {
colored_echo green "WiFi is now turned off."
printf "%b\n" "${GREEN}WiFi is now turned off.${RC}"
} || {
colored_echo red "Failed to turn off WiFi."
printf "%b\n" "${RED}Failed to turn off WiFi.${RC}"
}
echo "Press any key to return to the main menu..."
read -n 1
@ -117,64 +104,65 @@ wifi_off() {
# Function to prompt for WiFi network selection
prompt_for_network() {
local action=$1
local prompt_msg=$2
local success_msg=$3
local failure_msg=$4
action=$1
prompt_msg=$2
success_msg=$3
failure_msg=$4
while true; do
clear
networks=$(nmcli -t -f SSID dev wifi list | head -n 10)
if [ -z "$networks" ]; then
colored_echo red "No networks available. Please scan for networks first."
printf "%b\n" "${RED}No networks available. Please scan for networks first.${RC}"
echo "Press any key to return to the main menu..."
read -n 1
return
fi
# Display networks with numbers
IFS=$'\n' read -r -a network_list <<<"$networks"
for i in "${!network_list[@]}"; do
ssid=$(echo "${network_list[$i]}" | awk -F: '{print $1}')
echo "$((i+1)). SSID: $ssid"
i=1
echo "$networks" | while IFS= read -r network; do
ssid=$(echo "$network" | awk -F: '{print $1}')
echo "$i. SSID: $ssid"
i=$((i + 1))
done
echo "0. Exit to main menu"
echo -n "$prompt_msg"
read -e choice
read choice
# Validate the choice
if [[ $choice =~ ^[0-9]+$ ]] && [ "$choice" -le "${#network_list[@]}" ] && [ "$choice" -gt 0 ]; then
network=${network_list[$((choice-1))]}
if echo "$choice" | grep -qE '^[0-9]+$' && [ "$choice" -le "$((i - 1))" ] && [ "$choice" -gt 0 ]; then
network=$(echo "$networks" | sed -n "${choice}p")
ssid=$(echo "$network" | awk -F: '{print $1}')
if [ "$action" == "connect" ]; then
if [ "$action" = "connect" ]; then
echo -n "Enter password for SSID $ssid: "
read -s password
echo
nmcli dev wifi connect "$ssid" password "$password" && {
colored_echo green "$success_msg"
printf "%b\n" "${GREEN}$success_msg${RC}"
break
} || {
colored_echo red "$failure_msg"
printf "%b\n" "${RED}$failure_msg${RC}"
}
elif [ "$action" == "disconnect" ]; then
elif [ "$action" = "disconnect" ]; then
nmcli connection down "$ssid" && {
colored_echo green "$success_msg"
printf "%b\n" "${GREEN}$success_msg${RC}"
break
} || {
colored_echo red "$failure_msg"
printf "%b\n" "${RED}$failure_msg${RC}"
}
elif [ "$action" == "remove" ]; then
elif [ "$action" = "remove" ]; then
nmcli connection delete "$ssid" && {
colored_echo green "$success_msg"
printf "%b\n" "${GREEN}$success_msg${RC}"
break
} || {
colored_echo red "$failure_msg"
printf "%b\n" "${RED}$failure_msg${RC}"
}
fi
elif [ "$choice" -eq 0 ]; then
return
else
colored_echo red "Invalid choice. Please try again."
printf "%b\n" "${RED}Invalid choice. Please try again.${RC}"
fi
done
echo "Press any key to return to the main menu..."

View File

@ -64,9 +64,7 @@ impl Float {
// Returns true if the floating window is finished.
pub fn handle_key_event(&mut self, key: &KeyEvent) -> bool {
match key.code {
KeyCode::Enter | KeyCode::Char('p') | KeyCode::Esc | KeyCode::Char('q')
if self.content.is_finished() =>
{
KeyCode::Enter | KeyCode::Char('p') | KeyCode::Esc if self.content.is_finished() => {
true
}
_ => self.content.handle_key_event(key),

View File

@ -14,7 +14,6 @@ use std::{
use crate::theme::Theme;
use clap::Parser;
use crossterm::{
cursor::RestorePosition,
event::{self, DisableMouseCapture, Event, KeyEventKind},
style::ResetColor,
terminal::{disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen},
@ -38,7 +37,7 @@ struct Args {
override_validation: bool,
}
fn main() -> std::io::Result<()> {
fn main() -> io::Result<()> {
let args = Args::parse();
let mut state = AppState::new(args.theme, args.override_validation);
@ -55,8 +54,8 @@ fn main() -> std::io::Result<()> {
terminal.backend_mut().execute(LeaveAlternateScreen)?;
terminal.backend_mut().execute(DisableMouseCapture)?;
terminal.backend_mut().execute(ResetColor)?;
terminal.backend_mut().execute(RestorePosition)?;
terminal.show_cursor()?;
Ok(())
}

View File

@ -6,7 +6,7 @@ use crate::{
running_command::RunningCommand,
theme::Theme,
};
use crossterm::event::{KeyCode, KeyEvent, KeyEventKind};
use crossterm::event::{KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
use ego_tree::NodeId;
use linutil_core::{Command, ListNode, Tab};
use ratatui::{
@ -185,6 +185,7 @@ impl AppState {
draw_shortcuts(self, frame, vertical[1]);
}
pub fn handle_key(&mut self, key: &KeyEvent) -> bool {
match &mut self.focus {
Focus::FloatingWindow(command) => {
@ -192,31 +193,43 @@ impl AppState {
self.focus = Focus::List;
}
}
Focus::Search => match self.filter.handle_key(key) {
SearchAction::Exit => self.exit_search(),
SearchAction::Update => self.update_items(),
_ => {}
},
_ if key.code == KeyCode::Char('q') => return false,
_ if key.code == KeyCode::Char('q')
|| key.code == KeyCode::Char('c')
&& key.modifiers.contains(KeyModifiers::CONTROL) =>
{
return false;
}
Focus::TabList => match key.code {
KeyCode::Enter | KeyCode::Char('l') | KeyCode::Right | KeyCode::Tab => {
self.focus = Focus::List
}
KeyCode::Char('j') | KeyCode::Down
if self.current_tab.selected().unwrap() + 1 < self.tabs.len() =>
{
self.current_tab.select_next();
self.refresh_tab();
}
KeyCode::Char('k') | KeyCode::Up => {
self.current_tab.select_previous();
self.refresh_tab();
}
KeyCode::Char('/') => self.enter_search(),
KeyCode::Char('t') => self.theme.next(),
KeyCode::Char('T') => self.theme.prev(),
_ => {}
},
Focus::List if key.kind != KeyEventKind::Release => match key.code {
KeyCode::Char('j') | KeyCode::Down => self.selection.select_next(),
KeyCode::Char('k') | KeyCode::Up => self.selection.select_previous(),
@ -235,10 +248,12 @@ impl AppState {
KeyCode::Char('T') => self.theme.prev(),
_ => {}
},
_ => {}
_ => (),
};
true
}
fn update_items(&mut self) {
self.filter.update_items(
&self.tabs,
@ -246,12 +261,14 @@ impl AppState {
*self.visit_stack.last().unwrap(),
);
}
/// Checks either the current tree node is the root node (can we go up the tree or no)
/// Returns `true` if we can't go up the tree (we are at the tree root)
/// else returns `false`
pub fn at_root(&self) -> bool {
self.visit_stack.len() == 1
}
fn enter_parent_directory(&mut self) {
self.visit_stack.pop();
self.selection.select(Some(0));