more sway and some waybar
This commit is contained in:
parent
2ac99db38b
commit
93879b3ef7
21 changed files with 760 additions and 26 deletions
13
.config/sway/scripts/dnd.sh
Executable file
13
.config/sway/scripts/dnd.sh
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
case $1'' in
|
||||
'status')
|
||||
printf '{\"alt\":\"%s\",\"tooltip\":\"mode: %s\"}' $(makoctl mode | grep -q 'do-not-disturb' && echo dnd || echo default) $(makoctl mode | tail -1)
|
||||
;;
|
||||
'restore')
|
||||
makoctl restore
|
||||
;;
|
||||
'toggle')
|
||||
makoctl mode | grep 'do-not-disturb' && makoctl mode -r do-not-disturb || makoctl mode -a do-not-disturb
|
||||
;;
|
||||
esac
|
|
@ -20,7 +20,7 @@ notify() {
|
|||
}
|
||||
|
||||
if [ $status != 0 ]; then
|
||||
target_path=$(xdg-user-dir SCREENSHOT)
|
||||
target_path=$(xdg-user-dir SCREENSHOTS)
|
||||
timestamp=$(date +'recording_%Y%m%d-%H%M%S')
|
||||
|
||||
notify "Select a region to record" -t 1000
|
||||
|
|
15
.config/sway/scripts/scratchpad.sh
Executable file
15
.config/sway/scripts/scratchpad.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env sh
|
||||
tooltip=$(swaymsg -r -t get_tree | jq -r 'recurse(.nodes[]) | first(select(.name=="__i3_scratch")) | .floating_nodes | .[] | "\(.app_id) | \(.name)"')
|
||||
count=$(printf "%s" "$tooltip" | grep -c '^')
|
||||
|
||||
if [ "$count" -eq 0 ]; then
|
||||
exit 1
|
||||
elif [ "$count" -eq 1 ]; then
|
||||
class="one"
|
||||
elif [ "$count" -gt 1 ]; then
|
||||
class="many"
|
||||
else
|
||||
class="unknown"
|
||||
fi
|
||||
|
||||
printf '{"text":"%s", "class":"%s", "alt":"%s", "tooltip":"%s"}\n' "$count" "$class" "$class" "$(echo "${tooltip}" | sed -z 's/\n/\\n/g')"
|
8
.config/sway/scripts/screenshot-notify.sh
Executable file
8
.config/sway/scripts/screenshot-notify.sh
Executable file
|
@ -0,0 +1,8 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
set -e
|
||||
DIR=${XDG_SCREENSHOTS_DIR:-$HOME/Screenshots}
|
||||
|
||||
while true; do
|
||||
mkdir -p "$DIR" && inotifywait -q -e create "$DIR" --format '%w%f' | xargs notify-send "Screenshot saved"
|
||||
done
|
67
.config/sway/scripts/sunset.sh
Executable file
67
.config/sway/scripts/sunset.sh
Executable file
|
@ -0,0 +1,67 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
config="$HOME/.config/wlsunset/config"
|
||||
|
||||
#Startup function
|
||||
start() {
|
||||
[ -f "$config" ] && . "$config"
|
||||
temp_low=${temp_low:-"4000"}
|
||||
temp_high=${temp_high:-"6500"}
|
||||
duration=${duration:-"900"}
|
||||
sunrise=${sunrise:-"07:00"}
|
||||
sunset=${sunset:-"19:00"}
|
||||
location=${location:-"on"}
|
||||
fallback_longitude=${fallback_longitude:-"8.7"}
|
||||
fallback_latitude=${fallback_latitude:-"50.1"}
|
||||
|
||||
if [ "${location}" = "on" ]; then
|
||||
if [ -z ${longitude+x} ] || [ -z ${latitude+x} ]; then
|
||||
GEO_CONTENT=$(curl -sL https://manjaro-sway.download/geoip)
|
||||
fi
|
||||
longitude=${longitude:-$(echo "$GEO_CONTENT" | jq -r '.longitude // empty')}
|
||||
longitude=${longitude:-$fallback_longitude}
|
||||
latitude=${latitude:-$(echo "$GEO_CONTENT" | jq -r '.latitude // empty')}
|
||||
latitude=${latitude:-$fallback_latitude}
|
||||
|
||||
echo longitude: "$longitude" latitude: "$latitude"
|
||||
|
||||
wlsunset -l "$latitude" -L "$longitude" -t "$temp_low" -T "$temp_high" -d "$duration" &
|
||||
else
|
||||
wlsunset -t "$temp_low" -T "$temp_high" -d "$duration" -S "$sunrise" -s "$sunset" &
|
||||
fi
|
||||
}
|
||||
|
||||
#Accepts managing parameter
|
||||
case $1'' in
|
||||
'off')
|
||||
pkill -x wlsunset
|
||||
waybar-signal sunset
|
||||
;;
|
||||
'on')
|
||||
start
|
||||
waybar-signal sunset
|
||||
;;
|
||||
'toggle')
|
||||
if pkill -x -0 wlsunset; then
|
||||
pkill -x wlsunset
|
||||
else
|
||||
start
|
||||
fi
|
||||
waybar-signal sunset
|
||||
;;
|
||||
'check')
|
||||
command -v wlsunset
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
#Returns a string for Waybar
|
||||
if pkill -x -0 wlsunset; then
|
||||
class="on"
|
||||
text="location-based gamma correction"
|
||||
else
|
||||
class="off"
|
||||
text="no gamma correction"
|
||||
fi
|
||||
|
||||
printf '{"alt":"%s","tooltip":"%s"}\n' "$class" "$text"
|
97
.config/sway/scripts/valent.py
Executable file
97
.config/sway/scripts/valent.py
Executable file
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/env python3
|
||||
import dbus
|
||||
import json
|
||||
import logging, sys
|
||||
import os
|
||||
import math
|
||||
|
||||
level = logging.DEBUG if os.environ.get("DEBUG") == "true" else logging.INFO
|
||||
|
||||
logging.basicConfig(stream=sys.stderr, level=level)
|
||||
|
||||
CONNECTIVITY_STRENGTH_SYMBOL = ["", "", "", "", ""]
|
||||
|
||||
BATTERY_PERCENTAGE_SYMBOL = ["", "", "", "", "", "", "", "", "", ""]
|
||||
|
||||
bus = dbus.SessionBus()
|
||||
valent_object = bus.get_object("ca.andyholmes.Valent", "/ca/andyholmes/Valent")
|
||||
valent_interface = dbus.Interface(valent_object, "org.freedesktop.DBus.ObjectManager")
|
||||
managed_objects = valent_interface.GetManagedObjects()
|
||||
|
||||
dangerously_empty = False
|
||||
connected = False
|
||||
no_connectivity = False
|
||||
|
||||
devices = []
|
||||
|
||||
for path in managed_objects:
|
||||
device = {}
|
||||
device["state"] = (
|
||||
"connected"
|
||||
if managed_objects[path].get("ca.andyholmes.Valent.Device", {}).get("State", 0)
|
||||
== 3
|
||||
else "disconnected"
|
||||
)
|
||||
device["id"] = (
|
||||
managed_objects[path].get("ca.andyholmes.Valent.Device", {}).get("Id", 0)
|
||||
)
|
||||
device["name"] = (
|
||||
managed_objects[path].get("ca.andyholmes.Valent.Device", {}).get("Name", 0)
|
||||
)
|
||||
|
||||
device_obj = bus.get_object("ca.andyholmes.Valent", path)
|
||||
device_action_interface = dbus.Interface(device_obj, "org.gtk.Actions")
|
||||
|
||||
battery_state = device_action_interface.Describe("battery.state")[2][0]
|
||||
device["battery_percentage"] = battery_state["percentage"]
|
||||
device["battery_status"] = (
|
||||
"discharging" if battery_state["charging"] == 0 else "charging"
|
||||
)
|
||||
|
||||
connectivity_state = device_action_interface.Describe("connectivity_report.state")[
|
||||
2
|
||||
][0]["signal-strengths"]["1"]
|
||||
device["connectivity_strength"] = connectivity_state["signal-strength"]
|
||||
|
||||
if device["state"] == "connected":
|
||||
connected = True
|
||||
|
||||
if device["connectivity_strength"] <= 1:
|
||||
no_connectivity = True
|
||||
|
||||
if device["battery_percentage"] <= 15 and device["battery_status"] == "discharging":
|
||||
dangerously_empty = True
|
||||
|
||||
devices.append(device)
|
||||
|
||||
data = {}
|
||||
data["alt"] = (
|
||||
"no-devices"
|
||||
if len(devices) == 0
|
||||
else "dangerously-empty"
|
||||
if dangerously_empty
|
||||
else "no-signal"
|
||||
if no_connectivity
|
||||
else "connected"
|
||||
if connected
|
||||
else "disconnected"
|
||||
)
|
||||
data["class"] = data["alt"]
|
||||
data["tooltip"] = ""
|
||||
|
||||
logging.debug(devices)
|
||||
|
||||
tooltip = []
|
||||
|
||||
for device in devices:
|
||||
battery_symbol = math.ceil(round(device["battery_percentage"] / 10, 0))
|
||||
details = (
|
||||
f"\t{CONNECTIVITY_STRENGTH_SYMBOL[device['connectivity_strength']]} {BATTERY_PERCENTAGE_SYMBOL[battery_symbol]} {device['battery_percentage']}% ({device['battery_status']})"
|
||||
if device["state"] == "connected"
|
||||
else ""
|
||||
)
|
||||
tooltip.append(f"{device['name']} ({device['state']}){details}")
|
||||
|
||||
data["tooltip"] = "\n".join(tooltip)
|
||||
|
||||
print(json.dumps(data))
|
7
.config/sway/scripts/waybar.sh
Executable file
7
.config/sway/scripts/waybar.sh
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# wrapper script for waybar with args, see https://github.com/swaywm/sway/issues/5724
|
||||
CONFIG_PATH=$HOME/.config/waybar/config.jsonc
|
||||
STYLE_PATH=$HOME/.config/waybar/style.css
|
||||
|
||||
pkill -x waybar
|
||||
waybar -c "${CONFIG_PATH}" -s "${STYLE_PATH}" > $(mktemp -t XXXX.waybar.log)
|
28
.config/sway/scripts/wluma.sh
Executable file
28
.config/sway/scripts/wluma.sh
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/env sh
|
||||
|
||||
status() {
|
||||
systemctl --user is-active wluma >/dev/null 2>&1
|
||||
}
|
||||
|
||||
#Accepts managing parameter
|
||||
case $1'' in
|
||||
'toggle')
|
||||
status && systemctl --user stop wluma || systemctl --user --now enable wluma
|
||||
waybar-signal adaptive-brightness
|
||||
;;
|
||||
'check')
|
||||
[ -x "$(command -v wluma)" ] && [ $(ls -A /sys/class/backlight/ | wc -l) -gt 0 ]
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
||||
#Returns data for Waybar
|
||||
if status; then
|
||||
class="on"
|
||||
text="adaptive brightness"
|
||||
else
|
||||
class="off"
|
||||
text="static brightness"
|
||||
fi
|
||||
|
||||
printf '{"alt":"%s","tooltip":"%s"}\n' "$class" "$text"
|
Loading…
Add table
Add a link
Reference in a new issue