Browse Source

fix: hdmi, waybar, mako & sway

master
Tim 5 months ago
parent
commit
7265061daa
  1. 21
      bin/pass-gen
  2. 9
      bin/waybar-recording
  3. 22
      bin/waybar-systemd
  4. 37
      bin/waybar-yubikey
  5. 48
      bin/when
  6. 4
      config/mako/config
  7. 31
      config/sway/config
  8. 9
      packages/zsh.sym/aliases.zsh
  9. 3
      packages/zsh.sym/functions.zsh

21
bin/pass-gen

@ -0,0 +1,21 @@
#!/bin/sh
case $(echo "default\nno special chars\nshort" | dmenu -p "pass generator") in
default)
length=40
symbols="-y"
;;
"no special chars")
length=40
;;
short)
length=16
;;
*)
exit 1
;;
esac
#wl-clipboard-manager lock
pwgen -s "$length" $symbols | wl-copy -n
#wl-clipboard-manager unlock

9
bin/waybar-recording

@ -0,0 +1,9 @@
#!/bin/sh
if pgrep -x wf-recorder > /dev/null; then
printf '{"text": " "}\n'
elif pgrep -x obs-studio > /dev/null; then
printf '{"text": " "}\n'
else
printf '{"text": ""}\n'
fi

22
bin/waybar-systemd

@ -0,0 +1,22 @@
#!/bin/sh
failed_user="$(systemctl --plain --no-legend --user list-units --state=failed | awk '{ print $1 }')"
failed_system="$(systemctl --plain --no-legend list-units --state=failed | awk '{ print $1 }')"
failed_systemd_count="$(echo -n "$failed_system" | grep -c '^')"
failed_user_count="$(echo -n "$failed_user" | grep -c '^')"
text=$(( failed_systemd_count + failed_user_count ))
if [ "$text" -eq 0 ]; then
printf '{"text": ""}\n'
else
tooltip=""
[ -n "$failed_system" ] && tooltip="Failed system services:\n\n${failed_system}\n\n${tooltip}"
[ -n "$failed_user" ] && tooltip="Failed user services:\n\n${failed_user}\n\n${tooltip}"
tooltip="$(printf "$tooltip" | perl -pe 's/\n/\\n/g' | perl -pe 's/(?:\\n)+$//')"
printf '{"text": " %s", "tooltip": "%s" }\n' "$text" "$tooltip"
fi

37
bin/waybar-yubikey

@ -0,0 +1,37 @@
#!/bin/bash
socket="${XDG_RUNTIME_DIR:-/run/user/$UID}/yubikey-touch-detector.socket"
while true; do
touch_reasons=()
if [ ! -e "$socket" ]; then
printf '{"text": "Waiting for YubiKey socket"}\n'
while [ ! -e "$socket" ]; do sleep 1; done
fi
printf '{"text": ""}\n'
nc -U "$socket" | while read -n5 cmd; do
reason="${cmd:0:3}"
if [ "${cmd:4:1}" = "1" ]; then
touch_reasons+=("$reason")
else
for i in "${!touch_reasons[@]}"; do
if [ "${touch_reasons[i]}" = "$reason" ]; then
unset 'touch_reasons[i]'
break
fi
done
fi
if [ "${#touch_reasons[@]}" -eq 0 ]; then
printf '{"text": ""}\n'
else
tooltip="YubiKey is waiting for a touch, reasons: ${touch_reasons[@]}"
printf '{"text": " ", "tooltip": "%s"}\n' "$tooltip"
fi
done
sleep 1
done

48
bin/when

@ -0,0 +1,48 @@
#!/usr/bin/env python
import sys
import time
time_blocks = [
("year", 31557600),
("week", 604800),
("day", 86400),
("hour", 3600),
("minute", 60),
("second", 1),
]
def format(start, now, max_suffixes=2):
if start <= now:
duration = now - start
word = "ago"
else:
duration = start - now
word = "later"
result = ""
num_suffixes = 0
for suffix, size in time_blocks:
count = int(duration // size)
duration %= size
if count:
result += "{} {}{} ".format(count, suffix, "s" if count > 1 else "")
num_suffixes += 1
if num_suffixes >= max_suffixes:
break
return result + word
def main():
if len(sys.argv) != 2:
print("Usage: {} <timestamp>".format(sys.argv[0]))
sys.exit(1)
print(format(float(sys.argv[1]), time.time()))
if __name__ == "__main__":
main()

4
config/mako/config

@ -1,5 +1,5 @@
#font
default-timeout=1000
default-timeout=2500
layer=overlay
anchor=top-right
width=310
@ -8,7 +8,7 @@ border-radius=2
border-size=2
max-icon-size=128
text-alignment=center
background-color=#eeeeee
background-color=#bbbbbb
text-color=#444444
[urgency=low]

31
config/sway/config

@ -16,7 +16,7 @@ set $term alacritty
# Your preferred application launcher
# Note: pass the final command to swaymsg so that the resulting window can be opened
# on the original workspace that the command was run on.
set $menu "rofi -show run -m 1"
set $menu "rofi -show run"
bindsym $mod+p exec --no-startup-id "rofi -show drun "
bindsym $mod+c exec --no-startup-id "rofi -show calc -modi calc -no-sort -no-bold > /dev/null"
@ -209,7 +209,7 @@ bindsym $ps3 exec grim $(xdg-user-dir PICTURES)/ps_$(date +"%Y%m%d%H%M%S").png
bindsym $ps4 exec grim -g "$(slurp)" $(xdg-user-dir PICTURES)/ps_$(date +"%Y%m%d%H%M%S").png
#
# Our hotkey reboot
# Our hotkey reboot - Superseeded by `wlogout`
#
set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
@ -224,14 +224,14 @@ mode "$mode_system" {
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+F9 mode "$mode_system"
bindsym $mod+F9 exec wlogout
### Media Keys
bindsym XF86AudioPlay exec 'playerctl play-pause || mpc toggle'
bindsym XF86AudioPlay exec 'playerctl play-pause && mpc toggle'
bindsym XF86AudioPrev exec 'playerctl previous || mpc prev'
bindsym XF86AudioNext exec 'playerctl next || mpc next'
# F6,F7,F8 Incase you dont have media keys
bindsym $mod+F7 exec 'playerctl play-pause || mpc toggle'
bindsym $mod+F7 exec 'playerctl play-pause && mpc toggle'
bindsym $mod+F6 exec 'playerctl previous || mpc prev'
bindsym $mod+F8 exec 'playerctl next || mpc next'
@ -241,7 +241,7 @@ bindsym XF86AudioLowerVolume exec amixer sset Master 5%- unmute
### Window configs
gaps inner 5
gaps outer 8
gaps outer 10
default_border pixel 5
#smart_borders on
@ -251,30 +251,30 @@ smart_gaps on
#assign [class="Firefox"] 2
#assign [class="vlc"] 9
assign [class="Steam"] 4
assign [class="csgo_linux64"] 5
assign [class="Cities.x64"] 5
assign [class="Signal"] 2
assign [class="overwatch.exe"] 6
for_window [class="Signal"] move container to 2
for_window [class="Steam"] move container to 4
for_window [class="csgo_linux64"] move container to 5
for_window [class="Cities.x64"] move container to 5
for_window [class="overwatch.exe"] move container to 5
for_window [class="overwatch.exe"] floating enable
assign [class=".*wine.*"] 6
#assign [class=".*wine.*"] move container to 6
for_window [class=".*wine.*"] floating enable
# Enable or disable floating
for_window [class="Pavucontrol"] floating enable
for_window [class="feh"] floating enable
for_window [app_id="pavucontrol"] floating enable
for_window [app_id="feh"] floating enable
for_window [window_role="pop-up"] floating enable
for_window [window_role="bubble"] floating enable
for_window [window_role="task_dialog"] floating enable
for_window [window_role="Preferences"] floating enable
for_window [window_type="dialog"] floating enable
for_window [window_type="menu"] floating enable
for_window [app_id="mpv"] floating enable, resize set width 531 height 300, move position 120 700
## Status Bar
bar {
swaybar_command waybar
}
#exec waybar
## Environment thingies
exec systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK
@ -282,7 +282,6 @@ exec hash dbus-update-activation-environment 2>/dev/null && \
dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP=sway
## Starting
#exec dunst -force_xwayland
exec mako
exec firefox
exec signal-desktop

9
packages/zsh.sym/aliases.zsh

@ -1,15 +1,19 @@
# Actual Usefull commands
alias lefty='xmodmap -e "pointer = 3 2 1"'
alias righty='xmodmap -e "pointer = 1 2 3"'
alias leftscreen='xrandr --output DVI-I-2 --auto --left-of DVI-I-1'
alias hdmitoggle='togglehdmi'
alias togglehdmi="swaymsg output HDMI-A-1 disable; swaymsg output HDMI-A-1 enable;"
alias dptoggle='swaymsg output DP-1 disable; swaymsg output DP-1 enable'
alias sound='pavucontrol'
alias LS='ls'
alias CD='cd'
alias FG='fg'
alias HTOP='htop'
alias emerge-world-estimate='emerge -puND @world | genlop --pretend'
alias emerge-system-estimate='emerge -puND @system | genlop --pretend'
# Hack tmux to use 256 colors
alias tmux="TERM=xterm-256color tmux"
alias :wq='echo "This isnt VIM! exiting anyway"; exit'
alias :wq='echo "This isnt VIM! exiting anyway"; sleep 1; exit'
alias tmxu='tmux'
alias awksum="awk '{sum += \$1} END {print sum}'"
@ -54,3 +58,4 @@ alias shrug='echo "¯\_(ツ)_/¯"'
alias eac3to="wine ~/repos/eac3to/eac3to.exe 2>/dev/null"
alias eacout='wine ~/repos/eac3to/eac3to.exe 2>/dev/null | tr -cd "\11\12\15\40-\176"'
alias window-info="echo 'Focus window now!';sleep 2; swaymsg -t get_tree | jq -r '..|try select(.focused == true)'"

3
packages/zsh.sym/functions.zsh

@ -38,3 +38,6 @@ function gitexport(){
git archive master | tar -x -C "$1"
}
function newalias(){
echo "alias $1=$(echo $@ | sed -e 's/'$1\ '//')" >> $HOME/.zsh/aliases.zsh
}

Loading…
Cancel
Save