Skip to content

Feat/service #202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,34 @@ curl -fsSL https://raw.githubusercontent.com/Axenide/Ax-Shell/main/install.sh |
- Zed Sans
- Tabler Icons

2. Download and run Ax-Shell:
2. Download:
```bash
git clone https://github.com/Axenide/Ax-Shell.git ~/.config/Ax-Shell
uwsm -- app python ~/.config/Ax-Shell/main.py > /dev/null 2>&1 & disown
ln -s ~/.config/Ax-Shell/run_shell.sh ~/.local/bin/ax-shell # make sure to have ~/.local/bin/ in your PATH
```
- If using uwsm, install te service:
```bash
install -Dm0644 /dev/stdin "$XDG_CONFIG_HOME/systemd/user/ax-shell.service" <<EOF
[Unit]
Description=A hackable shell for Hyprland, powered by Fabric.
After=graphical-session.target

[Service]
Type=exec
ExecStart=$HOME/.local/bin/ax-shell
Restart=on-failure
Slice=app-graphical.slice

[Install]
WantedBy=graphical-session.target
EOF
```
3. Run Ax-Shell:
```bash
# with service (for uwsm)
systemctl --user enable --now ax-shell
# with executable
ax-shell
```

<h2><sub><img src="https://raw.githubusercontent.com/Tarikul-Islam-Anik/Animated-Fluent-Emojis/master/Emojis/Travel%20and%20places/Rocket.png" alt="Rocket" width="25" height="25" /></sub> Roadmap</h2>
Expand Down
11 changes: 11 additions & 0 deletions config/hypr/restart_shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Get exit code
uwsm check is-active

if [[ $? == 0 ]]; then
systemctl --user restart ax-shell.service
else
killall ax-shell
$HOME/.local/bin/ax-shell
fi
2 changes: 2 additions & 0 deletions config/settings_constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import subprocess
from .data import (
APP_NAME,
APP_NAME_CAP,
Expand All @@ -10,6 +11,7 @@

SOURCE_STRING = f"""
# {APP_NAME_CAP}
{"exec-once = ax-shell" if not subprocess.run(["uwsm", "check", "is-active"]).returncode == 0 else ""}
source = ~/.config/{APP_NAME_CAP}/config/hypr/{APP_NAME}.conf
"""

Expand Down
5 changes: 2 additions & 3 deletions config/settings_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,15 @@ def generate_hyprconf() -> str:
is_vertical = bar_position in ["Left", "Right"]
animation_type = "slidefadevert" if is_vertical else "slidefade"

return f"""exec-once = uwsm-app $(python {home}/.config/{APP_NAME_CAP}/main.py)
exec = pgrep -x "hypridle" > /dev/null || uwsm app -- hypridle
return f"""exec = pgrep -x "hypridle" > /dev/null || uwsm app -- hypridle
exec = uwsm app -- swww-daemon
exec-once = wl-paste --type text --watch cliphist store
exec-once = wl-paste --type image --watch cliphist store

$fabricSend = fabric-cli exec {APP_NAME}
$axMessage = notify-send "Axenide" "FIRE IN THE HOLE‼️🗣️🔥🕳️" -i "{home}/.config/{APP_NAME_CAP}/assets/ax.png" -A "🗣️" -A "🔥" -A "🕳️" -a "Source Code"

bind = {bind_vars.get('prefix_restart', 'SUPER ALT')}, {bind_vars.get('suffix_restart', 'B')}, exec, killall {APP_NAME}; uwsm-app $(python {home}/.config/{APP_NAME_CAP}/main.py) # Reload {APP_NAME_CAP}
bind = {bind_vars.get('prefix_restart', 'SUPER ALT')}, {bind_vars.get('suffix_restart', 'B')}, exec, {home}/.config/{APP_NAME_CAP}/config/hypr/restart_shell.sh # Reload {APP_NAME_CAP}
bind = {bind_vars.get('prefix_axmsg', 'SUPER')}, {bind_vars.get('suffix_axmsg', 'A')}, exec, $axMessage # Message
bind = {bind_vars.get('prefix_dash', 'SUPER')}, {bind_vars.get('suffix_dash', 'D')}, exec, $fabricSend 'notch.open_notch("dashboard")' # Dashboard
bind = {bind_vars.get('prefix_bluetooth', 'SUPER')}, {bind_vars.get('suffix_bluetooth', 'B')}, exec, $fabricSend 'notch.open_notch("bluetooth")' # Bluetooth
Expand Down
171 changes: 102 additions & 69 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,80 +1,81 @@
#!/bin/bash

set -e # Exit immediately if a command fails
set -u # Treat unset variables as errors
set -o pipefail # Prevent errors in a pipeline from being masked
set -e # Exit immediately if a command fails
set -u # Treat unset variables as errors
set -o pipefail # Prevent errors in a pipeline from being masked

REPO_URL="https://github.com/Axenide/Ax-Shell.git"
INSTALL_DIR="$HOME/.config/Ax-Shell"
EXECUTABLE_PATH="$HOME/.local/bin/ax-shell"
PACKAGES=(
brightnessctl
cava
cliphist
fabric-cli-git
gnome-bluetooth-3.0
gobject-introspection
gpu-screen-recorder
hypridle
hyprlock
hyprpicker
hyprshot
hyprsunset
imagemagick
libnotify
matugen-bin
noto-fonts-emoji
nvtop
playerctl
python-fabric-git
python-gobject
python-ijson
python-numpy
python-pillow
python-psutil
python-pywayland
python-requests
python-setproctitle
python-toml
python-watchdog
swappy
swww-git
tesseract
tmux
ttf-nerd-fonts-symbols-mono
unzip
upower
uwsm
vte3
webp-pixbuf-loader
wl-clipboard
brightnessctl
cava
cliphist
fabric-cli-git
gnome-bluetooth-3.0
gobject-introspection
gpu-screen-recorder
hypridle
hyprlock
hyprpicker
hyprshot
hyprsunset
imagemagick
libnotify
matugen-bin
noto-fonts-emoji
nvtop
playerctl
python-fabric-git
python-gobject
python-ijson
python-numpy
python-pillow
python-psutil
python-pywayland
python-requests
python-setproctitle
python-toml
python-watchdog
swappy
swww-git
tesseract
tmux
ttf-nerd-fonts-symbols-mono
unzip
upower
uwsm
vte3
webp-pixbuf-loader
wl-clipboard
)

# Prevent running as root
if [ "$(id -u)" -eq 0 ]; then
echo "Please do not run this script as root."
exit 1
echo "Please do not run this script as root."
exit 1
fi

aur_helper="yay"

# Check if paru exists, otherwise use yay
if command -v paru &>/dev/null; then
aur_helper="paru"
aur_helper="paru"
elif ! command -v yay &>/dev/null; then
echo "Installing yay-bin..."
tmpdir=$(mktemp -d)
git clone --depth=1 https://aur.archlinux.org/yay-bin.git "$tmpdir/yay-bin"
(cd "$tmpdir/yay-bin" && makepkg -si --noconfirm)
rm -rf "$tmpdir"
echo "Installing yay-bin..."
tmpdir=$(mktemp -d)
git clone --depth=1 https://aur.archlinux.org/yay-bin.git "$tmpdir/yay-bin"
(cd "$tmpdir/yay-bin" && makepkg -si --noconfirm)
rm -rf "$tmpdir"
fi

# Clone or update the repository
if [ -d "$INSTALL_DIR" ]; then
echo "Updating Ax-Shell..."
git -C "$INSTALL_DIR" pull
echo "Updating Ax-Shell..."
git -C "$INSTALL_DIR" pull
else
echo "Cloning Ax-Shell..."
git clone --depth=1 "$REPO_URL" "$INSTALL_DIR"
echo "Cloning Ax-Shell..."
git clone --depth=1 "$REPO_URL" "$INSTALL_DIR"
fi

# Install required packages using the detected AUR helper (only if missing)
Expand All @@ -92,31 +93,63 @@ TEMP_ZIP="/tmp/zed-sans-1.2.0.zip"

# Check if fonts are already installed
if [ ! -d "$FONT_DIR" ]; then
echo "Downloading fonts from $FONT_URL..."
curl -L -o "$TEMP_ZIP" "$FONT_URL"
echo "Downloading fonts from $FONT_URL..."
curl -L -o "$TEMP_ZIP" "$FONT_URL"

echo "Extracting fonts to $FONT_DIR..."
mkdir -p "$FONT_DIR"
unzip -o "$TEMP_ZIP" -d "$FONT_DIR"
echo "Extracting fonts to $FONT_DIR..."
mkdir -p "$FONT_DIR"
unzip -o "$TEMP_ZIP" -d "$FONT_DIR"

echo "Cleaning up..."
rm "$TEMP_ZIP"
echo "Cleaning up..."
rm "$TEMP_ZIP"
else
echo "Fonts are already installed. Skipping download and extraction."
echo "Fonts are already installed. Skipping download and extraction."
fi

# Copy local fonts if not already present
if [ ! -d "$HOME/.fonts/tabler-icons" ]; then
echo "Copying local fonts to $HOME/.fonts/tabler-icons..."
mkdir -p "$HOME/.fonts/tabler-icons"
cp -r "$INSTALL_DIR/assets/fonts/"* "$HOME/.fonts"
echo "Copying local fonts to $HOME/.fonts/tabler-icons..."
mkdir -p "$HOME/.fonts/tabler-icons"
cp -r "$INSTALL_DIR/assets/fonts/"* "$HOME/.fonts"
else
echo "Local fonts are already installed. Skipping copy."
echo "Local fonts are already installed. Skipping copy."
fi

# Symlinks the executable to run the shell
if [ ! $(test $EXECUTABLE_PATH) ]; then
echo "Symlinking executable"
ln -s "$INSTALL_DIR/run_shell.sh" "$EXECUTABLE_PATH"
fi

# Installs service if uwsm is installed
if [ $(which uwm) ]; then
echo "Installing service"
install -Dm0644 /dev/stdin "$XDG_CONFIG_HOME/systemd/user/ax-shell.service" <<EOF
[Unit]
Description=A hackable shell for Hyprland, powered by Fabric.
After=graphical-session.target

[Service]
Type=exec
ExecStart=$HOME/.local/bin/ax-shell
Restart=on-failure
Slice=app-graphical.slice

[Install]
WantedBy=graphical-session.target
EOF
fi

python "$INSTALL_DIR/config/config.py"
echo "Starting Ax-Shell..."
killall ax-shell 2>/dev/null || true
uwsm app -- python "$INSTALL_DIR/main.py" > /dev/null 2>&1 & disown
uwsm check is-active
if [ $? ]; then
systemctl --user stop ax-shell.service
systemctl --user enable --now ax-shell.service
else
killall ax-shell 2>/dev/null || true
$EXECUTABLE_PATH >/dev/null 2>&1 &
disown
fi

echo "Installation complete."
29 changes: 28 additions & 1 deletion modules/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,34 @@ def on_update_clicked(self, _widget):
update_command = "curl -fsSL https://raw.githubusercontent.com/Axenide/Ax-Shell/main/install.sh | bash"
else:
# Ensure REPO_DIR is correctly defined at the top of the file.
update_command = f"git -C \"{REPO_DIR}\" pull && echo 'Reloading in 3...' && sleep 1 && echo '2...' && sleep 1 && echo '1...' && sleep 1 && killall {data.APP_NAME} && setsid python \"{REPO_DIR}main.py\""
update_command = f"""git -C \"{REPO_DIR}\" pull
if [ ! $(test $HOME/.local/bin/{data.APP_NAME}) ]; then
echo 'Symlinking executable'
ln -s \"{REPO_DIR}run_shell.sh\" \"$HOME/.local/bin/{data.APP_NAME}\"
fi
if [ $(which uwm) ]; then
install -Dm0644 /dev/stdin \"$XDG_CONFIG_HOME/systemd/user/{data.APP_NAME}.service\" <<EOF
[Unit]
Description=A hackable shell for Hyprland, powered by Fabric.
After=graphical-session.target

[Service]
Type=exec
ExecStart=$HOME/.local/bin/{data.APP_NAME}
Restart=on-failure
Slice=app-graphical.slice

[Install]
WantedBy=graphical-session.target
EOF
fi
echo 'Reloading in 3...' && sleep 1 && echo '2...' && sleep 1 && echo '1...' && sleep 1
uwsm check is-active
if [ $? ]; then
systemctl --user restart {data.APP_NAME}.service
else
killall {data.APP_NAME} && setsid python \"{REPO_DIR}main.py\"
fi"""


# Spawn the process asynchronously inside the terminal
Expand Down
4 changes: 4 additions & 0 deletions run_shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

python_path=$(which python) # Get python executable path
$python_path "$XDG_CONFIG_HOME/Ax-Shell/main.py"
8 changes: 5 additions & 3 deletions uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ echo "This will permanently delete Ax-Shell cache, configuration, and remove its
read -p "Are you sure you want to continue? [y/N] " confirm

if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
echo "Aborted."
exit 1
echo "Aborted."
exit 1
fi

rm -rf ~/.cache/ax-shell
rm -rf ~/.config/Ax-Shell
rm ~/.local/bin/ax-shell
rm ~/.config/systemd/user/ax-shell.service

conf_file=~/.config/hypr/hyprland.conf
tmp_file=$(mktemp)
Expand All @@ -26,6 +28,6 @@ BEGIN { found_comment=0 }
next
}
print
}' "$conf_file" > "$tmp_file" && mv "$tmp_file" "$conf_file"
}' "$conf_file" >"$tmp_file" && mv "$tmp_file" "$conf_file"

echo "Ax-Shell data and config removed successfully."