commit
84d94c9689
@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Monitor user sessions and lock screen on state change
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/session-monitor
|
||||
Restart=always
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
check_session_state() {
|
||||
active_session=$(loginctl | grep "online" | awk '{print $1}')
|
||||
|
||||
for session in $active_session; do
|
||||
current_state=$(loginctl show-session $session -p Active --value)
|
||||
|
||||
if [[ $current_state == "no" ]]; then
|
||||
/usr/bin/loginctl lock-session $session
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
while true; do
|
||||
check_session_state
|
||||
sleep 1
|
||||
done
|
@ -0,0 +1,52 @@
|
||||
Summary: Monitor user sessions and lock screen on state change
|
||||
Name: session-monitor
|
||||
Version: 0.1
|
||||
Release: 1%{?dist}
|
||||
License: GPLv2+
|
||||
URL: http://msvsphere-os.ru/
|
||||
Source0: session-monitor.sh
|
||||
Source1: session-monitor.service
|
||||
|
||||
BuildRequires: systemd-rpm-macros
|
||||
|
||||
Requires(post): systemd
|
||||
Requires(post): systemd-sysv
|
||||
Requires(preun): systemd
|
||||
Requires(posttrans): systemd
|
||||
|
||||
%description
|
||||
Monitor user sessions and lock screen on state change. Useful if screen was
|
||||
changed.
|
||||
|
||||
%prep
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}%{_bindir}
|
||||
mkdir -p %{buildroot}%{_unitdir}
|
||||
|
||||
install -m 755 %{SOURCE0} %{buildroot}%{_bindir}/%{name}
|
||||
install -m 644 %{SOURCE1} %{buildroot}%{_unitdir}
|
||||
|
||||
%post
|
||||
%systemd_post %{name}.service
|
||||
/usr/bin/systemctl enable --now %{name}.service ||:
|
||||
|
||||
%preun
|
||||
%systemd_preun %{name}.service
|
||||
/usr/bin/systemctl stop %{name}.service ||:
|
||||
|
||||
%postun
|
||||
%systemd_postun_with_restart %{name}.service
|
||||
|
||||
%files
|
||||
%{_bindir}/%{name}
|
||||
%{_unitdir}/%{name}.service
|
||||
|
||||
%changelog
|
||||
* Mon Sep 02 2024 Arkady L. Shane <tigro@msvsphere-os.ru> - 0.1-1
|
||||
- Rebuilt for MSVSphere 9.4
|
||||
|
||||
* Wed Aug 07 2024 Arkady L. Shane <tigro@msvsphere-os.ru> - 0.1-1
|
||||
- Initial build
|
Loading…
Reference in new issue