mirror of
https://github.com/nwg-piotr/nwg-shell.git
synced 2024-09-11 14:17:12 +03:00
commit
f65649ac3d
@ -1,43 +1,79 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
"""
|
||||
This script checks the installed nwg-shell package version, first installed shell version, and performed updates,
|
||||
recorded in the shell data file. If the shell needs an update, it sends a notification, and saves the lock file,
|
||||
to avoid consecutive runs -> notifications in the same sway session. The lock file will be then removed in `autostart`.
|
||||
|
||||
Project: https://github.com/nwg-piotr/nwg-shell
|
||||
Author's email: nwg.piotr@gmail.com
|
||||
Copyright (c) 2022 Piotr Miller
|
||||
License: MIT
|
||||
"""
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
from nwg_shell.__about__ import __version__
|
||||
|
||||
from nwg_shell.tools import load_json, save_json, is_newer
|
||||
from nwg_shell.tools import load_json, save_string, temp_dir, eprint
|
||||
|
||||
data_home = os.getenv('XDG_DATA_HOME') if os.getenv('XDG_DATA_HOME') else os.path.join(os.getenv("HOME"),
|
||||
".local/share")
|
||||
tmp_dir = temp_dir()
|
||||
|
||||
|
||||
def main():
|
||||
lock_file = os.path.join(tmp_dir, "nwg-shell-check-update.lock")
|
||||
if os.path.isfile(lock_file):
|
||||
# don't notify twice
|
||||
print("'{}' file found, terminating".format(lock_file))
|
||||
sys.exit(0)
|
||||
|
||||
# This file will be removed in autostart
|
||||
save_string(str("this is to avoid multiple nwg-shell update checks in the same sway session"), lock_file)
|
||||
|
||||
shell_data_file = os.path.join(data_home, "nwg-shell/data")
|
||||
|
||||
if not os.path.isfile(shell_data_file):
|
||||
eprint("'{}' file not found, can't check updates. Terminating.".format(shell_data_file))
|
||||
sys.exit(1)
|
||||
|
||||
shell_data = load_json(shell_data_file)
|
||||
if not shell_data:
|
||||
if not os.path.isdir(os.path.join(data_home, "nwg-shell/")):
|
||||
os.makedirs(os.path.join(data_home, "nwg-shell"))
|
||||
eprint("'{}' file corrupted, can't check updates. Terminating.".format(shell_data_file))
|
||||
sys.exit(1)
|
||||
|
||||
print("Shell data file not found, creating default.")
|
||||
shell_data = {"last-upgrade": "0.0.0"}
|
||||
save_json(shell_data, shell_data_file)
|
||||
# Shell versions that need to trigger update
|
||||
need_update = ["0.3.0"]
|
||||
|
||||
# Shell versions that need to trigger upgrade
|
||||
need_upgrade = ["0.2.0", "0.2.4", "0.2.5"]
|
||||
if __version__ > shell_data["installed-version"]:
|
||||
# If not just installed
|
||||
pending_updates = []
|
||||
for version in need_update:
|
||||
if version not in shell_data["updates"]:
|
||||
pending_updates.append(version)
|
||||
|
||||
if shell_data["last-upgrade"] and __version__:
|
||||
if is_newer(__version__, shell_data["last-upgrade"]) and __version__ in need_upgrade:
|
||||
print("Upgrade to {} available. Run 'nwg-shell-installer -u'.".format(__version__))
|
||||
if len(pending_updates) > 0:
|
||||
updates_desc = ", ".join(pending_updates)
|
||||
print("Update(s) to {} available.".format(", ".join(pending_updates)))
|
||||
# notification looks better if appears after a period of time since startup
|
||||
time.sleep(5)
|
||||
subprocess.Popen(
|
||||
'exec {}'.format("notify-send -i /usr/share/pixmaps/nwg-shell.svg 'nwg-shell v{} available' "
|
||||
"'Run \"nwg-shell-installer -u\" in terminal.'".format(__version__)), shell=True)
|
||||
# send notification with actions, wait for response
|
||||
output = subprocess.check_output(
|
||||
'exec {}'.format(
|
||||
"notify-send -i /usr/share/pixmaps/nwg-shell.svg 'nwg-shell update' "
|
||||
"'Update(s) to {} available!' --action=update=Update --action=later=Later --wait".format(
|
||||
updates_desc)), shell=True)
|
||||
|
||||
if output.strip().decode("utf-8") == "update":
|
||||
# run updater script
|
||||
subprocess.call('exec nwg-shell-updater', shell=True)
|
||||
else:
|
||||
print("No upgrade needed.")
|
||||
else:
|
||||
print("Couldn't check if upgrade needed.")
|
||||
print("Just installed.")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -1,9 +1,11 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
"""
|
||||
nwg-shell installer, to copy all the components' configs and style sheets to their locations,
|
||||
or to restore original files. Pass the `--all` argument on first run or none to select files interactively.
|
||||
Intended to work/tested with Arch Linux.
|
||||
Installer script to copy all the components' configs and style sheets to their locations, or to restore original files.
|
||||
Pass the `--all` argument to install/overwrite all, or use w/ no argument to restore selected files interactively.
|
||||
This script is primarily intended to work (and tested!) on fresh installed Arch Linux.
|
||||
See: https://github.com/nwg-piotr/nwg-shell/wiki
|
||||
|
||||
The package dependencies should pull all the packages needed for the nwg-shell to run.
|
||||
|
||||
Project: https://github.com/nwg-piotr/nwg-shell
|
||||
@ -15,13 +17,12 @@ License: MIT
|
||||
import argparse
|
||||
import datetime
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from shutil import copy, copy2, copytree
|
||||
from shutil import copy, copytree
|
||||
|
||||
from nwg_shell.__about__ import __version__
|
||||
|
||||
from nwg_shell.tools import load_json, save_json, load_text_file, save_list_to_text_file
|
||||
from nwg_shell.tools import load_json, save_json
|
||||
|
||||
dir_name = os.path.dirname(__file__)
|
||||
|
||||
@ -31,38 +32,23 @@ config_home = os.getenv('XDG_CONFIG_HOME') if os.getenv('XDG_CONFIG_HOME') else
|
||||
data_home = os.getenv('XDG_DATA_HOME') if os.getenv('XDG_DATA_HOME') else os.path.join(os.getenv("HOME"),
|
||||
".local/share")
|
||||
|
||||
shell_data = []
|
||||
shell_data = None
|
||||
shell_data_file = os.path.join(data_home, "nwg-shell/data")
|
||||
|
||||
|
||||
def is_command(cmd):
|
||||
cmd = cmd.split()[0] # strip arguments
|
||||
cmd = "command -v {}".format(cmd)
|
||||
try:
|
||||
is_cmd = subprocess.check_output(cmd, shell=True).decode("utf-8").strip()
|
||||
if is_cmd:
|
||||
return is_cmd
|
||||
|
||||
except subprocess.CalledProcessError:
|
||||
return ""
|
||||
|
||||
|
||||
def launch(cmd):
|
||||
print("Executing '{}'".format(cmd))
|
||||
subprocess.Popen('exec {}'.format(cmd), shell=True)
|
||||
|
||||
|
||||
def copy_from_skel(name, folder="config", skip_confirmation=False):
|
||||
a = input("Install/overwrite files in the '{}' directory? y/N ".format(name)) if not skip_confirmation else "Y"
|
||||
if a.strip().upper() != "Y":
|
||||
print("'{}' directory skipped".format(name))
|
||||
return
|
||||
src = os.path.join(dir_name, "skel/{}/".format(folder), name)
|
||||
if folder == "data":
|
||||
dst = os.path.join(data_home, name)
|
||||
else:
|
||||
dst = os.path.join(config_home, name)
|
||||
|
||||
a = input("Install/overwrite files in the '{}' directory? y/N ".format(dst)) if not skip_confirmation else "Y"
|
||||
if a.strip().upper() != "Y":
|
||||
print("'{}' directory skipped".format(dst))
|
||||
return
|
||||
|
||||
else:
|
||||
src = os.path.join(dir_name, "skel/{}/".format(folder), name)
|
||||
if folder == "data":
|
||||
dst = os.path.join(data_home, name)
|
||||
else:
|
||||
dst = os.path.join(config_home, name)
|
||||
print("Copying files to '{}'".format(dst), end=" ")
|
||||
try:
|
||||
copytree(src, dst, dirs_exist_ok=True)
|
||||
@ -71,45 +57,12 @@ def copy_from_skel(name, folder="config", skip_confirmation=False):
|
||||
print("Failure: {}".format(e), file=sys.stderr)
|
||||
|
||||
|
||||
def update_sway_config():
|
||||
# backup original file
|
||||
now = datetime.datetime.now()
|
||||
new_name = now.strftime("config-backup-%Y%m%d-%H%M%S")
|
||||
src = os.path.join(config_home, "sway/config")
|
||||
dst = os.path.join(config_home, "sway/{}".format(new_name))
|
||||
try:
|
||||
if os.path.isfile(src):
|
||||
copy(src, dst)
|
||||
print("Your old sway config file has been saved as '{}'".format(new_name))
|
||||
except Exception as e:
|
||||
print("Couldn't back up your old sway config: {}".format(e))
|
||||
|
||||
a = input("You are about to overwrite your sway config file. Proceed? y/N ")
|
||||
proceed = a.strip().upper() == "Y"
|
||||
|
||||
if proceed:
|
||||
src = os.path.join(dir_name, "skel/config/sway/config")
|
||||
dst = os.path.join(config_home, "sway/config")
|
||||
print("Copying '{}'".format(dst), end=" ")
|
||||
try:
|
||||
copy(src, dst)
|
||||
print("OK")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
else:
|
||||
print("Sway config file update skipped.")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-a",
|
||||
"--all",
|
||||
action="store_true",
|
||||
help="Install/overwrite all configs and styles w/o confirmation")
|
||||
parser.add_argument("-u",
|
||||
"--upgrade",
|
||||
action="store_true",
|
||||
help="Upgrade current nwg-shell install")
|
||||
parser.add_argument("-v",
|
||||
"--version",
|
||||
action="version",
|
||||
@ -117,254 +70,59 @@ def main():
|
||||
help="display version information")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Load own data file, initiate first if it doesn't exist
|
||||
if not os.path.isdir(os.path.join(data_home, "nwg-shell/")):
|
||||
copy_from_skel("nwg-shell", folder="data", skip_confirmation=True)
|
||||
print("\n*******************************************************************")
|
||||
print(" This script installs/overwrites configs and style sheets ")
|
||||
print(" for sway and nwg-shell components. ")
|
||||
print(" The only backup that will be made is the main sway config file. ")
|
||||
print(" This script should be used on a fresh Arch Linux installation. ")
|
||||
print(" If you're running it on your existing sway setup, ")
|
||||
print(" you're doing it at your own risk. ")
|
||||
print("*******************************************************************")
|
||||
|
||||
global shell_data
|
||||
if not os.path.isfile(shell_data_file):
|
||||
if not os.path.isdir(os.path.join(data_home, "nwg-shell")):
|
||||
os.makedirs(os.path.join(data_home, "nwg-shell"))
|
||||
shell_data = {"last-upgrade": __version__}
|
||||
save_json(shell_data, shell_data_file)
|
||||
|
||||
a = input("\nProceed? y/N ")
|
||||
if a.strip().upper() != "Y":
|
||||
print("Installation cancelled")
|
||||
sys.exit(0)
|
||||
else:
|
||||
shell_data = load_json(shell_data_file)
|
||||
if not os.path.isfile(shell_data_file):
|
||||
# It must be a new installation. We need to init and save the shell data file.
|
||||
if not os.path.isdir(os.path.join(data_home, "nwg-shell")):
|
||||
os.makedirs(os.path.join(data_home, "nwg-shell"))
|
||||
shell_data = {"installed-version": __version__, "updates": [__version__]}
|
||||
save_json(shell_data, shell_data_file)
|
||||
|
||||
# Upgrade
|
||||
if args.upgrade:
|
||||
print("--------------------------------------------------------------")
|
||||
print("| You are about to upgrade nwg-shell to v{}. |".format(__version__))
|
||||
print("| This will modify and/or replace your config files. |")
|
||||
print("| |")
|
||||
print("| If something goes wrong, run 'nwg-shell-installer -a' |")
|
||||
print("| or 'nwg-shell-installer' (interactive mode), |")
|
||||
print("| in order to install default configs. |")
|
||||
print("--------------------------------------------------------------")
|
||||
|
||||
a = input("\nProceed? y/N ")
|
||||
if a.strip().upper() != "Y":
|
||||
print("Installation cancelled")
|
||||
sys.exit(0)
|
||||
else:
|
||||
if __version__ == "0.2.0":
|
||||
print("\n[Updating panel presets]")
|
||||
for item in ["preset-0", "preset-1", "preset-2", "preset-3"]:
|
||||
src = os.path.join(config_home, "nwg-panel/{}".format(item))
|
||||
panel_config = load_json(src)
|
||||
changed = False
|
||||
for panel in panel_config:
|
||||
if "custom-items" in panel["controls-settings"]:
|
||||
for i in panel["controls-settings"]["custom-items"]:
|
||||
# replace lxappearance with nwg-look
|
||||
if "lxappearance" in i["cmd"]:
|
||||
print("replacing 'lxappearance' with 'nwg-look' in '{}'".format(item))
|
||||
i["name"] = "GTK settings"
|
||||
i["icon"] = "nwg-look"
|
||||
i["cmd"] = "nwg-look"
|
||||
changed = True
|
||||
|
||||
# replace wdisplays with nwg-displays
|
||||
if "wdisplays" in i["cmd"]:
|
||||
print("replacing 'wdisplays' with 'nwg-displays' in '{}'".format(item))
|
||||
i["name"] = "Displays"
|
||||
i["icon"] = "nwg-displays"
|
||||
i["cmd"] = "nwg-displays"
|
||||
changed = True
|
||||
|
||||
# update nwg-shell-config
|
||||
if "nwg-shell-config" in i["cmd"] and i["icon"] != "nwg-shell-config":
|
||||
print("updating 'nwg-shell-config' in '{}'".format(item))
|
||||
i["icon"] = "nwg-shell-config"
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
print("Saving '{}'".format(src))
|
||||
save_json(panel_config, src)
|
||||
|
||||
if not changed:
|
||||
print("No change needed.")
|
||||
|
||||
update_sway_config()
|
||||
|
||||
# Use nwg-look to apply default GTK settings if it has not been done yet
|
||||
if not os.path.isfile(os.path.join(data_home, "nwg-look/gsettings")):
|
||||
print("\nApplying default GTK settings. Run 'nwg-look' utility to set your preferences.")
|
||||
print("You'll find it in the 'Controls' menu as 'GTK settings'.")
|
||||
copy_from_skel("nwg-look", folder="data", skip_confirmation=True)
|
||||
launch("nwg-look -a")
|
||||
|
||||
elif __version__ == "0.2.4":
|
||||
print("--------------------------------------------------------------")
|
||||
print("| nwg-shell 0.2.4 simplifies some key bindings in the main |")
|
||||
print("| sway config file, and adds 2 buttons to panel presets. |")
|
||||
print("| Also some minor bugs in related css files have been fixed. |")
|
||||
print("| If you proceed with the upgrade, your sway config file, |")
|
||||
print("| panel presets and panel css style sheets will be |")
|
||||
print("| overwritten with new defaults. |")
|
||||
print("| Changes you made to panel presets 0-3 will be lost. |")
|
||||
print("| Your old sway config file will be backed up. |")
|
||||
print("| |")
|
||||
print("| You may also do it later with the `nwg-shell-installer` |")
|
||||
print("| or `nwg-shell-installer -a` command. |")
|
||||
print("--------------------------------------------------------------\n")
|
||||
|
||||
update_sway_config()
|
||||
|
||||
a = input("\nOverwrite nwg-panel config files? y/N ")
|
||||
proceed = a.strip().upper() == "Y"
|
||||
|
||||
if proceed:
|
||||
copy_from_skel("nwg-panel", folder="config", skip_confirmation=True)
|
||||
else:
|
||||
print("nwg-panel configs update cancelled.")
|
||||
|
||||
elif __version__ == "0.2.5":
|
||||
print("--------------------------------------------------------------")
|
||||
print("| nwg-shell 0.2.5 comes with own `nwg-autotiling` script, |")
|
||||
print("| that replaces the `autotiling` package. This is to avoid |")
|
||||
print("| adding the nwg-shell-specific stuff to the original script,|")
|
||||
print("| which is quite widely used outside the project. |")
|
||||
print("| |")
|
||||
print("| The `nwg-autotiling` script should be more stable here. |")
|
||||
print("| |")
|
||||
print("| The upgrade process will only replace `autotiling` |")
|
||||
print("| with `nwg-autotiling` in your `autostart` config file. |")
|
||||
print("| It should be 100% safe. |")
|
||||
print("--------------------------------------------------------------\n")
|
||||
|
||||
a = input("Proceed with `autostart` upgrade? y/N ")
|
||||
proceed = a.strip().upper() == "Y"
|
||||
|
||||
if proceed:
|
||||
autostart = os.path.join(config_home, "sway", "autostart")
|
||||
old = load_text_file(autostart).splitlines()
|
||||
new = []
|
||||
changed = False
|
||||
for line in old:
|
||||
if "autotiling" not in line:
|
||||
new.append(line)
|
||||
elif "nwg-autotiling" not in line:
|
||||
new.append("exec_always nwg-autotiling")
|
||||
print("`autotiling` replaced with nwg-autotiling\n")
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
save_list_to_text_file(new, autostart)
|
||||
else:
|
||||
print("No change needed.\n")
|
||||
|
||||
# Inform about no longer needed stuff
|
||||
# Packages
|
||||
for item in ["lxappearance", "wdisplays", "nwg-wrapper", "autotiling"]:
|
||||
if is_command(item):
|
||||
print("The '{}' package is no longer necessary, you may uninstall it now.".format(item))
|
||||
|
||||
# Scripts
|
||||
for item in ["import-gsettings", "sway-save-outputs"]:
|
||||
if is_command(item):
|
||||
c = is_command(item)
|
||||
if c:
|
||||
print("The '{}' script is no longer necessary, you may delete it now.".format(c))
|
||||
|
||||
# Save shell data file
|
||||
shell_data = {"last-upgrade": __version__}
|
||||
save_json(shell_data, shell_data_file)
|
||||
|
||||
print("\n--------------------------------------------------------------")
|
||||
print("| Restart sway for changes to take effect. |")
|
||||
print("--------------------------------------------------------------\n")
|
||||
|
||||
# Installation
|
||||
else:
|
||||
print("\n-------------------------------------------------------------------")
|
||||
print("| This script installs/overwrites configs and style sheets |")
|
||||
print("| for sway and nwg-shell components. |")
|
||||
print("| The only backup that will be made is the main sway config file. |")
|
||||
print("| This script should be used on a fresh Arch Linux installation. |")
|
||||
print("| If you're running it on your existing sway setup, |")
|
||||
print("| you're doing it at your own risk. |")
|
||||
print("| |")
|
||||
print("| See 'nwg-shell-installer -h' for other options. |")
|
||||
print("-------------------------------------------------------------------")
|
||||
a = input("\nProceed? y/N ")
|
||||
if a.strip().upper() != "Y":
|
||||
print("Installation cancelled")
|
||||
sys.exit(0)
|
||||
|
||||
a = input("Install helper scripts? Y/n ") if not args.all else "Y"
|
||||
if a.strip().upper() == "Y" or args.all:
|
||||
print("\n[Scripts installation]")
|
||||
paths = []
|
||||
bin_path = ""
|
||||
for path in os.getenv("PATH").split(":"):
|
||||
if path.startswith(os.getenv("HOME")) and os.path.exists(path) and path not in paths:
|
||||
paths.append(path)
|
||||
if len(paths) == 0:
|
||||
print("No directory in '{}' found on $PATH, dunno where to install scripts, sorry".format(
|
||||
os.getenv("HOME")))
|
||||
sys.exit(1)
|
||||
elif len(paths) == 1 or args.all:
|
||||
bin_path = paths[0]
|
||||
else:
|
||||
print("More then 1 possible path for scripts found:")
|
||||
for i in range(len(paths)):
|
||||
print(" {}) {}".format(i + 1, paths[i]))
|
||||
|
||||
while bin_path == "":
|
||||
i = input("Select folder to install scripts to: ")
|
||||
try:
|
||||
bin_path = paths[int(i) - 1]
|
||||
except:
|
||||
pass
|
||||
|
||||
src = os.path.join(dir_name, "skel/bin/")
|
||||
for file in os.listdir(src):
|
||||
print("Copying {}".format(os.path.join(bin_path, file)), end=" ")
|
||||
try:
|
||||
copy2(os.path.join(src, file), os.path.join(bin_path, file))
|
||||
print("OK")
|
||||
except Exception as e:
|
||||
print("Failure: {}".format(e), file=sys.stderr)
|
||||
|
||||
src = os.path.join(dir_name, "skel/azotebg")
|
||||
dst = os.path.join(os.getenv("HOME"), ".azotebg")
|
||||
print("Copying {}".format(dst), end=" ")
|
||||
try:
|
||||
copy2(src, dst)
|
||||
print("OK")
|
||||
except Exception as e:
|
||||
print("Failure: {}".format(e), file=sys.stderr)
|
||||
|
||||
a = input("Install configs, style sheets and initial data files? y/N ") if not args.all else "Y"
|
||||
if a.strip().upper() == "Y" or args.all:
|
||||
print("\n[Configs, styles and data installation]")
|
||||
|
||||
# Backup sway config file
|
||||
now = datetime.datetime.now()
|
||||
new_name = now.strftime("config-backup-%Y%m%d-%H%M%S")
|
||||
src = os.path.join(config_home, "sway/config")
|
||||
dst = os.path.join(config_home, "sway/{}".format(new_name))
|
||||
proceed = True
|
||||
try:
|
||||
if os.path.isfile(src):
|
||||
copy(src, dst)
|
||||
print("* Original sway config file copied to '{}'".format(new_name))
|
||||
except Exception as e:
|
||||
print("Error: {}".format(e))
|
||||
a = input("Proceed with installation? y/N ")
|
||||
proceed = a.strip().upper() == "Y"
|
||||
|
||||
if proceed:
|
||||
for item in ["sway", "nwg-panel", "nwg-wrapper", "nwg-drawer", "nwg-dock", "nwg-bar", "swaync"]:
|
||||
copy_from_skel(item, folder="config", skip_confirmation=args.all)
|
||||
for item in ["nwg-look"]:
|
||||
copy_from_skel(item, folder="data", skip_confirmation=args.all)
|
||||
|
||||
print("\n\nThat's all. You may run sway now.\n")
|
||||
|
||||
shell_data = {"last-upgrade": __version__}
|
||||
# Installing over existing install
|
||||
shell_data = load_json(shell_data_file)
|
||||
# We no longer need the pre-v0.3.0 "last-upgrade" key: delete it if found
|
||||
if "last-upgrade" in shell_data:
|
||||
del shell_data["last-upgrade"]
|
||||
save_json(shell_data, shell_data_file)
|
||||
else:
|
||||
print("File installation cancelled")
|
||||
|
||||
# Backup sway config file
|
||||
now = datetime.datetime.now()
|
||||
new_name = now.strftime("config-backup-%Y%m%d-%H%M%S")
|
||||
src = os.path.join(config_home, "sway/config")
|
||||
dst = os.path.join(config_home, "sway/{}".format(new_name))
|
||||
proceed = True
|
||||
try:
|
||||
if os.path.isfile(src):
|
||||
copy(src, dst)
|
||||
print("* Original sway config file copied to '{}'".format(new_name))
|
||||
except Exception as e:
|
||||
print("Error: {}".format(e))
|
||||
a = input("Proceed with installation? y/N ")
|
||||
proceed = a.strip().upper() == "Y"
|
||||
|
||||
if proceed:
|
||||
for item in ["sway", "nwg-panel", "nwg-drawer", "nwg-dock", "nwg-bar", "swaync", "foot"]:
|
||||
copy_from_skel(item, folder="config", skip_confirmation=args.all)
|
||||
for item in ["nwg-look"]:
|
||||
copy_from_skel(item, folder="data", skip_confirmation=args.all)
|
||||
|
||||
print("\n\nThat's all. You may run sway now.\n")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -8,7 +8,6 @@ def main():
|
||||
print("Commands:")
|
||||
print(" nwg-shell-installer installs selected default configs interactively")
|
||||
print(" nwg-shell-installer -a installs all configs from scratch")
|
||||
print(" nwg-shell-installer -u upgrades configs if necessary")
|
||||
print(" nwg-shell-check-updates checks for updates")
|
||||
|
||||
|
||||
|
179
nwg_shell/skel/config/foot/foot.ini
Normal file
179
nwg_shell/skel/config/foot/foot.ini
Normal file
@ -0,0 +1,179 @@
|
||||
# -*- conf -*-
|
||||
|
||||
# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd)
|
||||
# term=foot (or xterm-256color if built with -Dterminfo=disabled)
|
||||
# login-shell=no
|
||||
|
||||
# app-id=foot
|
||||
# title=foot
|
||||
# locked-title=no
|
||||
|
||||
font=monospace:size=11
|
||||
# font-bold=<bold variant of regular font>
|
||||
# font-italic=<italic variant of regular font>
|
||||
# font-bold-italic=<bold+italic variant of regular font>
|
||||
# line-height=<font metrics>
|
||||
# letter-spacing=0
|
||||
# horizontal-letter-offset=0
|
||||
# vertical-letter-offset=0
|
||||
# underline-offset=<font metrics>
|
||||
# box-drawings-uses-font-glyphs=no
|
||||
dpi-aware=no
|
||||
|
||||
# initial-window-size-pixels=700x500 # Or,
|
||||
# initial-window-size-chars=<COLSxROWS>
|
||||
# initial-window-mode=windowed
|
||||
# pad=2x2 # optionally append 'center'
|
||||
# resize-delay-ms=100
|
||||
|
||||
# notify=notify-send -a ${app-id} -i ${app-id} ${title} ${body}
|
||||
|
||||
# bold-text-in-bright=no
|
||||
# word-delimiters=,│`|:"'()[]{}<>
|
||||
# selection-target=primary
|
||||
# workers=<number of logical CPUs>
|
||||
|
||||
[bell]
|
||||
# urgent=no
|
||||
# notify=no
|
||||
# command=
|
||||
# command-focused=no
|
||||
|
||||
[scrollback]
|
||||
# lines=1000
|
||||
# multiplier=3.0
|
||||
# indicator-position=relative
|
||||
# indicator-format=
|
||||
|
||||
[url]
|
||||
# launch=xdg-open ${url}
|
||||
# label-letters=sadfjklewcmpgh
|
||||
# osc8-underline=url-mode
|
||||
# protocols=http, https, ftp, ftps, file, gemini, gopher
|
||||
# uri-characters=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.,~:;/?#@!$&%*+="'
|
||||
|
||||
[cursor]
|
||||
# style=block
|
||||
# color=111111 dcdccc
|
||||
# blink=no
|
||||
# beam-thickness=1.5
|
||||
# underline-thickness=<font underline thickness>
|
||||
|
||||
[mouse]
|
||||
# hide-when-typing=no
|
||||
# alternate-scroll-mode=yes
|
||||
|
||||
[colors]
|
||||
alpha=0.9
|
||||
# foreground=dcdccc
|
||||
# background=111111
|
||||
|
||||
## Normal/regular colors (color palette 0-7)
|
||||
# regular0=222222 # black
|
||||
# regular1=cc9393 # red
|
||||
# regular2=7f9f7f # green
|
||||
# regular3=d0bf8f # yellow
|
||||
# regular4=6ca0a3 # blue
|
||||
# regular5=dc8cc3 # magenta
|
||||
# regular6=93e0e3 # cyan
|
||||
# regular7=dcdccc # white
|
||||
|
||||
## Bright colors (color palette 8-15)
|
||||
# bright0=666666 # bright black
|
||||
# bright1=dca3a3 # bright red
|
||||
# bright2=bfebbf # bright green
|
||||
# bright3=f0dfaf # bright yellow
|
||||
# bright4=8cd0d3 # bright blue
|
||||
# bright5=fcace3 # bright magenta
|
||||
# bright6=b3ffff # bright cyan
|
||||
# bright7=ffffff # bright white
|
||||
|
||||
## dimmed colors (see foot.ini(5) man page)
|
||||
# dim0=<not set>
|
||||
# ...
|
||||
# dim7=<not-set>
|
||||
|
||||
## The remaining 256-color palette
|
||||
# 16 = <256-color palette #16>
|
||||
# ...
|
||||
# 255 = <256-color palette #255>
|
||||
|
||||
## Misc colors
|
||||
# selection-foreground=<inverse foreground/background>
|
||||
# selection-background=<inverse foreground/background>
|
||||
# jump-labels=<regular0> <regular3>
|
||||
# urls=<regular3>
|
||||
# scrollback-indicator=<regular0> <bright4>
|
||||
|
||||
[csd]
|
||||
# preferred=server
|
||||
# size=26
|
||||
# font=<primary font>
|
||||
# color=<foreground color>
|
||||
# border-width=0
|
||||
# border-color=<csd.color>
|
||||
# button-width=26
|
||||
# button-color=<background color>
|
||||
# button-minimize-color=<regular4>
|
||||
# button-maximize-color=<regular2>
|
||||
# button-close-color=<regular1>
|
||||
|
||||
[key-bindings]
|
||||
# scrollback-up-page=Shift+Page_Up
|
||||
# scrollback-up-half-page=none
|
||||
# scrollback-up-line=none
|
||||
# scrollback-down-page=Shift+Page_Down
|
||||
# scrollback-down-half-page=none
|
||||
# scrollback-down-line=none
|
||||
# clipboard-copy=Control+Shift+c XF86Copy
|
||||
# clipboard-paste=Control+Shift+v XF86Paste
|
||||
# primary-paste=Shift+Insert
|
||||
# search-start=Control+Shift+r
|
||||
# font-increase=Control+plus Control+equal Control+KP_Add
|
||||
# font-decrease=Control+minus Control+KP_Subtract
|
||||
# font-reset=Control+0 Control+KP_0
|
||||
# spawn-terminal=Control+Shift+n
|
||||
# minimize=none
|
||||
# maximize=none
|
||||
# fullscreen=none
|
||||
# pipe-visible=[sh -c "xurls | fuzzel | xargs -r firefox"] none
|
||||
# pipe-scrollback=[sh -c "xurls | fuzzel | xargs -r firefox"] none
|
||||
# pipe-selected=[xargs -r firefox] none
|
||||
# show-urls-launch=Control+Shift+u
|
||||
# show-urls-copy=none
|
||||
# noop=none
|
||||
|
||||
[search-bindings]
|
||||
# cancel=Control+g Control+c Escape
|
||||
# commit=Return
|
||||
# find-prev=Control+r
|
||||
# find-next=Control+s
|
||||
# cursor-left=Left Control+b
|
||||
# cursor-left-word=Control+Left Mod1+b
|
||||
# cursor-right=Right Control+f
|
||||
# cursor-right-word=Control+Right Mod1+f
|
||||
# cursor-home=Home Control+a
|
||||
# cursor-end=End Control+e
|
||||
# delete-prev=BackSpace
|
||||
# delete-prev-word=Mod1+BackSpace Control+BackSpace
|
||||
# delete-next=Delete
|
||||
# delete-next-word=Mod1+d Control+Delete
|
||||
# extend-to-word-boundary=Control+w
|
||||
# extend-to-next-whitespace=Control+Shift+w
|
||||
# clipboard-paste=Control+v Control+y
|
||||
# primary-paste=Shift+Insert
|
||||
|
||||
[url-bindings]
|
||||
# cancel=Control+g Control+c Control+d Escape
|
||||
# toggle-url-visible=t
|
||||
|
||||
[mouse-bindings]
|
||||
# selection-override-modifiers=Shift
|
||||
# primary-paste=BTN_MIDDLE
|
||||
# select-begin=BTN_LEFT
|
||||
# select-begin-block=Control+BTN_LEFT
|
||||
# select-extend=BTN_RIGHT
|
||||
# select-extend-character-wise=Control+BTN_RIGHT
|
||||
# select-word=BTN_LEFT-2
|
||||
# select-word-whitespace=Control+BTN_LEFT-2
|
||||
# select-row=BTN_LEFT-3
|
@ -1,6 +1,19 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def temp_dir():
|
||||
if os.getenv("TMPDIR"):
|
||||
return os.getenv("TMPDIR")
|
||||
elif os.getenv("TEMP"):
|
||||
return os.getenv("TEMP")
|
||||
elif os.getenv("TMP"):
|
||||
return os.getenv("TMP")
|
||||
|
||||
return "/tmp"
|
||||
|
||||
|
||||
def load_json(path):
|
||||
@ -27,6 +40,15 @@ def load_text_file(path):
|
||||
return None
|
||||
|
||||
|
||||
def save_string(string, file):
|
||||
try:
|
||||
file = open(file, "wt")
|
||||
file.write(string)
|
||||
file.close()
|
||||
except:
|
||||
print("Error writing file '{}'".format(file))
|
||||
|
||||
|
||||
def save_list_to_text_file(data, file_path):
|
||||
text_file = open(file_path, "w")
|
||||
for line in data:
|
||||
@ -46,9 +68,9 @@ def is_newer(string_new, string_existing):
|
||||
if new and existing:
|
||||
if new[0] > existing[0]:
|
||||
return True
|
||||
elif new[1] > existing[1]:
|
||||
elif new[1] > existing[1] and new[0] >= existing[0]:
|
||||
return True
|
||||
elif new[2] > existing[2]:
|
||||
elif new[2] > existing[2] and new[0] >= existing[0] and new[1] >= existing[1]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
@ -64,3 +86,7 @@ def major_minor_path(string):
|
||||
return int(parts[0]), int(parts[1]), int(parts[2])
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def eprint(*args, **kwargs):
|
||||
print(*args, file=sys.stderr, **kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user