diff options
| author | littleblack111 <jerrylam110209@gmail.com> | 2023-06-25 14:19:54 +0800 |
|---|---|---|
| committer | littleblack111 <jerrylam110209@gmail.com> | 2023-06-25 14:19:54 +0800 |
| commit | d86fb7ecd498910b78fd197d92a494f165b42169 (patch) | |
| tree | 17ab598689e7152507b0741e21325ef60d82e6dc /unfreezeapp | |
| parent | bd7784d182c0c7609d419817b18462283e51062d (diff) | |
more scripts and updated .gitignore for bins
Diffstat (limited to 'unfreezeapp')
| -rwxr-xr-x | unfreezeapp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/unfreezeapp b/unfreezeapp new file mode 100755 index 0000000..116b981 --- /dev/null +++ b/unfreezeapp @@ -0,0 +1,39 @@ +#!/bin/bash + +# Define the function to get the list of running GUI applications +running_gui_apps() { + applications=() + + # loop through all open windows (ids) + for win_id in $( wmctrl -l | cut -d' ' -f1 ); do + + # test if window is a normal window + if $( xprop -id $win_id _NET_WM_WINDOW_TYPE | grep -q _NET_WM_WINDOW_TYPE_NORMAL ) ; then + + # get the process ID of the window + pid=$( xprop -id $win_id _NET_WM_PID | cut -d' ' -f3 ) + + # get the process name from the process ID using ps + pname=$( ps -p $pid -o comm= ) + + # add to result list + applications+=( "$pname" ) + + fi + + done + + # sort result list and remove duplicates + readarray -t applications < <(printf '%s\0' "${applications[@]}" | sort -z | xargs -0n1 | uniq) + + printf '%s\n' "${applications[@]}" +} + +# Call the function to get the list of running GUI applications +apps=$(running_gui_apps) + +# Replace newline characters with spaces using tr +apps=$(echo "$apps" | tr '\n' ' ') + +# Use killall with the -STOP option and the modified apps variable to stop the applications +killall -CONT $apps |
