mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-21 04:54:17 +02:00
Integrate library into example scripts.
- example scripts are now standalone. - consistency enforced via test
This commit is contained in:
parent
d0770ffb19
commit
c34057db8f
5 changed files with 48 additions and 7 deletions
15
example_scripts/screenshot_script
Normal file → Executable file
15
example_scripts/screenshot_script
Normal file → Executable file
|
|
@ -10,7 +10,20 @@
|
|||
# Example:
|
||||
# screenshot_script "gwenview"
|
||||
|
||||
source "$(dirname "${BASH_SOURCE[0]}")/cb_script_header.sh"
|
||||
named_pipe_send="$(mktemp -u)"
|
||||
named_pipe_recv="$(mktemp -u)"
|
||||
mkfifo "${named_pipe_send}"
|
||||
mkfifo "${named_pipe_recv}"
|
||||
nc -U "${CAGEBREAK_SOCKET}" < "${named_pipe_send}" > "${named_pipe_recv}"&
|
||||
# The file descriptor 3 is set up to send commands to cagebreak and file
|
||||
# descriptor 4 can be used to read events. Notice that events will pile up in
|
||||
# file descriptor 4, so it is a good idea to continuously read from it or to
|
||||
# clear it before starting a new transaction.
|
||||
exec 3>"${named_pipe_send}"
|
||||
exec 4<"${named_pipe_recv}"
|
||||
# When the script exits, the os will clean up the pipe
|
||||
rm "${named_pipe_recv}"
|
||||
rm "${named_pipe_send}"
|
||||
|
||||
if [[ ${#} -lt 1 ]]
|
||||
then
|
||||
|
|
|
|||
18
example_scripts/show_workspace_views
Normal file → Executable file
18
example_scripts/show_workspace_views
Normal file → Executable file
|
|
@ -1,11 +1,23 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2020 - 2024, project-repo and the cagebreak contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
#
|
||||
# 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"
|
||||
named_pipe_send="$(mktemp -u)"
|
||||
named_pipe_recv="$(mktemp -u)"
|
||||
mkfifo "${named_pipe_send}"
|
||||
mkfifo "${named_pipe_recv}"
|
||||
nc -U "${CAGEBREAK_SOCKET}" < "${named_pipe_send}" > "${named_pipe_recv}"&
|
||||
# The file descriptor 3 is set up to send commands to cagebreak and file
|
||||
# descriptor 4 can be used to read events. Notice that events will pile up in
|
||||
# file descriptor 4, so it is a good idea to continuously read from it or to
|
||||
# clear it before starting a new transaction.
|
||||
exec 3>"${named_pipe_send}"
|
||||
exec 4<"${named_pipe_recv}"
|
||||
# When the script exits, the os will clean up the pipe
|
||||
rm "${named_pipe_recv}"
|
||||
rm "${named_pipe_send}"
|
||||
|
||||
echo "dump" >&3
|
||||
|
||||
|
|
|
|||
|
|
@ -371,6 +371,7 @@ run_target('create-artefacts',
|
|||
# Test Suite
|
||||
|
||||
test('Build without warnings', find_program('test/build-w-o-warnings'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
|
||||
test('Example script header is consistent', find_program('test/script-header'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
|
||||
test('Build without xwayland', find_program('test/build-w-o-xwayland'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
|
||||
test('Copyright and LICENSE', find_program('test/copyright-license'), args : [ cagebreak_main_file + cagebreak_source_strings + cagebreak_header_strings + fuzz_sources + fuzz_headers + fuzz_override_lib ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()), ''.join('MESONLICENSE=', meson.project_license())], suite: 'devel' )
|
||||
test('Clang-format (formatting check)', find_program('test/clang-format'), args : [ cagebreak_main_file + cagebreak_source_strings + cagebreak_header_strings + fuzz_sources + fuzz_headers + fuzz_override_lib ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
|
||||
|
|
|
|||
17
test/script-header
Normal file
17
test/script-header
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2024, project-repo and the cagebreak contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
# Each example script must contain the header unmodified.
|
||||
|
||||
# shellcheck disable=2164
|
||||
cd "${MESONCURRENTCONFIGDIR}"
|
||||
|
||||
RESULT=0
|
||||
|
||||
for file in example_scripts/*
|
||||
do
|
||||
# shellcheck disable=2002
|
||||
grep "$(cat test/testing-configurations/cb_script_header.sh | tail -n +3 | tr '\n' ' ' )" <(cat "$file" | tr '\n' ' ') || RESULT=1
|
||||
done
|
||||
|
||||
exit $RESULT
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Copyright 2023 - 2024, project-repo and the cagebreak contributors
|
||||
# Copyright 2024, project-repo and the cagebreak contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
named_pipe_send="$(mktemp -u)"
|
||||
named_pipe_recv="$(mktemp -u)"
|
||||
mkfifo "${named_pipe_send}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue