aboutsummaryrefslogtreecommitdiffstats
path: root/install.sh
blob: 5aca202b21a260c1e76597591898831b2512ff3b (plain) (blame)
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
#!/usr/bin/env bash

set -e

echo "🌤️  panahone weather applet installer"
echo "======================================"
echo ""

# checks
if [[ "$OSTYPE" != "linux-gnu"* ]]; then
    echo "❌ error: this app is designed for linux systems."
    exit 1
fi

if ! command -v python3 &>/dev/null; then
    echo "❌ error: python 3 is not installed."
    echo "please install python 3 first."
    exit 1
fi

PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2)
echo "✅ python 3 found: $(python3 --version)"

if ! python3 -c "import gi; gi.require_version('Gtk', '3.0')" 2>/dev/null; then
    echo "⚠️  gtk3 python bindings not found."
    echo ""
    echo "please install the required system packages:"
    echo ""
    echo "Arch:"
    echo "  sudo pacman -S python-gobject gtk3 libnotify"
    echo ""
    echo "Ubuntu/Debian:"
    echo "  sudo apt install python3-gi gir1.2-gtk-3.0 gir1.2-notify-0.7"
    echo ""
    echo "Fedora:"
    echo "  sudo dnf install python3-gobject gtk3 libnotify"
    echo ""
    read -p "press enter to continue after installing, or ctrl+c to exit..."
fi

# deps check
echo ""
echo "📦 installing python dependencies..."
cd src
pip3 install --user -r requirements.txt

if [ $? -eq 0 ]; then
    echo "✅ dependencies installed successfully"
else
    echo "❌ failed to install dependencies"
    exit 1
fi

# +x check
chmod +x panahone
echo "✅ made panahone executable"

# symbolic link (my personal preferred)
echo ""
read -p "do you want to create a symbolic link in ~/.local/bin? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
    mkdir -p ~/.local/bin
    ln -sf "$(pwd)/panahone" ~/.local/bin/panahone
    echo "✅ symbolic link created at ~/.local/bin/panahone"
    echo ""
    echo "⚠️  make sure ~/.local/bin is in your path:"
    echo "   add this to your ~/.bashrc or ~/.zshrc:"
    echo "   export PATH=\"\$HOME/.local/bin:\$PATH\""
fi

# .desktop file (i do not prefer this, personally but y'all go ahead!)
echo ""
read -p "do you want to create a desktop entry? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
    DESKTOP_FILE="$HOME/.local/share/applications/panahone.desktop"
    mkdir -p ~/.local/share/applications

    cat >"$DESKTOP_FILE" <<EOF
[Desktop Entry]
Name=Panahone
Comment=GTK3 Weather Applet
Exec=$(pwd)/panahone
Icon=weather-overcast
Terminal=false
Type=Application
Categories=Utility;
StartupNotify=false
EOF

    echo "✅ desktop entry created at $desktop_file"
fi

# xdg autostart
echo ""
read -p "do you want panahone to start automatically on login? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
    AUTOSTART_FILE="$HOME/.config/autostart/panahone.desktop"
    mkdir -p ~/.config/autostart

    cat >"$AUTOSTART_FILE" <<EOF
[Desktop Entry]
Name=Panahone
Comment=GTK3 Weather Applet
Exec=$(pwd)/panahone
Icon=weather-overcast
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true
EOF

    echo "✅ autostart entry created at $autostart_file"
fi

echo ""
echo "🎉 installation complete!"
echo ""
echo "you can now run panahone with:"
echo "  cd $(pwd) && ./panahone"
if [[ -L ~/.local/bin/panahone ]]; then
    echo "  or simply: panahone (if ~/.local/bin is in PATH)"
fi
echo ""
echo "for usage, run:"
echo "  ./panahone --help"
echo ""