Skip to content

Instantly share code, notes, and snippets.

@lidgnulinux
lidgnulinux / get_cursor_coordinate_wayland.sh
Created February 5, 2024 02:32
How to get cursor's coordinate on wayland.
#!/bin/bash
# Dependencies :
# - slurp (https://wayland.emersion.fr/slurp/).
# - awk.
# - cut.
# - sed.
# - Wayland compositor with layer_shell support.
# How to use :
#!/bin/sh
seatd_start() {
/usr/local/bin/seatd -g seatd 2> /dev/null &
}
seatd_stop() {
/bin/killall seatd 2> /dev/null
}
#!/usr/bin/bash
menu=" Minimize\n Floating Toggle\n Window Shot\n Move Workspace\n Close"
swspc () {
wspc=$(wofi -d -W 15% --prompt="Move To Worspace" --lines=2); swaymsg move window to workspace $wspc
}
active=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused) | .rect | "\(.x),\(.y)"')
00:00:00.000 [INFO] [sway/main.c:338] Sway version 1.8
00:00:00.000 [INFO] [sway/main.c:339] wlroots version 0.16.0
00:00:00.004 [INFO] [sway/main.c:120] Linux LIDG 6.2.0-rc3 #1 SMP PREEMPT_DYNAMIC Tue Jan 10 14:32:39 WIB 2023 x86_64 Intel(R) Core(TM) i7-2620M CPU @ 2.70GHz GenuineIntel GNU/Linux
00:00:00.004 [INFO] [sway/main.c:136] Contents of /etc/os-release:
00:00:00.004 [INFO] [sway/main.c:120] NAME=Slackware
00:00:00.004 [INFO] [sway/main.c:120] VERSION="15.0"
00:00:00.004 [INFO] [sway/main.c:120] ID=slackware
00:00:00.004 [INFO] [sway/main.c:120] VERSION_ID=15.0
00:00:00.004 [INFO] [sway/main.c:120] PRETTY_NAME="Slackware 15.0 x86_64 (post 15.0 -current)"
00:00:00.004 [INFO] [sway/main.c:120] ANSI_COLOR="0;34"
# i3blocks configuration file
#
# The i3blocks man page describes the usage of the binary,
# and its website describes the configuration:
#
# https://vivien.github.io/i3blocks
# Global properties
separator=true
#!/bin/sh
jwq() {
jq -r 'recurse(.nodes[]?) | select(.name == "__i3_scratch").floating_nodes[].'$1', select(.name == "__i3_scratch").floating_nodes[].window_properties.title'
}
app_id=$(swaymsg -t get_tree | jwq app_id | grep -v null)
win_id=$(swaymsg -t get_tree | jwq id | grep -v null)
#!/usr/bin/bash
menu=" Minimize\n Floating Toggle\n Window Shot\n Close"
active=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?, .floating_nodes[]?) | select(.focused) | .rect | "\(.x),\(.y)"')
x_cord=$(echo "$active" | cut -d ',' -f 1)
y_cord=$(echo "$active" | sed -e 's/^.*,//g')
selected=$(echo -e $menu | wofi -d -x $(expr $x_cord + 10) -y $(expr $y_cord - 20) -W 10% --prompt="Window Menu" --lines 5 | awk '{print tolower ($2)}')
@lidgnulinux
lidgnulinux / toggle-desktop-sway
Created January 6, 2023 23:06
Toggle desktop for sway.
#!/usr/bin/bash
unminimize () {
swaymsg [app_id='.*'] focus
}
minimize () {
#
# Automatically generated file; DO NOT EDIT.
# Linux/x86 6.1.0-rc6 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="gcc (Debian 12.2.0-9) 12.2.0"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=120200
CONFIG_CLANG_VERSION=0
CONFIG_AS_IS_GNU=y
CONFIG_AS_VERSION=23900
/* This stylesheet is generated, DO NOT EDIT */
/* Copyright 2009, 2015 Red Hat, Inc.
*
* Portions adapted from Mx's data/style/default.css
* Copyright 2009 Intel Corporation
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
* version 2.1, as published by the Free Software Foundation.
*