feat: improve session switching, fractional DPI/GTK theming, XDG launcher, CPU/RAM status, and power policy
This commit is contained in:
1 parent
72b05b650e
commit
07d9134d2d
28 files changed
+2670
-302
No files matched your search
+26
-7
@@ -142,19 +142,38 @@ is_proc_running() {
|
||||
_tgt="$1"
|
||||
[ -n "$_tgt" ] || return 1
|
||||
_self="$$"
|
||||
(ps -eo pid=,comm=,args= 2>/dev/null || ps -ax -o pid=,comm=,args= 2>/dev/null || true) | awk -v tgt="$_tgt" -v self="$_self" '
|
||||
_my_uid="$(id -u)"
|
||||
_cands="$( (ps -eo uid=,pid=,comm=,args= 2>/dev/null || ps -ax -o uid=,pid=,comm=,args= 2>/dev/null || true) | awk -v tgt="$_tgt" -v self="$_self" -v myuid="$_my_uid" '
|
||||
{
|
||||
pid = $1; comm = $2; arg1 = $3
|
||||
if (pid == self) next
|
||||
uid = $1; pid = $2; comm = $3; arg1 = $4
|
||||
if (uid != myuid || pid == self) next
|
||||
sub(/^.*\//, "", comm)
|
||||
sub(/^.*\//, "", arg1)
|
||||
if (comm == tgt || arg1 == tgt) {
|
||||
found = 1
|
||||
exit 0
|
||||
print pid
|
||||
}
|
||||
}
|
||||
END { exit found ? 0 : 1 }
|
||||
'
|
||||
' )"
|
||||
[ -n "${_cands:-}" ] || return 1
|
||||
|
||||
_cur_sid="${XDG_SESSION_ID:-}"
|
||||
_cur_dbus="${DBUS_SESSION_BUS_ADDRESS:-}"
|
||||
for _cpid in $_cands; do
|
||||
if [ -r "/proc/$_cpid/environ" ] && { [ -n "$_cur_sid" ] || [ -n "$_cur_dbus" ]; }; then
|
||||
_penv="$(tr '\0' '\n' < "/proc/$_cpid/environ" 2>/dev/null || true)"
|
||||
_p_sid="$(printf '%s\n' "$_penv" | awk 'substr($0, 1, 15) == "XDG_SESSION_ID=" { print substr($0, 16); exit }')"
|
||||
_p_dbus="$(printf '%s\n' "$_penv" | awk 'substr($0, 1, 25) == "DBUS_SESSION_BUS_ADDRESS=" { print substr($0, 26); exit }')"
|
||||
if [ -n "$_cur_sid" ] && [ -n "${_p_sid:-}" ] && [ "$_p_sid" != "$_cur_sid" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ -n "$_cur_dbus" ] && [ -n "${_p_dbus:-}" ] && [ "$_p_dbus" != "$_cur_dbus" ]; then
|
||||
continue
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
launch_cmd() {
|
||||
|
||||
Reference in new issue
Block a user