aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-rw-r--r--misc/.bashrc17
-rw-r--r--misc/.config/i3/config6
-rwxr-xr-xmisc/.config/i3/focus.sh33
-rwxr-xr-xmisc/.config/i3/rofi-pass.sh3
-rw-r--r--misc/.config/mpv/input.conf1
-rw-r--r--misc/.config/mpv/mpv.conf3
-rw-r--r--misc/.gdbinit26
-rwxr-xr-xmisc/bin/emms-audio-focus.sh45
-rwxr-xr-xmisc/bin/emms.sh3
-rwxr-xr-xmisc/bin/org-a-sync.el27
10 files changed, 154 insertions, 10 deletions
diff --git a/misc/.bashrc b/misc/.bashrc
index 2d44565..48bc504 100644
--- a/misc/.bashrc
+++ b/misc/.bashrc
@@ -140,7 +140,6 @@ alias which='alias | which -i'
alias chx="chmod +x"
# dedicated emacs instances for emms and erc, see `my-profile' in my
# emacs init files
-alias emms='EMACS_PROFILE=emms emacs'
alias erc='EMACS_PROFILE=erc emacs'
# Safer default for cp, mv, rm. These will print a verbose output of
@@ -283,5 +282,21 @@ gs-merge() {
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="$@"
}
+_chime() {
+ "$@"
+ local rc=$?
+ local d=/usr/share/sounds/freedesktop/stereo
+ if [ $rc -eq 0 ]; then
+ # success jingle
+ play -q -n synth 0.12 pluck C5 : synth 0.12 pluck E5 : synth 0.12 pluck G5 : synth 0.45 pluck C6
+ else
+ # failure jingle
+ play -q -n synth 0.12 pluck C4 : synth 0.12 pluck G3 : synth 0.12 pluck Eb3 : synth 0.45 pluck C3
+ fi
+ return $rc
+}
+
+alias chime='_chime '
+
# dptrp1
alias quaderno="dptrp1 --addr $QUADERNO_IP"
diff --git a/misc/.config/i3/config b/misc/.config/i3/config
index 803dcd1..4928269 100644
--- a/misc/.config/i3/config
+++ b/misc/.config/i3/config
@@ -41,7 +41,7 @@ bindsym $mod+q exec "pkill firefox; sleep 2; firefox"
# start rofi
bindsym $mod+j exec "PATH=$HOME/.local/bin:$HOME/bin:$PATH rofi -show combi"
-bindsym $mod+slash exec rofi-pass
+bindsym $mod+slash exec --no-startup-id ~/.config/i3/rofi-pass.sh
# show PATH, for debugging
bindsym $mod+Shift+z exec "echo $PATH|sed -e 's/:/\n/g' | rofi -dmenu"
@@ -207,8 +207,12 @@ bindsym $mod+Shift+m focus parent; fullscreen; focus child
bindsym $mod+equal exec dunstctl history-pop
bindsym $mod+minus exec dunstctl close
+bindsym $mod+F1 exec --no-startup-id ~/.config/i3/focus.sh
+
# startup
+exec --no-startup-id xsetroot -solid "#000000"
exec ibus-daemon
exec redshift-gtk
exec --no-startup-id i3-msg 'workspace $ws1; exec urxvt'
exec xscreensaver -no-splash &
+exec xautolock -time 15 -locker 'i3lock -c 000000' &
diff --git a/misc/.config/i3/focus.sh b/misc/.config/i3/focus.sh
new file mode 100755
index 0000000..6dd7d46
--- /dev/null
+++ b/misc/.config/i3/focus.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# toggle reading/focus mode on the current workspace
+
+WIDTH=1000 # desired window width in pixels
+
+ws=$(i3-msg -t get_tree | jq -c 'first(.. | objects
+ | select(.type=="workspace" and any(.. | objects; .focused == true)))')
+
+# Gap per side = (workspace width - desired width) / 2, minus any inner gap
+ws_width=$(echo "$ws" | jq '.rect.width')
+inner_gap=$(echo "$ws" | jq '.gaps.inner // 0')
+gap=$(( (ws_width - WIDTH) / 2 - inner_gap ))
+[ "$gap" -lt 0 ] && gap=0
+
+on="layout tabbed; gaps horizontal current set $gap; bar mode hide"
+off="layout splith; gaps horizontal current set 0; bar mode dock"
+
+count=$(echo "$ws" | jq '.nodes | length')
+inner=$(echo "$ws" | jq '.nodes[0].nodes | length')
+
+if [ "$count" -eq 1 ] && [ "$inner" -gt 0 ]; then
+ layout=$(echo "$ws" | jq -r '.nodes[0].layout')
+ child=$(echo "$ws" | jq '.nodes[0].nodes[0].id')
+ if [ "$layout" = "tabbed" ]; then
+ i3-msg "[con_id=$child] $off"
+ else
+ i3-msg "[con_id=$child] $on"
+ fi
+else
+ child=$(echo "$ws" | jq '.nodes[0].id')
+ i3-msg "[con_id=$child] $on"
+fi
diff --git a/misc/.config/i3/rofi-pass.sh b/misc/.config/i3/rofi-pass.sh
new file mode 100755
index 0000000..d8aea04
--- /dev/null
+++ b/misc/.config/i3/rofi-pass.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+rofi-pass "$@"
+xdotool keyup ctrl
diff --git a/misc/.config/mpv/input.conf b/misc/.config/mpv/input.conf
index 0238138..8d0f7a3 100644
--- a/misc/.config/mpv/input.conf
+++ b/misc/.config/mpv/input.conf
@@ -1,3 +1,4 @@
PREV seek -15
NEXT stop
a vf toggle hflip
+j script-message-to console type "seek absolute" 6
diff --git a/misc/.config/mpv/mpv.conf b/misc/.config/mpv/mpv.conf
index b6b1beb..a2677e7 100644
--- a/misc/.config/mpv/mpv.conf
+++ b/misc/.config/mpv/mpv.conf
@@ -5,10 +5,7 @@ save-position-on-quit
script-opts=ytdl_hook-ytdl_path=/usr/bin/yt-dlp
ytdl-format="bestvideo[height<=?720]+bestaudio/best"
-osc=no
stop-screensaver = "yes"
-# play audio with ui
-# profile=pseudo-gui
[emacsconf-talks]
# Positioning
diff --git a/misc/.gdbinit b/misc/.gdbinit
index 00be34f..433973a 100644
--- a/misc/.gdbinit
+++ b/misc/.gdbinit
@@ -25,6 +25,14 @@ define bc
b $arg0
c
end
+define enc
+ en $arg0
+ c
+end
+define disc
+ dis $arg0
+ c
+end
# Print backtrace of all threads
alias abt = thread apply all bt
set history save on
@@ -44,5 +52,23 @@ define wlrc
watch -l $arg0
rc
end
+define brc
+ b $arg0
+ rc
+end
+
+# bison
+define pbs
+ print yyvsp[$arg0 - yylen]
+end
+
+define disw
+python
+for b in gdb.breakpoints():
+ if b.type in (gdb.BP_WATCHPOINT, gdb.BP_HARDWARE_WATCHPOINT,
+ gdb.BP_READ_WATCHPOINT, gdb.BP_ACCESS_WATCHPOINT):
+ b.enabled = False
+end
+end
source ~/.gdbinit_local
diff --git a/misc/bin/emms-audio-focus.sh b/misc/bin/emms-audio-focus.sh
new file mode 100755
index 0000000..44a2080
--- /dev/null
+++ b/misc/bin/emms-audio-focus.sh
@@ -0,0 +1,45 @@
+#!/usr/bin/env bash
+# Pause EMMS while any other app plays audio; resume when quiet again.
+RESUME_DELAY=2 # seconds of silence before resuming
+
+others_playing() {
+ pactl --format=json list sink-inputs 2>/dev/null | jq '
+ [ .[] | select(.corked == false)
+ | select(.properties."application.name" != "emms")
+ | select(.properties."media.role" != "event") ] | length'
+}
+
+emms_pause_if_playing() { # prints t only if *we* paused it
+ emacsclient -s emms --eval '(when (and emms-player-playing-p
+ (not emms-player-paused-p))
+ (emms-pause) t)' 2>/dev/null
+}
+
+emms_resume() {
+ emacsclient -s emms --eval '(when emms-player-paused-p (emms-pause))' >/dev/null 2>&1
+}
+
+exec 3< <(pactl subscribe)
+paused_by_us=0
+quiet_since=0
+
+while :; do
+ # Wake up on a sound-server event or once a second; drain event bursts.
+ read -r -t 1 -u 3 _
+ while read -r -t 0.05 -u 3 _; do :; done
+
+ n=$(others_playing)
+ if (( ${n:-0} > 0 )); then
+ quiet_since=0
+ if (( ! paused_by_us )) && [[ $(emms_pause_if_playing) == t ]]; then
+ paused_by_us=1
+ fi
+ elif (( paused_by_us )); then
+ (( quiet_since )) || quiet_since=$SECONDS
+ if (( SECONDS - quiet_since >= RESUME_DELAY )); then
+ emms_resume
+ paused_by_us=0
+ quiet_since=0
+ fi
+ fi
+done
diff --git a/misc/bin/emms.sh b/misc/bin/emms.sh
new file mode 100755
index 0000000..0367671
--- /dev/null
+++ b/misc/bin/emms.sh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+EMACS_PROFILE=emms emacs
diff --git a/misc/bin/org-a-sync.el b/misc/bin/org-a-sync.el
index 7123f04..4ed9052 100755
--- a/misc/bin/org-a-sync.el
+++ b/misc/bin/org-a-sync.el
@@ -7,6 +7,21 @@
(my-setq-from-local my-org-agenda-and-next-export-files)
(my-setq-from-local org-agenda-files)
+(defvar my-org-agenda-export-seen (make-hash-table :test #'equal)
+ "Hash table of headings already shown in the current agenda run.")
+
+(defun my-org-agenda-drop-seen (item)
+ "Return agenda ITEM, or nil if its heading was already shown.
+Meant for `org-agenda-before-sorting-filter-function'. Items without
+an `org-hd-marker' (diary entries and the like) are always kept."
+ (let ((m (get-text-property 0 'org-hd-marker item)))
+ (if (not (and my-org-agenda-export-seen (markerp m) (marker-buffer m)))
+ item
+ (let ((key (cons (marker-buffer m) (marker-position m))))
+ (unless (gethash key my-org-agenda-export-seen)
+ (puthash key t my-org-agenda-export-seen)
+ item)))))
+
(progn
(setq org-todo-keywords
'((sequence "TODO(t)" "DOIN(i)" "WAIT(w)" "|"
@@ -16,16 +31,18 @@
org-enforce-todo-checkbox-dependencies nil)
(setq org-use-fast-todo-selection 'expert)
(setq org-agenda-custom-commands
- `(("A" "Agenda and next"
- ((agenda ""
+ `(("E" "Agenda and next (export: each heading once)"
+ ((agenda ""
((org-agenda-span 32)
;; only works when `org-agenda-start-on-weekday'
;; is nil
(org-agenda-start-day "-2d")))
(tags-todo "PRIORITY=\"A\"" nil))
- nil
- ,my-org-agenda-and-next-export-files
- )))
+ ;; Command-level settings are evaluated once per run, so both
+ ;; blocks share one fresh table.
+ ((org-agenda-before-sorting-filter-function
+ #'my-org-agenda-drop-seen))
+ ,my-org-agenda-and-next-export-files)))
(setq large-file-warning-threshold nil)
(setq org-agenda-todo-ignore-time-comparison-use-seconds t)
(setq org-agenda-todo-ignore-deadlines 'all)