add nwg-hello

This commit is contained in:
Matthew Stobbs
2025-03-11 21:20:14 -06:00
parent a7bb81db9c
commit a9d817ce05
6 changed files with 181 additions and 1 deletions

View File

@@ -0,0 +1,99 @@
diff --git a/install.sh b/install.sh
index fe77638..765b6a1 100755
--- a/install.sh
+++ b/install.sh
@@ -11,7 +11,7 @@ install -D -m 644 -t /usr/share/nwg-hello/ nwg.jpg
install -D -m 644 -t /usr/share/nwg-hello/ img/*
install -d /var/cache/nwg-hello
-install -Dm644 -t /var/cache/nwg-hello cache.json -o greeter
+install -Dm644 -t /var/cache/nwg-hello cache.json -o greetd
install -Dm 644 -t "/usr/share/licenses/nwg-hello" LICENSE
install -Dm 644 -t "/usr/share/doc/nwg-hello" README.md
diff --git a/nwg-hello-default.json b/nwg-hello-default.json
index 1374f67..42e769a 100644
--- a/nwg-hello-default.json
+++ b/nwg-hello-default.json
@@ -1,20 +1,21 @@
{
"session_dirs": [
"/usr/share/wayland-sessions",
- "/usr/share/xsessions"
+ "/usr/share/xsessions",
+ "/usr/local/share/wayland-sessions"
],
"custom_sessions": [
{
"name": "Shell",
- "exec": "/usr/bin/bash"
+ "exec": "/bin/zsh"
}
],
"monitor_nums": [],
"form_on_monitors": [],
"delay_secs": 1,
- "cmd-sleep": "systemctl suspend",
- "cmd-reboot": "systemctl reboot",
- "cmd-poweroff": "systemctl poweroff",
+ "cmd-sleep": "zzz",
+ "cmd-reboot": "openrc reboot",
+ "cmd-poweroff": "openrc poweroff",
"gtk-theme": "Adwaita",
"gtk-icon-theme": "",
"gtk-cursor-theme": "",
diff --git a/nwg_hello/main.py b/nwg_hello/main.py
index c3fe440..de81b29 100755
--- a/nwg_hello/main.py
+++ b/nwg_hello/main.py
@@ -43,7 +43,7 @@ args = parser.parse_args()
if args.log:
args.debug = True
-if args.log and os.getenv("USER") == "greeter":
+if args.log and os.getenv("USER") == "greetd":
now = datetime.now()
eprint(f'[nwg-hello log {now.strftime("%Y-%m-%d %H:%M:%S")}]', log=True)
@@ -68,9 +68,9 @@ defaults = {
"monitor_nums": [],
"form_on_monitors": [],
"delay_secs": 1,
- "cmd-sleep": "systemctl suspend",
- "cmd-reboot": "systemctl reboot",
- "cmd-poweroff": "systemctl poweroff",
+ "cmd-sleep": "zzz",
+ "cmd-reboot": "openrc reboot",
+ "cmd-poweroff": "openrc poweroff",
"gtk-theme": "Adwaita",
"gtk-icon-theme": "",
"gtk-cursor-theme": "",
diff --git a/nwg_hello/tools.py b/nwg_hello/tools.py
index d7eb76d..5a63e4e 100644
--- a/nwg_hello/tools.py
+++ b/nwg_hello/tools.py
@@ -17,7 +17,7 @@ def temp_dir():
def eprint(*args, log=False):
print(*args, file=sys.stderr)
# we don't log testing sessions
- if log and os.getenv("USER") == "greeter":
+ if log and os.getenv("USER") == "greetd":
log_file = os.path.join(temp_dir(), 'nwg-hello.log')
with open(log_file, 'a') as f:
print(*args, file=f)
diff --git a/sway-config b/sway-config
index f51b0e8..d7c67e1 100644
--- a/sway-config
+++ b/sway-config
@@ -3,7 +3,7 @@ exec "nwg-hello; swaymsg exit"
bindsym Mod4+shift+e exec swaynag \
-t warning \
-m 'What do you want to do?' \
- -b 'Poweroff' 'systemctl poweroff' \
- -b 'Reboot' 'systemctl reboot'
+ -b 'Poweroff' 'openrc poweroff' \
+ -b 'Reboot' 'openrc reboot'
-include /etc/sway/config.d/*
\ No newline at end of file
+include /etc/sway/config.d/*

View File

@@ -0,0 +1,9 @@
- name: Set nwg-hello configuration
ansible.builtin.set_fact:
nwg_hello:
vers: "{{ pkgconfig.nwg_hello.version }}"
git_repo: "{{ pkgconfig.nwg_hello.git_repo }}"
installed_files: "{{ pkgconfig.nwg_hello.build_installed_files }}"
git_path: "{{ d_tempdir.path }}/nwg-hello"
build_deps: "{{ pkgconfig.nwg_hello.bulid_deps[ansible_os_family] }}"
clean: "{{ pkgconfig.nwg_hello.clean | default(false) }}"

15
tasks/pkgs/nwg_hello.yml Normal file
View File

@@ -0,0 +1,15 @@
- name: Add nwg-hello
when:
- nwg_hello_configured is undefined
block:
- name: Load nwg-hello config
ansible.builtin.include_tasks:
file: config/nwg_hello.yml
- name: Append nwg-hello build_deps to sys_pkg
ansible.builtin.set_fact:
pkg_sys: "{{ pkg_sys + nwg_hello.build_deps }}"
- name: Append nwg-hello to pkg_src
ansible.builtin.set_fact:
pkg_src: "{{ pkg_src + ['nwg_hello'] }}"

View File

@@ -1,7 +1,7 @@
- name: Remove existing install
when:
- hyprland_clean
become: "{{ ext_become }}"
become: true
loop: "{{ aquamarine.installed_files }}"
loop_control:
loop_var: file

42
tasks/src/nwg_hello.yml Normal file
View File

@@ -0,0 +1,42 @@
- name: Remove existing install
when:
- nwg_hello.clean
become: true
loop: "{{ nwg_hello.installed_files }}"
loop_control:
loop_var: file
ansible.builtin.file:
state: absent
path: "{{ file }}"
- name: Check if nwg-hello is installed
register: stat_nwg_hello_inst
ansible.builtin.stat:
path: /etc/nwg-hello
- name: Build and install nwg-hello
when:
- not stat_nwg_hello_inst.stat.exists
block:
- name: Clone git repository
ansible.builtin.git:
depth: 1
dest: "{{ nwg_hello.git_path }}"
repo: "{{ nwg_hello.git_repo }}"
version: "{{ nwg_hello.vers }}"
- name: Apply patch if it exists for {{ ansible_os_family }}
ignore_failures: true
ansible.posix.patch:
basedir: "{{ nwg_hello.git_path }}"
src: nwg-hello/{{ ansible_os_family }}.patch
state: present
- name: Install nwg-hello
become: true
ansible.builtin.command:
creates: /etc/nwg-hello
chdir: "{{ nwg_hello.git_path }}"
argv:
- sh
- install.sh

15
vars/pkgs/nwg_hello.yml Normal file
View File

@@ -0,0 +1,15 @@
nwg_hello:
version: main
git_repo: https://github.com/nwg-piotr/nwg-hello
build_deps:
Alpine:
- py3-build
- py3-installer
- py3-wheel
- py3-setuptools
build_installed_files:
- /etc/nwg-hello
- /usr/share/nwg-hello
- /var/cache/nwg-hello
- /usr/share/licenses/nwg-hello
- /usr/share/doc/nwg-hello