Move install to post-install command

This commit is contained in:
Rico Tiongson 2019-03-02 19:17:10 +08:00
parent b097123884
commit de98f3a982
2 changed files with 32 additions and 28 deletions

View File

@ -5,10 +5,10 @@ Comfortable, seamless, and fast 3-finger (and 4-finger) touchpad swipe gestures
## Installation ## Installation
1. Install git, libinput, and g++ 1. Install Python3, libinput, and g++
```bash ```bash
sudo apt-get install git libinput-tools libxdo-dev g++ sudo apt-get install git python3-dev libinput-tools libxdo-dev
``` ```
2. Clone this repository 2. Clone this repository

View File

@ -81,38 +81,42 @@ try:
# include program to sources so it will be removed on uninstall # include program to sources so it will be removed on uninstall
) )
# create directories if they don't exist yet class Install(install):
if 'install' in sys.argv: def run(self):
os.path.exists(os.path.dirname(PROGRAM)) or os.makedirs(os.path.dirname(PROGRAM)) # perform original run command
os.path.exists(os.path.dirname(CONFIG)) or os.makedirs(os.path.dirname(CONFIG)) install.run(self)
# copy any of the old config files # create program/config directories
conf_files = [path for path in conf_paths if os.path.exists(path) and os.path.isfile(path)] os.path.exists(os.path.dirname(PROGRAM)) or os.makedirs(os.path.dirname(PROGRAM))
print('using configuration file at', conf_files[-1]) os.path.exists(os.path.dirname(CONFIG)) or os.makedirs(os.path.dirname(CONFIG))
if conf_files[-1] != CONFIG: # copy any of the old config files
# new installation or upgrading from old version, copy to new location conf_files = [path for path in conf_paths if os.path.exists(path) and os.path.isfile(path)]
copyfile(conf_files[-1], CONFIG) print('using configuration file at', conf_files[-1])
if conf_files[-1] == os.path.join(__DIR__, 'defaults.conf'): if conf_files[-1] != CONFIG:
# new installation - copy default configuration # new installation or upgrading from old version, copy to new location
print('copying configuration file to', CONFIG) copyfile(conf_files[-1], CONFIG)
else: if conf_files[-1] == os.path.join(__DIR__, 'defaults.conf'):
# upgrading - delete the deprecated config file (failsafe) # new installation - copy default configuration
try: print('copying configuration file to', CONFIG)
os.remove(conf_files[-1])
print('moving deprecated configuration file to', CONFIG)
except:
pass
# toggle autostart else:
os.chdir(os.getenv('HOME')) # upgrading - delete the deprecated config file (failsafe)
from comfortable_swipe import service try:
service.autostart() os.remove(conf_files[-1])
service.autostart() print('moving deprecated configuration file to', CONFIG)
except:
pass
print('\nTry running "{} start" to test'.format(NAME)) # toggle autostart
os.chdir(os.getenv('HOME'))
from comfortable_swipe import service
service.autostart()
service.autostart()
print('\nTry running "{} start" to test'.format(NAME))
finally: finally: