Skip to content

Commit

Permalink
Merge pull request #66 from nwg-piotr/gui
Browse files Browse the repository at this point in the history
updated install script for Arch Linux
  • Loading branch information
nwg-piotr authored Feb 1, 2023
2 parents aeb52f3 + 2308528 commit 4bb8011
Show file tree
Hide file tree
Showing 8 changed files with 289 additions and 16 deletions.
50 changes: 50 additions & 0 deletions install/arch-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/bash

# wget https://raw.github.com/nwg-piotr/nwg-shell/main/install/arch-dev.sh && chmod u+x arch-dev.sh && ./arch-dev.sh && rm ./arch-dev.sh
sudo pacman -S --noconfirm git man-db vi xdg-user-dirs

echo Initializing XDG user directories
xdg-user-dirs-update

echo "Adding $USER to video group"
sudo usermod -aG video $USER

echo "Installing Basic AUR Package Helper"
git clone https://bitbucket.org/natemaia/baph.git || { echo "Failed cloning baph: $?"; }
cd baph || { echo "Couldn't setup baph, terminating..."; exit 1; }
sudo make install

echo
echo "You're about to select components, that need to be preinstalled for the key bindings to work."
echo "None of above is a shell dependency, and you're free to change them any time later."
echo

PS3="Select file manager: "
select fm in thunar caja dolphin nautilus nemo pcmanfm;
do
break
done
echo

PS3="Select text editor: "
select editor in mousepad atom emacs gedit geany kate vim;
do
break
done
echo

PS3="Select web browser: "
select browser in chromium brave-bin google-chrome epiphany falkon firefox konqueror midori opera qutebrowser seamonkey surf vivaldi;
do
break
done
echo

echo "Installing selection: $fm $editor $browser"
baph -inN $fm $editor $browser

echo Installing nwg-shell
baph -inN nwg-shell-git

echo Installing initial configuration
nwg-shell-installer -w
50 changes: 50 additions & 0 deletions install/arch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/bash

# wget https://raw.github.com/nwg-piotr/nwg-shell/main/install/arch.sh && chmod u+x arch.sh && ./arch.sh && rm arch.sh
sudo pacman -S --noconfirm git man-db vi xdg-user-dirs

echo Initializing XDG user directories
xdg-user-dirs-update

echo "Adding $USER to video group"
sudo usermod -aG video $USER

echo "Installing Basic AUR Package Helper"
git clone https://bitbucket.org/natemaia/baph.git || { echo "Failed cloning baph: $?"; }
cd baph || { echo "Couldn't setup baph, terminating..."; exit 1; }
sudo make install

echo
echo "You're about to select components, that need to be preinstalled for the key bindings to work."
echo "None of above is a shell dependency, and you're free to change them any time later."
echo

PS3="Select file manager: "
select fm in thunar caja dolphin nautilus nemo pcmanfm;
do
break
done
echo

PS3="Select text editor: "
select editor in mousepad atom emacs gedit geany kate vim;
do
break
done
echo

PS3="Select web browser: "
select browser in chromium brave-bin google-chrome epiphany falkon firefox konqueror midori opera qutebrowser seamonkey surf vivaldi;
do
break
done
echo

echo "Installing selection: $fm $editor $browser"
baph -inN $fm $editor $browser

echo Installing nwg-shell
baph -inN nwg-shell

echo Installing initial configuration
nwg-shell-installer -w
27 changes: 27 additions & 0 deletions install/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/bash

# Download me, make executable, run & remove:
# wget https://raw.github.com/nwg-piotr/nwg-shell/gui/install/test.sh -O test.sh && chmod u+x test.sh && ./test.sh && rm arch.sh

echo "You're about to install the rest of components required for the key bindings to work."
echo "None of them is a shell dependency, and you're free to change them later."

PS3="Select file manager: "
select fm in thunar caja dolphin nautilus nemo pcmanfm;
do
break
done

PS3="Select text editor: "
select editor in mousepad atom emacs gedit geany kate vim;
do
break
done

PS3="Select web browser: "
select browser in chromium brave-bin google-chrome-stable epiphany falkon firefox konqueror midori opera qutebrowser seamonkey surf vivaldi-stable;
do
break
done

echo "baph -inN $fm $editor $browser"
59 changes: 54 additions & 5 deletions nwg_shell/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
import argparse
import datetime
import os
import subprocess
import sys
from shutil import copy, copytree

from nwg_shell.__about__ import __version__

from nwg_shell.tools import load_json, save_json
from nwg_shell.tools import load_json, save_json, is_command

dir_name = os.path.dirname(__file__)

Expand All @@ -35,6 +36,22 @@
shell_data = None
shell_data_file = os.path.join(data_home, "nwg-shell/data")

browsers = {
"brave": "brave --enable-features=UseOzonePlatform --ozone-platform=wayland",
"chromium": "chromium --enable-features=UseOzonePlatform --ozone-platform=wayland",
"google-chrome-stable": "google-chrome-stable --enable-features=UseOzonePlatform --ozone-platform=wayland",
"epiphany": "epiphany",
"falkon": "falkon",
"firefox": "MOZ_ENABLE_WAYLAND=1 firefox",
"konqueror": "konqueror",
"midori": "midori",
"opera": "opera",
"qutebrowser": "qutebrowser",
"seamonkey": "seamonkey",
"surf": "surf",
"vivaldi-stable": "vivaldi-stable --enable-features=UseOzonePlatform --ozone-platform=wayland",
}


def copy_from_skel(name, folder="config", skip_confirmation=False):
src = os.path.join(dir_name, "skel/{}/".format(folder), name)
Expand Down Expand Up @@ -155,7 +172,7 @@ def main():
del shell_data["last-upgrade"]
save_json(shell_data, shell_data_file)

# Backup sway config file
# Backup sway config file (we may have none on fresh installation)
now = datetime.datetime.now()
new_name = now.strftime("config-backup-%Y%m%d-%H%M%S")
src = os.path.join(config_home, "sway/config")
Expand All @@ -174,10 +191,39 @@ def main():
skip = args.all or args.web
for item in ["sway", "nwg-panel", "nwg-drawer", "nwg-dock", "nwg-bar", "nwg-look", "swaync", "foot", "gtklock"]:
copy_from_skel(item, folder="config", skip_confirmation=skip)
for item in ["nwg-look"]:
for item in ["nwg-look", "nwg-shell-config"]:
copy_from_skel(item, folder="data", skip_confirmation=skip)

# copy default background
# Set default apps, if found, for nwg-shell-config
shell_config_settings_file = os.path.join(data_home, "nwg-shell-config", "settings")
shell_config_settings = load_json(shell_config_settings_file)

if "terminal" not in shell_config_settings or not shell_config_settings["terminal"]:
shell_config_settings["terminal"] = "foot"

if "file-manager" not in shell_config_settings or not shell_config_settings["file-manager"]:
for cmd in ["thunar", "caja", "dolphin", "nautilus", "nemo", "pcmanfm"]:
if is_command(cmd):
shell_config_settings["file-manager"] = cmd
break

if "editor" not in shell_config_settings or not shell_config_settings["editor"]:
for cmd in ["mousepad", "atom", "emacs", "gedit", "geany", "kate", "vim"]:
if is_command(cmd):
shell_config_settings["editor"] = cmd
break

if "browser" not in shell_config_settings or not shell_config_settings["browser"]:
for cmd in ["brave", "chromium", "google-chrome-stable", "epiphany", "falkon", "firefox", "konqueror",
"midori",
"opera", "qutebrowser", "seamonkey", "surf", "vivaldi-stable"]:
if is_command(cmd):
shell_config_settings["browser"] = browsers[cmd]
break

save_json(shell_config_settings, shell_config_settings_file)

# Copy default background
bcg = os.path.join(os.getenv("HOME"), "azotebg")
if not os.path.isfile(bcg):
print("Copying default background")
Expand All @@ -187,7 +233,10 @@ def main():
if not args.web:
print("\nThat's all. You may run sway now.\n")
else:
print("\nThat's all. For the brightness control to work, reboot before running sway.\n")
print("\nThat's all. For the brightness control to work, you need to reboot before running sway.\n")
a = input("\nReboot now? Y/n ")
if a.strip().upper() == "Y" or not a:
subprocess.call("sudo reboot", shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)


if __name__ == '__main__':
Expand Down
92 changes: 92 additions & 0 deletions nwg_shell/skel/data/nwg-shell-config/settings
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"keyboard-layout": "us",
"autotiling-workspaces": "",
"autotiling-on": true,
"autotiling-limit": false,
"autotiling-output-limits": {},
"appindicator": true,
"night-lat": -1,
"night-long": -1,
"night-temp-low": 4500,
"night-temp-high": 6500,
"night-gamma": 1.0,
"night-on": true,
"terminal": "",
"file-manager": "",
"editor": "",
"browser": "",
"panel-preset": "preset-0",
"panel-custom": "",
"show-on-startup": true,
"keyboard-use-settings": true,
"keyboard-identifier": "",
"keyboard-xkb-layout": "us",
"keyboard-xkb-variant": "",
"keyboard-repeat-delay": 300,
"keyboard-repeat-rate": 40,
"keyboard-xkb-capslock": "disabled",
"keyboard-xkb-numlock": "disabled",
"keyboard-custom-name": "",
"keyboard-custom-value": "",
"pointer-use-settings": true,
"pointer-identifier": "",
"pointer-accel-profile": "flat",
"pointer-pointer-accel": 0.0,
"pointer-natural-scroll": "disabled",
"pointer-scroll-factor": 1.0,
"pointer-left-handed": "disabled",
"pointer-custom-name": "",
"pointer-custom-value": "",
"touchpad-use-settings": true,
"touchpad-identifier": "",
"touchpad-accel-profile": "flat",
"touchpad-pointer-accel": 0.0,
"touchpad-natural-scroll": "disabled",
"touchpad-scroll-factor": 1.0,
"touchpad-scroll-method": "two_finger",
"touchpad-left-handed": "disabled",
"touchpad-tap": "enabled",
"touchpad-tap-button-map": "lrm",
"touchpad-drag": "enabled",
"touchpad-drag-lock": "disabled",
"touchpad-dwt": "enabled",
"touchpad-middle-emulation": "enabled",
"touchpad-custom-name": "",
"touchpad-custom-value": "",
"lockscreen-use-settings": true,
"lockscreen-locker": "gtklock",
"lockscreen-background-source": "local",
"lockscreen-custom-cmd": "",
"lockscreen-timeout": 1200,
"sleep-cmd": "swaymsg \"output * dpms off\"",
"sleep-timeout": 1800,
"resume-cmd": "swaymsg \"output * dpms on\"",
"before-sleep": "",
"backgrounds-custom-path": "",
"backgrounds-use-custom-path": false,
"background-dirs": [
"/usr/share/backgrounds/nwg-shell"
],
"background-dirs-once-set": false,
"unsplash-width": 1920,
"unsplash-height": 1080,
"unsplash-keywords": [
"nature",
"water",
"landscape"
],
"help-font-size": 14,
"help-layer-shell": true,
"help-keyboard": false,
"gtklock-disable-input-inhibitor": false,
"gtklock-idle-timeout": 10,
"gtklock-logout-command": "swaymsg exit",
"gtklock-playerctl": false,
"gtklock-powerbar": false,
"gtklock-poweroff-command": "systemctl -i poweroff",
"gtklock-reboot-command": "systemctl reboot",
"gtklock-suspend-command": "systemctl suspend",
"gtklock-time-format": "%H:%M:%S",
"gtklock-userinfo": false,
"gtklock-userswitch-command": ""
}
14 changes: 14 additions & 0 deletions nwg_shell/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import json
import sys
import subprocess


def temp_dir():
Expand Down Expand Up @@ -64,6 +65,19 @@ def save_list_to_text_file(data, file_path):
text_file.close()


def is_command(cmd):
cmd = cmd.split()[0]
cmd = "command -v {}".format(cmd)
try:
is_cmd = subprocess.check_output(
cmd, shell=True).decode("utf-8").strip()
if is_cmd:
return True

except subprocess.CalledProcessError:
return False


def is_newer(string_new, string_existing):
"""
Compares versions in format 'major.minor.patch' (just numbers allowed).
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def read(f_name):

setup(
name='nwg-shell',
version='0.4.1',
version='0.4.2',
description='GTK3-based shell for sway Wayland compositor',
packages=find_packages(),
include_package_data=True,
Expand All @@ -21,6 +21,7 @@ def read(f_name):
"skel/config/nwg-panel/*",
"skel/config/nwg-look/*",
"skel/data/nwg-look/*",
"skel/data/nwg-shell-config/*",
"skel/config/sway/*",
"skel/config/swaync/*",
"skel/config/foot/*",
Expand Down
10 changes: 0 additions & 10 deletions webinstaller/arch.sh

This file was deleted.

0 comments on commit 4bb8011

Please sign in to comment.