-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·170 lines (151 loc) · 6.71 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·170 lines (151 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/bash
# Path of Trading - PoE2 Price Checker Installer
# Copyright (C) 2026 brendancohan
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
echo "======================================"
echo " Path of Trading v1.0 - Installer"
echo "======================================"
# 1. Dependency Checks
MISSING_DEPS=0
for cmd in python3 pip wl-paste ydotool quickshell; do
if ! command -v $cmd &> /dev/null; then
echo "❌ Missing dependency: $cmd"
MISSING_DEPS=1
else
echo "✅ Found: $cmd"
fi
done
if [ $MISSING_DEPS -eq 1 ]; then
echo ""
echo "Please install the missing dependencies before continuing."
echo "For example, on Arch Linux:"
echo " sudo pacman -S python python-pip wl-clipboard ydotool"
echo " yay -S quickshell-git"
exit 1
fi
echo ""
echo "⚙️ Setting up installation directory..."
INSTALL_DIR="$HOME/.local/share/pathoftrading-v1.0"
mkdir -p "$INSTALL_DIR"
# Copy files
echo "📂 Copying files to $INSTALL_DIR..."
cp backend.py "$INSTALL_DIR/"
cp PathofTrading.qml "$INSTALL_DIR/"
cp run_pricecheck.sh "$INSTALL_DIR/"
cp requirements.txt "$INSTALL_DIR/"
chmod +x "$INSTALL_DIR/run_pricecheck.sh"
echo "🐍 Creating Python virtual environment..."
cd "$INSTALL_DIR"
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt --quiet
deactivate
echo "🔗 Creating global symlink..."
mkdir -p "$HOME/.local/bin"
ln -sf "$INSTALL_DIR/run_pricecheck.sh" "$HOME/.local/bin/pathoftrading"
# Warn user if ydotool is not running/owned
YDOTOOL_SOCK="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/.ydotool_socket"
if [ ! -S "$YDOTOOL_SOCK" ]; then
echo "⚠️ ydotool socket not found at $YDOTOOL_SOCK."
echo " Ensure 'ydotoold' is running as a user service for the macro to work."
echo " You can add this to your startup config:"
echo " ydotoold --socket-path=\$XDG_RUNTIME_DIR/.ydotool_socket --socket-own=\$(id -u):\$(id -g)"
fi
echo ""
echo "✅ Installation Complete!"
echo "--------------------------------------"
echo "Would you like to automatically map a hotkey to your Window Manager?"
echo "1) Hyprland"
echo "2) Sway"
echo "3) Skip (I will map it manually, or I use KDE/GNOME/etc.)"
read -p "Select an option [1-3]: " wm_choice
case $wm_choice in
1)
echo ""
echo "Enter your desired Hyprland keybind (Default: CTRL_ALT, D)"
echo "(Note: You must literally type out the key names, e.g., 'SUPER, D'. Do NOT physically press the combination.)"
read -p "> " raw_bind
custom_bind=${raw_bind:-"CTRL_ALT, D"}
# Sanitize input to remove weird terminal control characters if the user hit a macro by mistake
custom_bind=$(echo "$custom_bind" | tr -cd '[:print:]')
if [ -z "$custom_bind" ] && [ -n "$raw_bind" ]; then
echo "⚠️ Invalid input detected (likely a physical keypress instead of typed text)."
echo "✅ Falling back to default: CTRL_ALT, D"
custom_bind="CTRL_ALT, D"
elif [ -n "$raw_bind" ]; then
echo "✅ Using custom keybind: $custom_bind"
else
echo "✅ Using default keybind: CTRL_ALT, D"
fi
HYPR_CONF="$HOME/.config/hypr/hyprland.conf"
KEY_CONF="$HOME/.config/hypr/keybindings.conf"
KEY_CONF_ALT="$HOME/.config/hypr/config/keybindings.conf"
if [ -f "$KEY_CONF_ALT" ]; then
echo -e "\n# Path of Trading\nbindr = $custom_bind, exec, $HOME/.local/bin/pathoftrading" >> "$KEY_CONF_ALT"
echo "✅ Added hotkey to $KEY_CONF_ALT"
elif [ -f "$KEY_CONF" ]; then
echo -e "\n# Path of Trading\nbindr = $custom_bind, exec, $HOME/.local/bin/pathoftrading" >> "$KEY_CONF"
echo "✅ Added hotkey to $KEY_CONF"
elif [ -f "$HYPR_CONF" ]; then
echo -e "\n# Path of Trading\nbindr = $custom_bind, exec, $HOME/.local/bin/pathoftrading" >> "$HYPR_CONF"
echo "✅ Added hotkey to $HYPR_CONF"
else
echo "⚠️ Could not find Hyprland config files. Please add manually:"
echo "bindr = $custom_bind, exec, $HOME/.local/bin/pathoftrading"
fi
if command -v hyprctl &> /dev/null; then
echo "🔄 Reloading Hyprland configuration..."
hyprctl reload &> /dev/null
echo "✅ Hyprland reloaded!"
fi
;;
2)
echo ""
echo "Enter your desired Sway keybind (Default: Mod1+Ctrl+d)"
echo "(Note: You must literally type out the key names, e.g., 'Mod4+d'. Do NOT physically press the combination.)"
read -p "> " raw_bind
custom_bind=${raw_bind:-"Mod1+Ctrl+d"}
# Sanitize input to remove weird terminal control characters
custom_bind=$(echo "$custom_bind" | tr -cd '[:print:]')
if [ -z "$custom_bind" ] && [ -n "$raw_bind" ]; then
echo "⚠️ Invalid input detected (likely a physical keypress instead of typed text)."
echo "✅ Falling back to default: Mod1+Ctrl+d"
custom_bind="Mod1+Ctrl+d"
elif [ -n "$raw_bind" ]; then
echo "✅ Using custom keybind: $custom_bind"
else
echo "✅ Using default keybind: Mod1+Ctrl+d"
fi
SWAY_CONF="$HOME/.config/sway/config"
if [ -f "$SWAY_CONF" ]; then
echo -e "\n# Path of Trading\nbindsym --release $custom_bind exec $HOME/.local/bin/pathoftrading" >> "$SWAY_CONF"
echo "✅ Added hotkey to $SWAY_CONF"
else
echo "⚠️ Could not find Sway config. Please add manually:"
echo "bindsym --release $custom_bind exec $HOME/.local/bin/pathoftrading"
fi
if command -v swaymsg &> /dev/null; then
echo "🔄 Reloading Sway configuration..."
swaymsg reload &> /dev/null
echo "✅ Sway reloaded!"
fi
;;
*)
echo "Skipping automatic hotkey mapping."
echo "To use Path of Trading, bind the 'pathoftrading' command to a hotkey."
echo "Example for KDE/GNOME: Set 'pathoftrading' as the action for a Custom Shortcut."
;;
esac
echo "--------------------------------------"