Skip to content

Instantly share code, notes, and snippets.

@rifazn
rifazn / dark-toggle.sh
Last active September 19, 2021 14:24
A shell script to toggle between light and dark variants of a GTK theme.
#!/bin/sh
# A small POSIX compliant script to toggle between dark and light variant
# of a theme for GNOME based desktops.
# Copyright (C) 2021 Rifaz Nahiyan
# This code is licensed under the MIT License.
# View the license in its entirety at: https://opensource.org/licenses/MIT
get_current_theme () {
org.gnome.desktop.wm.keybindings switch-group ['<Super>Above_Tab', '<Alt>Above_Tab']
org.gnome.desktop.wm.keybindings begin-resize ['<Alt>F8']
org.gnome.desktop.wm.keybindings switch-to-workspace-7 []
org.gnome.desktop.wm.keybindings begin-move ['<Alt>F7']
org.gnome.desktop.wm.keybindings move-to-side-w []
org.gnome.desktop.wm.keybindings move-to-corner-nw []
org.gnome.desktop.wm.keybindings move-to-workspace-10 []
org.gnome.desktop.wm.keybindings move-to-workspace-6 []
org.gnome.desktop.wm.keybindings move-to-workspace-right ['<Control><Shift><Alt>Right']
org.gnome.desktop.wm.keybindings always-on-top []
@christian-eriksson
christian-eriksson / window_finder_bash.sh
Last active January 24, 2022 23:23
Script using xprop and grep to look for a provided (as cmd-line argument) WM_CLASS. The script identifies a window which has a grandparent with 2 children somewhere in it's tree.
#!/bin/bash
# The script is looking for a window with a given WM_CLASS property. The window
# will be attached to the root node (R in the graph below), the root note is
# what you get from 'xprop -root'. There are two different types of windows with
# the same WM_CLASS (Q and W) but their tree structures are different. However,
# the tree structure of the two windows are different as seen in the graph
# below.
#
# R
@gdamjan
gdamjan / 50-micmute-led.rules
Last active January 28, 2022 12:17
Udev rules etc...
# set the microphone mute led to glow when capture is enabled
ACTION=="add",SUBSYSTEM=="sound",KERNEL=="ctl-led",ATTR{mic/mode}="follow-route"
@NuxRo
NuxRo / msteams.lua
Created March 13, 2020 13:46
Apply Windows Decorations to Microsoft Teams
-- MS Teams on Linux doesn't show the window decorations, let's fix that
-- drop this in your devilspie2 folder, typically ~/.config/devilspie2 and start devilspie2
if string.match(get_window_name(), "Microsoft Teams") then
decorate_window();
end
@xoner
xoner / movewin.sh
Created June 18, 2012 06:39
Move windows between monitors in a multimunitor setup in linux
#!/bin/bash
#++++++++++++++++
# Monitor Switch
#
# Moves currently focused window from one monitor to the other.
# Designed for a system with two monitors.
# Script should be triggered using a keyboard shortcut.
# If the window is maximized it should remain maximized after being moved.
# If the window is not maximized it should retain its current size, unless
# height is too large for the destination monitor, when it will be trimmed.
# Remap express keys of XP-PEN Artist22E Pro_V3
# Input device ID: bus 0x03 vendor 0x28bd product 0x900b version 0x100
#
# place me into /etc/udev/hwdb.d/10-xp-pen-keyboard.hwdb
# and run:
# sudo udevadm hwdb --update; sudo udevadm trigger
#
# print list of key codes:
# sed -n '/KEY_/{s/.*KEY_\([A-Za-z0-9_]\+\).*/\L\1/g;p}' /usr/include/linux/input-event-codes.h | less
#
@adnan360
adnan360 / ibus-cli.md
Last active June 15, 2022 02:22
Control ibus layouts right from Linux terminal

Control ibus layouts right from Linux terminal

Ibus is an input tool that allows to type in many languages and keyboard layouts under GNU/Linux. Being able to control ibus layouts is extremely helpful on minimal desktop environments and window managers, like i3, sway etc. You can utilize the learnings of this on Waybar, Polybar etc.

First run the ibus daemon (if not already running):

ibus-daemon -xdr
@luckman212
luckman212 / frontapp.py
Created May 10, 2019 05:15
simple python script that prints the frontmost (aka focused) app
#!/usr/bin/python
# references
# https://developer.apple.com/documentation/appkit/nsworkspace
# https://bmn.name/post/2016/05/28/current-osx-app/
# https://stackoverflow.com/questions/28815863/how-to-get-active-window-title-using-python-in-mac
# https://apple.stackexchange.com/questions/123730/is-there-a-way-to-detect-what-program-is-stealing-focus-on-my-mac/
try:
from AppKit import NSWorkspace
# app: Xdotool
# user input
direction = 'down' # 'up' or 'down' or 'left' or 'right'
# end of user input
time.sleep(1)
system.exec_command("xdotool key space")
time.sleep(1)
activeApp = window.get_active_class()
if activeApp == 'nemo.Nemo' or activeApp == 'nemo-desktop.Nemo-desktop':
if direction == 'up':