summaryrefslogtreecommitdiff
path: root/home/ebisu
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-13 23:52:46 -0700
committerFuwn <[email protected]>2024-10-13 23:52:46 -0700
commit76d0b38c3072ad17b993cfadfc399373b8cb0aa9 (patch)
treea40f5ba73d46c3fafaedfdb207dcc078d0e6cb8e /home/ebisu
parentdevenv: enable extra git hooks (diff)
downloadnixos-config-76d0b38c3072ad17b993cfadfc399373b8cb0aa9.tar.xz
nixos-config-76d0b38c3072ad17b993cfadfc399373b8cb0aa9.zip
flake: treefmt
Diffstat (limited to 'home/ebisu')
-rw-r--r--home/ebisu/kansai/fortune/desktop/hyprland/hyprland/scripts/common.sh200
1 files changed, 100 insertions, 100 deletions
diff --git a/home/ebisu/kansai/fortune/desktop/hyprland/hyprland/scripts/common.sh b/home/ebisu/kansai/fortune/desktop/hyprland/hyprland/scripts/common.sh
index 25be5b6..325fd90 100644
--- a/home/ebisu/kansai/fortune/desktop/hyprland/hyprland/scripts/common.sh
+++ b/home/ebisu/kansai/fortune/desktop/hyprland/hyprland/scripts/common.sh
@@ -5,142 +5,142 @@
# . "${HOME}/.config/hypr/hyprland/scripts/common.sh"
get_hyprctl_monitors() {
- hyprctl monitors -j || true
+ hyprctl monitors -j || true
}
get_hyprctl_workspaces() {
- hyprctl workspaces -j || true
+ hyprctl workspaces -j || true
}
get_focused_monitor() {
- (get_hyprctl_monitors || true) |
- jq -r '.[] | select(.focused) | .name'
+ (get_hyprctl_monitors || true) |
+ jq -r '.[] | select(.focused) | .name'
}
get_active_monitor() {
- get_focused_monitor
+ get_focused_monitor
}
get_active_workspaces() {
- local monitor=$1
+ local monitor=$1
- (get_hyprctl_workspaces || true) |
- (jq -r ".[] | select(.monitor == \"${monitor}\") | .id" || true) |
- grep -v '-'
+ (get_hyprctl_workspaces || true) |
+ (jq -r ".[] | select(.monitor == \"${monitor}\") | .id" || true) |
+ grep -v '-'
}
get_active_workspace() {
- local monitor=$1
+ local monitor=$1
- (get_hyprctl_monitors || true) |
- jq -r ".[] | select(.name == \"${monitor}\") | .activeWorkspace.id"
+ (get_hyprctl_monitors || true) |
+ jq -r ".[] | select(.name == \"${monitor}\") | .activeWorkspace.id"
}
get_current_workspace() {
- (hyprctl activeworkspace -j || true) |
- jq -r ".id"
+ (hyprctl activeworkspace -j || true) |
+ jq -r ".id"
}
get_empty_workspace() {
- local monitor=$1
+ local monitor=$1
- (hyprctl workspaces -j || true) |
- (jq -r ".[] | select(.monitor == \"${monitor}\" and .windows == 0) | .id" || true) |
- (grep -v '-' || true) |
- head -n 1
+ (hyprctl workspaces -j || true) |
+ (jq -r ".[] | select(.monitor == \"${monitor}\" and .windows == 0) | .id" || true) |
+ (grep -v '-' || true) |
+ head -n 1
}
get_workspace_client_count() {
- local workspace=$1
+ local workspace=$1
- (hyprctl workspaces -j || true) | jq -r ".[] | select(.id == ${workspace}) | .windows"
+ (hyprctl workspaces -j || true) | jq -r ".[] | select(.id == ${workspace}) | .windows"
}
get_relative_target_workspace() {
- target_workspace=$1
- workspace=0
-
- case "$(get_focused_monitor)" in
- "HDMI-A-2")
- workspace=$((target_workspace + 10))
- ;;
- "DP-2")
- workspace=${target_workspace}
- ;;
- "DP-1")
- workspace=$((target_workspace + 20))
- ;;
- *)
- exit 1
- ;;
- esac
-
- echo "${workspace}"
+ target_workspace=$1
+ workspace=0
+
+ case "$(get_focused_monitor)" in
+ "HDMI-A-2")
+ workspace=$((target_workspace + 10))
+ ;;
+ "DP-2")
+ workspace=${target_workspace}
+ ;;
+ "DP-1")
+ workspace=$((target_workspace + 20))
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+
+ echo "${workspace}"
}
is_monitor_fullscreen() {
- monitor=$1
+ monitor=$1
- (hyprctl workspaces -j || true) |
- jq -r ".[] | select(.monitor == \"${monitor}\") | select(.id == $(get_active_workspace "${monitor}" || true)) | .hasfullscreen"
+ (hyprctl workspaces -j || true) |
+ jq -r ".[] | select(.monitor == \"${monitor}\") | select(.id == $(get_active_workspace "${monitor}" || true)) | .hasfullscreen"
}
get_relative_target_monitor() {
- direction=$1
- ignore_fullscreen=${2:-0}
-
- case $(get_focused_monitor) in
- "HDMI-A-2")
- if [[ "${direction}" == "right" ]]; then
- target_monitor="DP-2"
- else
- target_monitor="DP-1"
- fi
- ;;
- "DP-2")
- if [[ "${direction}" == "right" ]]; then
- target_monitor="DP-1"
- else
- target_monitor="HDMI-A-2"
- fi
- ;;
- "DP-1")
- if [[ "${direction}" == "left" ]]; then
- target_monitor="DP-2"
- else
- target_monitor="HDMI-A-2"
- fi
- ;;
- *)
- exit 1
- ;;
- esac
-
- if [[ "$(is_monitor_fullscreen "${target_monitor}")" == "true" && "${ignore_fullscreen}" = 0 ]]; then
- case $target_monitor in
- "HDMI-A-2")
- if [[ "$direction" == "right" ]]; then
- target_monitor="DP-2"
- else
- target_monitor="DP-1"
- fi
- ;;
- "DP-2")
- if [[ "$direction" == "right" ]]; then
- target_monitor="DP-1"
- else
- target_monitor="HDMI-A-2"
- fi
- ;;
- "DP-1")
- if [[ "$direction" == "left" ]]; then
- target_monitor="DP-2"
- else
- target_monitor="HDMI-A-2"
- fi
- ;;
- esac
- fi
-
- echo "${target_monitor}"
+ direction=$1
+ ignore_fullscreen=${2:-0}
+
+ case $(get_focused_monitor) in
+ "HDMI-A-2")
+ if [[ ${direction} == "right" ]]; then
+ target_monitor="DP-2"
+ else
+ target_monitor="DP-1"
+ fi
+ ;;
+ "DP-2")
+ if [[ ${direction} == "right" ]]; then
+ target_monitor="DP-1"
+ else
+ target_monitor="HDMI-A-2"
+ fi
+ ;;
+ "DP-1")
+ if [[ ${direction} == "left" ]]; then
+ target_monitor="DP-2"
+ else
+ target_monitor="HDMI-A-2"
+ fi
+ ;;
+ *)
+ exit 1
+ ;;
+ esac
+
+ if [[ "$(is_monitor_fullscreen "${target_monitor}")" == "true" && ${ignore_fullscreen} == 0 ]]; then
+ case $target_monitor in
+ "HDMI-A-2")
+ if [[ $direction == "right" ]]; then
+ target_monitor="DP-2"
+ else
+ target_monitor="DP-1"
+ fi
+ ;;
+ "DP-2")
+ if [[ $direction == "right" ]]; then
+ target_monitor="DP-1"
+ else
+ target_monitor="HDMI-A-2"
+ fi
+ ;;
+ "DP-1")
+ if [[ $direction == "left" ]]; then
+ target_monitor="DP-2"
+ else
+ target_monitor="HDMI-A-2"
+ fi
+ ;;
+ esac
+ fi
+
+ echo "${target_monitor}"
}