forked from GH-forks/hyprfreeze
feat: session/desktop detection
This commit is contained in:
parent
93a2017713
commit
6607c0c568
2 changed files with 19 additions and 1 deletions
|
@ -19,6 +19,7 @@ Hyprfreeze is available in [AUR](https://aur.archlinux.org/packages/hyprfreeze-g
|
|||
- a compatible window manager (`hyprland` or `sway`) to get the PID of the active window
|
||||
- `jq` to parse json
|
||||
- `psmisc` contains 'pstree' which is required to list child processes
|
||||
- Systemd for the `loginctl` utility
|
||||
### Optional
|
||||
- [`hyprprop`](https://github.com/vilari-mickopf/hyprprop) to get the pid of a window by selecting it with your mouse
|
||||
### Highly Recommended
|
||||
|
|
19
hyprfreeze
19
hyprfreeze
|
@ -101,8 +101,23 @@ function getPidByProp() {
|
|||
debugPrint "PID by prop: $PID"
|
||||
}
|
||||
|
||||
function detectEnvironment() {
|
||||
local Type
|
||||
local Desktop
|
||||
eval "$(loginctl show-session $(loginctl | grep $(whoami) | awk '{print $1}') -p Type -p Desktop)"
|
||||
[ -z "$Type" ] && echo "Could not determine session type via \`loginctl\`." && exit 1
|
||||
[ -z "$Desktop" ] && echo "Could not determine desktop environment via \`loginctl\`." && exit 1
|
||||
SESSION=$Type
|
||||
DESKTOP=$Desktop
|
||||
}
|
||||
|
||||
function printInfo() {
|
||||
debugPrint "Printing process info...\n"
|
||||
debugPrint "Printing environment info..."
|
||||
echo -e "$(tput bold)Session type:$(tput sgr0) $SESSION"
|
||||
echo -e "$(tput bold)Desktop:$(tput sgr0) $DESKTOP"
|
||||
echo ""
|
||||
|
||||
debugPrint "Printing process info..."
|
||||
echo -e "$(tput bold)Process tree:$(tput sgr0)"
|
||||
ps -p "$PID" 2>/dev/null && pstree -p "$PID"
|
||||
|
||||
|
@ -226,4 +241,6 @@ DEBUG=0
|
|||
|
||||
args "$@"
|
||||
|
||||
detectEnvironment
|
||||
|
||||
main
|
||||
|
|
Loading…
Reference in a new issue