summaryrefslogtreecommitdiff
path: root/unfreezeapp
blob: 495a75089d876513604a394c50439c939c0b3838 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash

# in order to execute the function, X env have to be prepared
#killall -CONT Xorg

# 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
bspcomp & #killall -CONT picom
killall -CONT $apps
killall -CONT polybar
exec $HOME/scripts/runtransani.sh &