moved all desktop utils into this repo
This commit is contained in:
parent
cd7e93374e
commit
2241d30a86
28 changed files with 151 additions and 45 deletions
|
@ -1,23 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Get the list of connected Bluetooth devices
|
||||
devices=$(bluetoothctl devices Connected | awk '{print $2}')
|
||||
name[0]=""
|
||||
battery[0]=0
|
||||
i=0
|
||||
# Iterate through each device and get its name and battery percentage
|
||||
for device in $devices; do
|
||||
|
||||
# Get the device info using bluetoothctl
|
||||
info=$(bluetoothctl info "$device")
|
||||
|
||||
# Extract the name and battery percentage from the device info
|
||||
name[i]=$(echo "$info" | awk '/Name:/ {for(i=2; i<=NF; i++) printf "%s ", $i;}')
|
||||
battery[i]=$(echo "$info" | awk '/Battery Percentage:/ {print $4}' | tr -d '()')
|
||||
|
||||
|
||||
|
||||
((i=i+1))
|
||||
done
|
||||
|
||||
echo '{"name":"'"${name[0]}"'","battery":"'"${battery[0]}"'"}'
|
|
@ -1,10 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
FILE_TO_WATCH="/sys/class/backlight/intel_backlight/brightness" # Replace with the actual file path
|
||||
brightness_file="/sys/class/backlight/intel_backlight/brightness"
|
||||
min_brightness=1
|
||||
max_brightness=96000
|
||||
|
||||
cat "$FILE_TO_WATCH"
|
||||
# Check if an argument is provided
|
||||
if [[ -z $1 ]]; then
|
||||
# echo "Error: Number argument is missing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while true; do
|
||||
inotifywait -e modify "$FILE_TO_WATCH"
|
||||
cat "$FILE_TO_WATCH"
|
||||
done
|
||||
# Retrieve the argument value
|
||||
number_to_add=$1
|
||||
|
||||
# Validate if the argument is a number
|
||||
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
|
||||
# echo "Error: Invalid number argument."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Read the current brightness value from the file
|
||||
current_brightness=$(cat "$brightness_file")
|
||||
|
||||
# Add the desired number to the current brightness
|
||||
new_brightness=$((current_brightness + number_to_add))
|
||||
|
||||
# Enforce minimum and maximum brightness values
|
||||
if (( new_brightness < min_brightness )); then
|
||||
new_brightness=$min_brightness
|
||||
elif (( new_brightness > max_brightness )); then
|
||||
new_brightness=$max_brightness
|
||||
fi
|
||||
|
||||
# Write the new brightness value back to the file
|
||||
echo "$new_brightness" >> "$brightness_file"
|
8
scripts/clients/.idea/.gitignore
generated
vendored
8
scripts/clients/.idea/.gitignore
generated
vendored
|
@ -1,8 +0,0 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
2
scripts/clients/.idea/clients.iml
generated
2
scripts/clients/.idea/clients.iml
generated
|
@ -1,2 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module classpath="CMake" type="CPP_MODULE" version="4" />
|
4
scripts/clients/.idea/misc.xml
generated
4
scripts/clients/.idea/misc.xml
generated
|
@ -1,4 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CMakeWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
|
||||
</project>
|
8
scripts/clients/.idea/modules.xml
generated
8
scripts/clients/.idea/modules.xml
generated
|
@ -1,8 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/clients.iml" filepath="$PROJECT_DIR$/.idea/clients.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -1,18 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(clients)
|
||||
|
||||
# Set C++ standard
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
include_directories(lib)
|
||||
|
||||
set(SOURCES
|
||||
src/main.cpp
|
||||
)
|
||||
|
||||
add_executable(clients ${SOURCES})
|
||||
|
||||
|
||||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/build)
|
File diff suppressed because it is too large
Load diff
|
@ -1,294 +0,0 @@
|
|||
#include <string>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
json workspacesOutput;
|
||||
std::map<std::string, std::string> iconMap;
|
||||
std::map<int, std::string> monitorMap;
|
||||
|
||||
std::map<std::string, int> specialWorkspaceMap = {
|
||||
{"special:ctrl", 0},
|
||||
{"special:alt", 1},
|
||||
{"special:altgr", 2},
|
||||
{"special:strg", 3}
|
||||
};
|
||||
|
||||
|
||||
/*json workspacesOutput = json::parse(R"(
|
||||
[
|
||||
"normal":
|
||||
{
|
||||
"activeOn": str
|
||||
"icon": str
|
||||
"id": int
|
||||
"occupied": int
|
||||
},
|
||||
"special":
|
||||
{
|
||||
"activeOn": str
|
||||
"icon": str
|
||||
"id": str
|
||||
"occupied": int
|
||||
}
|
||||
]
|
||||
|
||||
)");*/
|
||||
|
||||
|
||||
std::string command(std::string inputCommand)
|
||||
{
|
||||
const char* command = inputCommand.c_str();
|
||||
char buffer[128];
|
||||
std::string result;
|
||||
FILE* pipe = popen(command, "r");
|
||||
|
||||
if(!pipe)
|
||||
{
|
||||
std::cerr << "No pipe opened" << std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
while(!feof(pipe))
|
||||
{
|
||||
if(fgets(buffer, 128, pipe) != NULL)
|
||||
{
|
||||
result += buffer;
|
||||
}
|
||||
}
|
||||
|
||||
pclose(pipe);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void generateIconMap()
|
||||
{
|
||||
json clients = json::parse(command("hyprctl clients -j"));
|
||||
|
||||
for (const json& client : clients)
|
||||
{
|
||||
std::string pid = std::to_string(static_cast<int>(client["pid"]));
|
||||
|
||||
if (pid == "-1")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
std::string initClass = client["initialClass"];
|
||||
if (initClass == "")
|
||||
{
|
||||
initClass = "aguiienagi";
|
||||
}
|
||||
|
||||
//TODO unjank
|
||||
|
||||
std::string cmd ="cd /home/willifan/.config/eww/scripts/ && ./test.sh ";
|
||||
std::string test = std::string("cd /home/willifan/.config/eww/scripts/ && ./test.sh ") + initClass + " " + pid;
|
||||
|
||||
|
||||
iconMap[client["address"]] = command(test);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void generateMonitorMap()
|
||||
{
|
||||
json monitorsInput = json::parse(command("hyprctl monitors -j"));
|
||||
|
||||
monitorMap.clear();
|
||||
|
||||
for (const json& monitor : monitorsInput)
|
||||
{
|
||||
monitorMap[monitor["activeWorkspace"]["id"]] = std::to_string(static_cast<int>(monitor["id"]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
json getWorkspace(json workspaceInput)
|
||||
{
|
||||
json workspaceOutput;
|
||||
|
||||
if (workspaceInput["id"] > 0) //normal workspace
|
||||
{
|
||||
workspaceOutput["id"] = workspaceInput["id"];
|
||||
}
|
||||
else //special workspace
|
||||
{
|
||||
workspaceOutput["id"] = workspaceInput["name"];
|
||||
}
|
||||
|
||||
workspaceOutput["activeOn"] = monitorMap[workspaceInput["id"]];
|
||||
workspaceOutput["occupied"] = workspaceInput["windows"];
|
||||
|
||||
if (!(workspaceInput["lastwindow"] == "0x0")) //workspace not empty
|
||||
{
|
||||
workspaceOutput["icon"] = iconMap[workspaceInput["lastwindow"]];
|
||||
}
|
||||
else //workspace empty
|
||||
{
|
||||
workspaceOutput["icon"] = "";
|
||||
}
|
||||
|
||||
return workspaceOutput;
|
||||
}
|
||||
|
||||
//TODO fix special workspaces
|
||||
void getAllWorkspaces()
|
||||
{
|
||||
json workspacesInput = json::parse(command("hyprctl workspaces -j"));
|
||||
|
||||
int specialIndex = 4; //next index after specialWorkspaceMap
|
||||
|
||||
for(const auto& workspace : workspacesInput)
|
||||
{
|
||||
if(workspace["id"] >= 1 && workspace["id"] <= 9)
|
||||
{
|
||||
int index = workspace["id"].get<int>() - 1;
|
||||
|
||||
workspacesOutput[index]["normal"].clear();
|
||||
workspacesOutput[index]["normal"] = getWorkspace(workspace);
|
||||
}
|
||||
else if (std::string(workspace["name"]).find("special:") == 0)
|
||||
{
|
||||
std::string name = workspace["name"];
|
||||
|
||||
int currentIndex;
|
||||
|
||||
if (specialWorkspaceMap.contains(name))
|
||||
{
|
||||
currentIndex = specialWorkspaceMap[name];
|
||||
}
|
||||
else
|
||||
{
|
||||
currentIndex = specialIndex;
|
||||
specialIndex++;
|
||||
}
|
||||
workspacesOutput[currentIndex]["special"].clear();
|
||||
workspacesOutput[currentIndex]["special"] = getWorkspace(workspace);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//TODO optimize whatever
|
||||
|
||||
|
||||
void handle(std::string message)
|
||||
{
|
||||
/*
|
||||
Call generateMonitorMap when workspaces change their monitor
|
||||
Call generateIconMap when clients are opened or closed
|
||||
*/
|
||||
|
||||
if (message.find("workspacev2>>") == 0) //emitted ONCE when switching to a workspace
|
||||
{
|
||||
generateMonitorMap();
|
||||
getAllWorkspaces();
|
||||
std::cout << workspacesOutput << std::endl;
|
||||
}
|
||||
else if (message.find("moveworkspacev2>>") == 0) //emitted when a workspace switches to another monitor, TWICE when swaping
|
||||
{
|
||||
generateMonitorMap();
|
||||
getAllWorkspaces();
|
||||
std::cout << workspacesOutput << std::endl;
|
||||
}
|
||||
else if (message.find("openwindow>>") == 0) //emitted ONCE when a new client is created
|
||||
{
|
||||
generateIconMap();
|
||||
getAllWorkspaces();
|
||||
std::cout << workspacesOutput << std::endl;
|
||||
}
|
||||
else if (message.find("closewindow>>") == 0) //emitted ONCE when a client gets closed
|
||||
{
|
||||
generateIconMap();
|
||||
getAllWorkspaces();
|
||||
std::cout << workspacesOutput << std::endl;
|
||||
}
|
||||
else if (message.find("movewindowv2>>") == 0) //emitted ONCE when a client changes its workspace
|
||||
{
|
||||
getAllWorkspaces();
|
||||
std::cout << workspacesOutput << std::endl;
|
||||
}
|
||||
else if (message.find("activewindow>>v2") == 0) //emitted ONCE when focus changes to another client
|
||||
{
|
||||
getAllWorkspaces();
|
||||
std::cout << workspacesOutput << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
{
|
||||
generateIconMap();
|
||||
generateMonitorMap();
|
||||
getAllWorkspaces();
|
||||
std::cout << workspacesOutput << std::endl;
|
||||
|
||||
std::string socketPath = "/tmp/hypr/" + std::string(std::getenv("HYPRLAND_INSTANCE_SIGNATURE")) + "/.socket2.sock";
|
||||
|
||||
|
||||
// Create a socket
|
||||
int sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd == -1) {
|
||||
std::cerr << "Error: Failed to create socket\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Define the address of the IPC socket
|
||||
struct sockaddr_un addr;
|
||||
addr.sun_family = AF_UNIX;
|
||||
strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path) - 1);
|
||||
|
||||
// Connect to the IPC socket
|
||||
if (connect(sockfd, (struct sockaddr*)&addr, sizeof(addr)) == -1) {
|
||||
std::cerr << "Error: Failed to connect to IPC socket\n";
|
||||
close(sockfd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Receive and print messages from the IPC socket
|
||||
char buffer[1024];
|
||||
ssize_t bytes_received;
|
||||
while ((bytes_received = recv(sockfd, buffer, sizeof(buffer), 0)) > 0) {
|
||||
|
||||
std::string message = std::string(buffer, bytes_received);
|
||||
|
||||
std::istringstream iss(message);
|
||||
std::string messageLine;
|
||||
|
||||
while(std::getline(iss, messageLine)){
|
||||
handle(messageLine);
|
||||
}
|
||||
|
||||
}
|
||||
if (bytes_received == -1) {
|
||||
std::cerr << "Error: Failed to receive message\n";
|
||||
}
|
||||
|
||||
// Close the socket
|
||||
close(sockfd);
|
||||
|
||||
return 0;
|
||||
}
|
7
scripts/idle.sh
Executable file
7
scripts/idle.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
if [[ $(acpi -a | awk '{print $3}') == "on-line" ]]; then
|
||||
swaylock
|
||||
else
|
||||
systemctl suspend-then-hibernate
|
||||
fi
|
7
scripts/lock.sh
Executable file
7
scripts/lock.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
swaylock &
|
||||
|
||||
sleep 0.1
|
||||
|
||||
hyprctl dispatch dpms off
|
|
@ -1,6 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
status=$(playerctl status)
|
||||
name=$(playerctl metadata title)
|
||||
|
||||
echo '{"status":"'"$status"'","name":"'"$name"'"}'
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
|
||||
unset id name horizontal vertical scale activeWorkspace
|
||||
|
||||
i=0
|
||||
|
||||
while read -r k n h v s t; do
|
||||
id[i]="$k"
|
||||
name[i]="$n"
|
||||
horizontal[i]="$h"
|
||||
vertical[i]="$v"
|
||||
scale[i]="$s"
|
||||
if [[ $((t%2)) == 1 ]]; then
|
||||
temp=${vertical[$i]}
|
||||
vertical[i]=${horizontal[$i]}
|
||||
horizontal[i]=$temp
|
||||
fi
|
||||
((i=i+1))
|
||||
done < <(hyprctl monitors -j | jq -r '.[]|"\(.id) \(.name) \(.width) \(.height) \(.scale) \(.transform)"')
|
||||
|
||||
echo -n "" > "$XDG_CONFIG_HOME"/eww/bar.yuck
|
||||
|
||||
eww close-all
|
||||
|
||||
sleep 2
|
||||
|
||||
for ((i = 0; i < ${#id[@]}; i++)); do
|
||||
scale_value=$(echo "${scale[$i]}" | bc -l)
|
||||
|
||||
new_width_float=$(echo "(${horizontal[$i]} / ${scale_value}) -10" | bc)
|
||||
|
||||
new_width=$(echo "$new_width_float / 1" | bc)
|
||||
|
||||
monitorID=$(xrandr --listactivemonitors | grep +"${name[$i]}" | awk '{sub(/.$/,"",$1); print $1}')
|
||||
|
||||
eww open bar --id bar"${monitorID}" --arg monitor="${monitorID}" --arg width="${new_width}" --arg height=30
|
||||
sleep 2
|
||||
done
|
|
@ -1,43 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
ethernet() {
|
||||
name="Wired"
|
||||
image="ethernet"
|
||||
}
|
||||
|
||||
wifi() {
|
||||
wifiInfo=$(nmcli -t -f active,ssid,signal device wifi list)
|
||||
|
||||
signalStrength=$(awk -F: '/yes:/ {print $3}' <<< $wifiInfo)
|
||||
name=$(awk -F: '/yes:/ {print $2}' <<< $wifiInfo)
|
||||
|
||||
if [[ $signalStrength -ge 70 ]]; then
|
||||
image="wifiHigh"
|
||||
elif [[ $signalStrength -ge 60 ]]; then
|
||||
image="wifiMedium"
|
||||
elif [[ $signalStrength -ge 40 ]]; then
|
||||
image="wifiLow"
|
||||
else
|
||||
image="wifiVeryLow"
|
||||
fi
|
||||
}
|
||||
|
||||
while true; do
|
||||
name="No Connection"
|
||||
image="n.A."
|
||||
|
||||
networkInfo=$(nmcli -f NAME,TYPE connection show --active | awk '!/loopback/ && NR > 1')
|
||||
|
||||
if [[ $(awk '/wifi/' <<< "$networkInfo") ]]; then
|
||||
wifi
|
||||
fi
|
||||
|
||||
if [[ $(awk '/ethernet/' <<< "$networkInfo") ]]; then
|
||||
ethernet
|
||||
fi
|
||||
|
||||
|
||||
echo '{"name":"'"$name"'","image":"'"$image"'"}'
|
||||
|
||||
sleep 2
|
||||
done
|
10
scripts/scale.sh
Executable file
10
scripts/scale.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
while read -r f s; do
|
||||
if [[ $f == true && $(awk -v s="$s" 'BEGIN{ if (s > 1.5) print 1; else print 0; }') == 1 ]]; then
|
||||
export GDK_SCALE=2
|
||||
export QT_SCALE_FACTOR=2
|
||||
fi
|
||||
done < <(hyprctl monitors -j | jq -r '.[]|"\(.focused) \(.scale)"')
|
||||
|
||||
wofi --show drun
|
0
scripts/startup.sh
Normal file
0
scripts/startup.sh
Normal file
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
getIcon() {
|
||||
local desktop=""
|
||||
|
||||
# Search for desktop files by WM class
|
||||
if [ -n "$1" ]; then
|
||||
desktop=$(grep -l "StartupWMClass.*$1$" /run/current-system/sw/share/applications/*.desktop)
|
||||
[ -z "$desktop" ] && desktop=$(grep -Pl "Name\s*=\s*$1$" /run/current-system/sw/share/applications/*.desktop)
|
||||
[ -z "$desktop" ] && desktop=$(ls /run/current-system/sw/share/applications/"${1}".desktop 2>/dev/null)
|
||||
fi
|
||||
|
||||
# If not found by WM class, search by process name
|
||||
if [ -z "$desktop" ] && [ -n "$2" ]; then
|
||||
process=$(ps -p "${2}" -o comm=)
|
||||
desktop=$(grep -Pl "$process" /run/current-system/sw/share/applications/*.desktop)
|
||||
[ -n "$desktop" ]
|
||||
fi
|
||||
|
||||
# If not found by WM class or process name, search by name or description
|
||||
if [ -z "$desktop" ] && [ -n "$1" ]; then
|
||||
desktop=$(grep -Pl "$1" /run/current-system/sw/share/applications/*.desktop)
|
||||
fi
|
||||
|
||||
echo "$desktop"
|
||||
}
|
||||
|
||||
desktop=$(getIcon "$1" "$2")
|
||||
if [ -n "$desktop" ]; then
|
||||
desktop=$(echo "$desktop" | awk 'NR==1')
|
||||
icon=$(awk -F'[[:space:]]*=[[:space:]]*' '/Icon[[:space:]]*=/ && !seen[$2]++ {print $2; exit}' "$desktop")
|
||||
echo -n "${icon}.svg"
|
||||
fi
|
|
@ -1,24 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
generate() {
|
||||
message=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
|
||||
volume=$(awk '{print $2 * 100}' <<< "$message")
|
||||
min_volume="0"
|
||||
max_volume="100"
|
||||
|
||||
if [[ $(awk '{print $3}' <<< "$message") == "[MUTED]" ]]; then
|
||||
muted=1
|
||||
else
|
||||
muted=0
|
||||
fi
|
||||
# Check if an argument is provided
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Error: Number argument is missing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo '{"volume":"'"$volume"'","muted":"'"$muted"'"}'
|
||||
}
|
||||
# Retrieve the argument value
|
||||
number_to_add=$1
|
||||
|
||||
generate
|
||||
# Validate if the argument is a number
|
||||
if ! [[ $number_to_add =~ ^-?[0-9]+$ ]]; then
|
||||
echo "Error: Invalid number argument."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pactl subscribe | while read -r event; do
|
||||
if [[ "$event" == *"Event 'change'"* ]]; then
|
||||
|
||||
generate
|
||||
# Read the current brightness value from the file
|
||||
current_volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@ | awk '{print $2 * 100}')
|
||||
|
||||
fi
|
||||
done
|
||||
# Add the desired number to the current brightness
|
||||
new_volume=$((current_volume + number_to_add))
|
||||
|
||||
# Enforce minimum and maximum brightness values
|
||||
if (( new_volume < min_volume )); then
|
||||
new_volume=$min_volume
|
||||
elif (( new_volume > max_volume )); then
|
||||
new_volume=$max_volume
|
||||
fi
|
||||
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${new_volume}%"
|
||||
|
|
34
scripts/workspaces.sh
Executable file
34
scripts/workspaces.sh
Executable file
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Check if an argument is provided
|
||||
if [[ -z $1 ]]; then
|
||||
# echo "Error: Number argument is missing."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Retrieve the argument value
|
||||
new_workspace=$1
|
||||
|
||||
if [[ $new_workspace == special:* ]]; then
|
||||
hyprctl dispatch togglespecialworkspace "${new_workspace:8}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Validate if the argument is a number
|
||||
if ! [[ $new_workspace =~ ^-?[0-9]+$ ]]; then
|
||||
# echo "Error: Invalid number argument."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while read -r i a f;do
|
||||
workspace[$a]=$i
|
||||
if [[ $f == true ]]; then
|
||||
active=$i
|
||||
fi
|
||||
done < <(hyprctl monitors -j | jq -r '.[]|"\(.id) \(.activeWorkspace.id) \(.focused)"')
|
||||
|
||||
if [[ ${workspace[$new_workspace]} ]]; then
|
||||
hyprctl dispatch swapactiveworkspaces $active ${workspace[$new_workspace]}
|
||||
else
|
||||
hyprctl --batch "dispatch moveworkspacetomonitor $new_workspace $active ; dispatch workspace $new_workspace"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue