diff --git a/gajim/gajim.py b/gajim/gajim.py
index 27e827cf4d6e862897265d513a89553339fc79b5..c0915ae0b6eb4df05dd7e9944bb41db4236acec2 100644
--- a/gajim/gajim.py
+++ b/gajim/gajim.py
@@ -437,6 +437,14 @@ class GajimApplication(Gtk.Application):
                 self.lookup_action(account + action_name).set_enabled(True)
 
 
-if __name__ == '__main__':
+def main():
+    if sys.platform != 'win32':
+        if os.geteuid() == 0:
+            sys.exit("You must not launch gajim as root, it is insecure.")
+
     appli = GajimApplication()
     appli.run(sys.argv)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/gajim/gajim_remote.py b/gajim/gajim_remote.py
index dbe3bb6b92340745d9c603d7019b558e8e612a03..53bf9f9050245fc1184633705966f9994e271155 100644
--- a/gajim/gajim_remote.py
+++ b/gajim/gajim_remote.py
@@ -27,6 +27,7 @@
 
 # gajim-remote help will show you the D-BUS API of Gajim
 
+import os
 import sys
 import locale
 import urllib
@@ -500,5 +501,13 @@ class GajimRemote:
             raise exceptions.ServiceNotAvailable
         return None
 
-if __name__ == '__main__':
+
+def main():
+    if os.geteuid() == 0:
+        sys.exit("You must not launch gajim as root, it is insecure.")
+
     GajimRemote()
+
+
+if __name__ == '__main__':
+    main()
diff --git a/gajim/history_manager.py b/gajim/history_manager.py
index 72f1bc08b7ff516157a7605be5e2b036fc93e24e..f53073788ab9226d8c14fb4c70c88a7906efdeac 100644
--- a/gajim/history_manager.py
+++ b/gajim/history_manager.py
@@ -30,7 +30,6 @@
 
 import os
 import sys
-import signal
 import gi
 gi.require_version('Gtk', '3.0')
 from gi.repository import Gtk
@@ -668,7 +667,15 @@ class HistoryManager:
         path = self.logs_liststore.get_path(iter_)
         self.logs_listview.scroll_to_cell(path)
 
-if __name__ == '__main__':
-    signal.signal(signal.SIGINT, signal.SIG_DFL)  # ^C exits the application
+
+def main():
+    if sys.platform != 'win32':
+        if os.geteuid() == 0:
+            sys.exit("You must not launch gajim as root, it is insecure.")
+
     HistoryManager()
     Gtk.main()
+
+
+if __name__ == '__main__':
+    main()
diff --git a/launch.py b/launch.py
index 68e4680e00adab42c41e9767e015c9345e8ef4eb..20e03a7b71c8ae1c654d9f07e57e02d5f6b9740e 100755
--- a/launch.py
+++ b/launch.py
@@ -1,12 +1,4 @@
 #!/usr/bin/env python3
 
-import os
-import sys
-
-if sys.platform != 'win32':
-    if os.geteuid() == 0:
-        sys.exit("You must not launch gajim as root, it is insecure.")
-
-import gajim.gajim as g
-
-g.GajimApplication().run(sys.argv)
+from gajim import gajim
+gajim.main()
diff --git a/scripts/gajim b/scripts/gajim
deleted file mode 100644
index 47f28512e41e629ff9a3da7afc957839be1abcbd..0000000000000000000000000000000000000000
--- a/scripts/gajim
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env python3
-##
-## Copyright (C) 2005 Yann Le Boulanger <asterix AT lagaule.org>
-## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com>
-##                    Stefan Bethge <stefan AT lanpartei.de>
-## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
-##
-## This file is part of Gajim.
-##
-## Gajim 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; version 3 only.
-##
-## Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
-##
-
-import os
-import sys
-
-if sys.platform != 'win32':
-    if os.geteuid() == 0:
-        sys.exit("You must not launch gajim as root, it is insecure.")
-
-import gajim.gajim as g
-
-g.GajimApplication().run(sys.argv)
diff --git a/scripts/gajim-history-manager b/scripts/gajim-history-manager
deleted file mode 100644
index cbf3cb4fcc11ed300c830134d7151e63d9bcc8e4..0000000000000000000000000000000000000000
--- a/scripts/gajim-history-manager
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/usr/bin/env python3
-##
-## Copyright (C) 2005 Yann Le Boulanger <asterix AT lagaule.org>
-## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com>
-##                    Stefan Bethge <stefan AT lanpartei.de>
-## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
-##
-## This file is part of Gajim.
-##
-## Gajim 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; version 3 only.
-##
-## Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
-##
-
-import os
-import sys
-
-if sys.platform != 'win32':
-    if os.geteuid() == 0:
-        sys.exit("You must not launch gajim as root, it is insecure.")
-
-import gi
-gi.require_version('Gtk', '3.0')
-from gi.repository import Gtk
-import gajim.history_manager as g
-
-g.HistoryManager()
-Gtk.main()
diff --git a/scripts/gajim-remote b/scripts/gajim-remote
deleted file mode 100644
index 6245968782babc3b1974feb74513a968a1dbdb58..0000000000000000000000000000000000000000
--- a/scripts/gajim-remote
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/env python3
-##
-## Copyright (C) 2005 Yann Le Boulanger <asterix AT lagaule.org>
-## Copyright (C) 2006 Dimitur Kirov <dkirov AT gmail.com>
-##                    Stefan Bethge <stefan AT lanpartei.de>
-## Copyright (C) 2008 Jonathan Schleifer <js-gajim AT webkeks.org>
-##
-## This file is part of Gajim.
-##
-## Gajim 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; version 3 only.
-##
-## Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
-##
-
-import os
-import sys
-
-if os.geteuid() == 0:
-    sys.exit("You must not launch gajim as root, it is insecure.")
-
-import gajim.gajim_remote as g
-
-g.GajimRemote()
diff --git a/setup.py b/setup.py
index b0ef1dcc1e56c00e2e9dbb116c0126528cc2b88c..7a469624a866f00ec1060e4e250da527feca9938 100644
--- a/setup.py
+++ b/setup.py
@@ -261,10 +261,15 @@ setup(
         'test_nogui': test_nogui,
         'update_po': update_po,
     },
-    scripts=[
-        'scripts/gajim',
-        'scripts/gajim-history-manager',
-        'scripts/gajim-remote'],
+    entry_points={
+        'console_scripts': [
+            'gajim-remote = gajim.gajim_remote:main',
+        ],
+        'gui_scripts': [
+            'gajim = gajim.gajim:main',
+            'gajim-history-manager = gajim.history_manager:main',
+        ]
+    },
     packages=find_packages(exclude=["gajim.dev", "test*"]),
     package_data={'gajim': package_data},
     data_files=data_files,