Closed ahmeteid7 closed 8 months ago
Disable tiling as described here: https://github.com/leukipp/cortile/blob/e9328e36bc575224d331e5baa3c6bae9c874377d/config.toml#L118C5-L118C5
# Check if Cortile is running
if pgrep -f "/home/eid/go/bin/cortile" > /dev/null; then #that consider disable and exit as not running state, i wish if i can check the disable state separately
# The application is running, so let's kill it
echo '{"Action":"layout_fullscreen"}' | nc -U /tmp/cortile.sock.in
sleep 1
pkill -f "/home/eid/go/bin/cortile"
else
# The application is not running, so let's start it
/home/eid/go/bin/cortile &
If you are talking about socket communication commands (#41) you can use
echo '{"Action":"exit"}' | nc -U /tmp/cortile.sock.in
to gracefully stop cortile (the process is not running any more). When using
echo '{"Action":"disable"}' | nc -U /tmp/cortile.sock.in
the process still runs in the background and is listening for an enable
command (e.g. via keyboard shortcut).
You can use any command available in the config.toml
, e.g. also
echo '{"Action":"toggle"}' | nc -U /tmp/cortile.sock.in
As described in the README https://github.com/leukipp/cortile?tab=readme-ov-file#incoming-commands-and-requests the current state can also be requested. Here you would need two processes (two terminal windows) running. One is for listening and the other is for sending. Using the scripts you should be able to do this:
# terminal 1 (input)
./listen.sh -s /tmp/cortile.sock
# terminal 2 (input)
./send.sh -s /tmp/cortile.sock -m '{"State":"workspaces"}'
# terminal 1 (output)
Received 'workspaces' with tiling 'enabled = true' on 'desktop = 0' and 'screen = 1' with 'layout = 2'
The listening terminal 1
will also output all the internal commands executed by cortile.
what i mean is to check disable and enable state by script, based on that i can do things, like new toggle(that toggle bw disable+fullscreen and enable+right layout) , or do things like exit with fullscreen to avoid the affect of tiling after exit etc. to try to do check disable or enable state :
#!/bin/bash
FLAG_FILE="/tmp/cortile_flag"
# Create the file with initial state if it doesn't exist
[ -e "$FLAG_FILE" ] || echo "disable" > "$FLAG_FILE"
# Read the current state from the file
flag=$(cat "$FLAG_FILE")
if [ "$flag" == "enable" ]; then
# Disable
sleep 1
echo '{"Action":"layout_fullscreen"}' | nc -U /tmp/cortile.sock.in
sleep 1
echo '{"Action":"disable"}' | nc -U /tmp/cortile.sock.in
else
# Enable
echo '{"Action":"enable"}' | nc -U /tmp/cortile.sock.in
sleep 1
echo '{"Action":"layout_vertical_right"}' | nc -U /tmp/cortile.sock.in
fi
# Toggle the state by updating the flag file (moved to the end)
[ "$flag" == "enable" ] && echo "disable" > "$FLAG_FILE" || echo "enable" > "$FLAG_FILE"
that script worked with me, but i think may be easy check with socket communication, i'll try to understand it
You could use the listen.sh
script as a template and write the flag file somewhere starting here.
Your solution will work if you only use the script to execute commands (e.g. not using cortile key-bindings at all). Also keep in mind that the enable
state of cortile is per workspace and per screen. So depending on you setup you would need n = num_workspaces * num_screens
numbers of flag files.
There is another hacky way to execute scripts. Any command not recognized by cortile will be executed as external command. Therefore, something like this will also work:
# config.toml
"/tmp/my_script.sh enable" = "Control-Shift-A"
"/tmp/my_script.sh disable" = "Control-Shift-B"
# my_script.sh
if [ "$1" == "disable" ]; then
# Disable
echo '{"Action":"layout_fullscreen"}' | nc -U /tmp/cortile.sock.in
echo '{"Action":"disable"}' | nc -U /tmp/cortile.sock.in
else
# Enable
echo '{"Action":"enable"}' | nc -U /tmp/cortile.sock.in
echo '{"Action":"layout_vertical_right"}' | nc -U /tmp/cortile.sock.in
fi
i tried the hacky way, and make it toggle based on flag(create empty file and delete it)
#!/bin/bash
FLAG_FILE="/tmp/cortile_flag"
# Toggle Cortile state
if [ -e "$FLAG_FILE" ]; then
echo '{"Action":"layout_fullscreen"}' | nc -U /tmp/cortile.sock.in
sleep 1
echo '{"Action":"disable"}' | nc -U /tmp/cortile.sock.in
rm "$FLAG_FILE"
else
echo '{"Action":"enable"}' | nc -U /tmp/cortile.sock.in
echo '{"Action":"layout_vertical_right"}' | nc -U /tmp/cortile.sock.in
touch "$FLAG_FILE"
fi
config.toml "/home/eid/Desktop/toggle.sh toggle"="Control-Shift-KP_0"
sorry, i wish if i can know what disable does in cortile as command , i mean it's not kill, it's stop?