Skip to content

Commit

Permalink
Streamlined installation process and fixed python runtime error
Browse files Browse the repository at this point in the history
  • Loading branch information
Corewala committed Nov 17, 2020
1 parent 270b0d0 commit 6aed539
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 28 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ sh build.sh
```

## Install or uninstall Smother
This software comes with install and uninstall scripts.
- Run `install.sh` to install
- Run `uninstall.sh` to uninstall
Run `install.sh` to access installation options.

## Notice
This software uses ufw, and will screw up your config. Do not use this software if you use ufw for anything else.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mkdir build
nuitka3 ./smother.py -o build/smother
nuitka3 ./smother.py -o build/smother &> /dev/null
echo '[Desktop Entry]
Type=Application
Name=Smother
Expand Down
46 changes: 42 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
sudo systemctl enable ufw &> /dev/null
sudo ufw enable &> /dev/null
cp build/smother ~/.local/bin
cp build/Smother.desktop ~/.local/share/applications
printf "Please select\n";
printf "1: Install or update Smother\n";
printf "2: Uninstall Smother\n";
printf "> ";

#Repeat only if the user hasn't entered an integer...
while ! [[ $selection =~ ^[1-2]+$ ]];
do
read selection;
#if the entered value was not an integer, show this
if ! [[ $selection =~ ^[1-2]+$ ]]; then
sleep 1;
printf "$(tput setaf 9)Please try again$(tput sgr0)\n";
printf "1: Install or update Smother\n";
printf "2: Uninstall Smother\n";
printf "> ";
fi
done

case $selection in
1)
sudo systemctl enable ufw &> /dev/null
sudo ufw enable &> /dev/null
cp build/smother ~/.local/bin
cp build/Smother.desktop ~/.local/share/applications
;;

2)
#Uninstall
sudo /usr/bin/ufw --force reset &> /dev/null
sudo /usr/bin/ufw enable &> /dev/null
sudo /usr/bin/rm /etc/ufw/*.rules.* &> /dev/null
sudo /usr/bin/ufw default deny incoming &> /dev/null
sudo /usr/bin/ufw default allow outgoing &> /dev/null
rm ~/.local/bin/smother
rm ~/.local/share/applications/Smother.desktop
;;

*)
printf "[$(tput setaf 12 && tput blink)INFO$(tput sgr0)] $(tput setaf 12)Exiting script$(tput sgr0)\n";
;;
esac
26 changes: 13 additions & 13 deletions smother.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import gi
import os
from gi.repository import gtk
from gi.repository import Gtk
gi.require_version('Gtk', '3.0')


class Smother(gtk.Window):
class Smother(Gtk.Window):

def __init__(self):
gtk.Window.__init__(self, title ="Smother")
gtk.Window.set_resizable(self, False);
Gtk.Window.__init__(self, title ="Smother")
Gtk.Window.set_resizable(self, False);
self.set_border_width(10)

vbox = gtk.Box(orientation = gtk.Orientation.VERTICAL, spacing = 20)
vbox = Gtk.Box(orientation = Gtk.Orientation.VERTICAL, spacing = 20)
self.add(vbox)

stack = gtk.Stack()
stack.set_transition_type(gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
stack = Gtk.Stack()
stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
stack.set_transition_duration(1000)

self.killbutton = gtk.Button(label ="Enable Killswitch")
self.killbutton = Gtk.Button(label ="Enable Killswitch")
self.killbutton.connect("clicked", self.on_enable_clicked)
stack.add_titled(self.killbutton, "kill", "Enable")

self.unkillbutton = gtk.Button(label ="Disable Killswitch")
self.unkillbutton = Gtk.Button(label ="Disable Killswitch")
self.unkillbutton.connect("clicked", self.on_disable_clicked)
stack.add_titled(self.unkillbutton, "unkill", "Disable")

stack_switcher = gtk.StackSwitcher()
stack_switcher = Gtk.StackSwitcher()
stack_switcher.set_stack(stack)
vbox.pack_start(stack_switcher, True, True, 0)
vbox.pack_start(stack, True, True, 0)
Expand All @@ -37,6 +37,6 @@ def on_disable_clicked(self, widget):
os.system("gksu bash -c \'/usr/bin/ufw --force reset \n /usr/bin/ufw enable \n /usr/bin/rm /etc/ufw/*.rules.* \n /usr/bin/ufw default deny incoming \n /usr/bin/ufw default allow outgoing\'")

win = Smother()
win.connect("destroy", gtk.main_quit)
win.connect("destroy", Gtk.main_quit)
win.show_all()
gtk.main()
Gtk.main()
7 changes: 0 additions & 7 deletions uninstall.sh

This file was deleted.

0 comments on commit 6aed539

Please sign in to comment.