Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2
- """
- This script install dependencies to make polybar and another packages
- that are essential
- """
- import os
- import subprocess
- C_PATH = os.path.join(os.environ.get('HOME'), '.config')
- class ConfigEnvironment(object):
- def __init__(self):
- self._fn = 'config'
- self._i3 = os.path.join(C_PATH, 'i3')
- self._url = "https://slexy.org/raw/s2WPP7dZps?token=df3078431c32b4785d7c60f7a1edc27edfc8033fd49d8ea5c90e365d660b70c8&ts=1536847473"
- os.chdir(self._i3)
- self.write()
- def write(self):
- """
- Write the config file on i3 path
- self.write() -> None
- """
- print('Config environment wrote')
- os.system("wget \"{}\" -O {} -q".format(self._url, self._fn))
- class LaunchFile(object):
- def __init__(self):
- self._fn = 'launch.sh'
- self._polybar = os.path.join(C_PATH, 'polybar')
- self._url = "https://paste.fedoraproject.org/paste/tySdJNWuShuDJWjs8gMLnQ/raw"
- os.chdir(self._polybar)
- self.write()
- def write(self):
- """
- Write the launch.sh file on polybar path
- self.write() -> None
- """
- print('Launch to polybar config wrote')
- os.system("wget \"{}\" -O {} -q".format(self._url, self._fn))
- class PolybarConfig(object):
- def __init__(self):
- self._fn = 'config'
- self._polybar = os.path.join(C_PATH, 'polybar')
- self._url = "https://slexy.org/raw/s21drNCMVV?token=5bc42f5b73574be1c786a8cee6cd1208d2955886153f76a9d47d91289e130e45&ts=1536847438"
- os.chdir(self._polybar)
- self.write()
- def write(self):
- """
- Write the confi file on polybar path
- self.write() -> None
- """
- print('Polybar config wrote')
- os.system("wget \"{}\" -O {} -q".format(self._url, self._fn))
- class SpotifyFile(object):
- def __init__(self):
- self._fn = 'spotify.sh'
- self._polybar = os.path.join(C_PATH, 'polybar')
- self._url = "https://slexy.org/raw/s2106qJfcX?token=50756853c117e119dddabee9aa63f1933830e09290cad8b5f9928316823f057d&ts=1536847556"
- os.chdir(self._polybar)
- self.write()
- def write(self):
- """
- Write the confi file on polybar path
- self.write() -> None
- """
- print('Spotify wrote')
- os.system("wget \"{}\" -O {} -q".format(self._url, self._fn))
- class Packages(object):
- def __init__(self):
- self._fn = 'principal-packages'
- if not self._check_principal_packages():
- print('Installing packages...')
- self.install_principal_packages()
- def _check_principal_packages(self):
- """
- Check if principal packages are installed
- self._check_principal_packages() -> Boolean value
- """
- with open('principal-packages', 'r') as f:
- packages = f.readlines()
- for package in packages:
- try:
- r = subprocess.check_output('dpkg -l | grep {}'.format(package.strip()), shell=True)
- return True
- except subprocess.CalledProcessError:
- return False
- def install_principal_packages(self):
- """
- Install packages :p
- self.install_principal_packages() -> None
- """
- with open('principal-packages', 'r') as f:
- packages = f.readlines()
- for package in packages:
- os.system('apt install -y {}'.format(package))
- if __name__ == '__main__':
- if os.getuid() != 1000:
- packages = Packages()
- PolybarConfig()
- SpotifyFile()
- LaunchFile()
- ConfigEnvironment()
- else:
- print("Run as sudo user")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement