mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-24 06:24:19 +02:00
Add example scripts for socket interaction
This commit is contained in:
parent
8660346f76
commit
e46a32ab43
3 changed files with 60 additions and 0 deletions
23
example_scripts/show_workspace_views.sh
Normal file
23
example_scripts/show_workspace_views.sh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script displays the process names of the views on the current workspace.
|
||||
|
||||
# Start up the ipc link
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/cb_script_header.sh"
|
||||
|
||||
echo "dump" >&3
|
||||
|
||||
while IFS= read -r -d $'\0' event
|
||||
do
|
||||
# Remove the cg-ipc header
|
||||
event="${event:6}"
|
||||
if [[ "$(echo "${event}" | jq ".event_name")" = "\"dump\"" ]]
|
||||
then
|
||||
curr_output="$(echo "${event}"|jq ".curr_output")"
|
||||
curr_workspace="$(echo "${event}"|jq -r ".outputs.${curr_output}.curr_workspace")"
|
||||
# Print the process names of the view on the current workspace. jq retrieves
|
||||
# their PID and ps is then used to retrieve the process names.
|
||||
(echo -n "message ";ps -o comm=Command -p $(echo "${event}"|jq -r ".outputs.${curr_output}.workspaces[$((curr_workspace-1))].views[].pid")|tail +2|sed ':a; N; $!ba; s/\n/||/g') >&3
|
||||
break
|
||||
fi
|
||||
done <&4
|
||||
Loading…
Add table
Add a link
Reference in a new issue