Skip to content

Instantly share code, notes, and snippets.

View neilbags's full-sized avatar

Neil McKenzie neilbags

View GitHub Profile
@neilbags
neilbags / sway-rename-workspace.sh
Created June 14, 2024 07:16
Rename a workspace dynamically in sway using wofi for input
#!/bin/bash
# Get the current workspace number
current_workspace=$(swaymsg -t get_workspaces | jq -r '.[] | select(.focused) | .name')
# Extract the number from the current workspace name
workspace_number=$(echo $current_workspace | grep -o '^[0-9]*')
new_name=`wofi --dmenu --prompt='Workspace Name:'`
@neilbags
neilbags / gist:1e4bac6d0cdca2a0ec1e0307f133109c
Created March 9, 2023 00:20
dbus-monitor chrome youtube
signal time=1678321200.584405 sender=:1.141 -> destination=(null destination) serial=14 path=/org/mpris/MediaPlayer2; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
string "org.mpris.MediaPlayer2.Player"
array [
dict entry(
string "PlaybackStatus"
variant string "Playing"
)
]
array [
]
@neilbags
neilbags / i3-move-to-empty.py
Created October 16, 2022 00:17
Move i3 container to next empty workspace, and follow
#!/usr/bin/python3
import json, subprocess
output = subprocess.check_output(['i3-msg', '-t', 'get_workspaces'])
workspaces = json.loads(output)
next_num = next(i for i in range(1, 100) if not [ws for ws in workspaces if ws['num'] == i])
subprocess.call(['i3-msg', f'move container to workspace number {next_num}; workspace {next_num}'])
@neilbags
neilbags / iso2unix
Created October 11, 2022 22:35
iso2unix
#!/usr/bin/python3
import fileinput
import dateutil.parser as dp
for line in fileinput.input():
print(dp.parse(line).timestamp())
Docker image: ghcr.io/home-assistant/home-assistant:stable
Pending updates
HACS
You are running version 1.15.2, version 1.24.3 is available
Sonoff LAN
You are running version v2.4.6, version v2.4.3 is available
homeassistant | 2022-04-07 18:29:45 INFO (MainThread) [backoff] Backing off async_download_file(...) for 0.8s (TypeError: timeout() got an unexpected keyword argument 'loop')
homeassistant | 2022-04-07 18:29:46 INFO (MainThread) [backoff] Backing off async_download_file(...) for 0.2s (TypeError: timeout() got an unexpected keyword argument 'loop')
@neilbags
neilbags / 50-wireguard.sh
Created October 27, 2021 02:04
/etc/NetworkManager/dispatcher.d/50-wireguard
#!/bin/sh -e
WLAN_DEV=wlan0
HOME_GATEWAY=192.168.2.1
WG_NAME=wg-home
if [ "$2" = "connectivity-change" ]; then
exit 0;
fi
if [ -z "$1" ]; then
@neilbags
neilbags / metallb-config.yml
Created January 23, 2021 00:08
metallb config
apiVersion: v1
kind: ConfigMap
metadata:
namespace: metallb-system
name: config
data:
config: |
address-pools:
- name: default
protocol: layer2
nodes:
- address: 10.0.0.11
user: ubuntu
role:
- controlplane
- etcd
- worker
- address: 10.0.0.12
user: ubuntu
role: