Some changes
This commit is contained in:
parent
f40f9f5277
commit
ee1321e857
@ -1,6 +1,57 @@
|
|||||||
#!/bin/sh
|
#!/usr/bin/env -S emacs -x
|
||||||
if [ "${#}" -gt 0 ]; then
|
;; -*- mode: emacs-lisp; lexical-binding: t -*-
|
||||||
config_flags="-c ${1}"
|
(require 'cl-lib)
|
||||||
fi
|
(require 'server)
|
||||||
fcitx5-remote -t
|
(require 'dbus)
|
||||||
eww ${config_flags} update fcitx5-state="$(fcitx5-remote)"
|
|
||||||
|
(defun cmdline-for-pid (pid)
|
||||||
|
"Return the command line arguments passed to PID.
|
||||||
|
PID can be a string or a number."
|
||||||
|
(butlast (string-split
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents-literally
|
||||||
|
(format "/proc/%s/cmdline" pid))
|
||||||
|
(buffer-substring-no-properties (point-min)
|
||||||
|
(point-max)))
|
||||||
|
"\0")))
|
||||||
|
(defun current-eww-config-dir ()
|
||||||
|
"Return the configuration directory for a currently running eww process."
|
||||||
|
;; This probably only works on Linux
|
||||||
|
(catch 'found
|
||||||
|
(dolist (subdir (directory-files "/proc"))
|
||||||
|
(when (string-match-p (rx bos (+ num) eos) subdir)
|
||||||
|
(ignore-error permission-denied
|
||||||
|
(let* ((attrs (file-attributes (format "/proc/%s/exe" subdir)))
|
||||||
|
(type (file-attribute-type attrs)))
|
||||||
|
(when (and (stringp type)
|
||||||
|
(string-match-p (rx (or bos "/") "eww") type))
|
||||||
|
(cl-maplist (lambda (tail)
|
||||||
|
(when (equal (car tail) "-c")
|
||||||
|
(throw 'found (cl-second tail))))
|
||||||
|
(cmdline-for-pid subdir)))))))))
|
||||||
|
|
||||||
|
(defun set-eww-fcitx-state (state)
|
||||||
|
"Set the Fcitx state for Eww to STATE."
|
||||||
|
(let ((args (list "update" (format "fcitx5-state=%s" state)))
|
||||||
|
(cfg-dir (current-eww-config-dir)))
|
||||||
|
(when cfg-dir
|
||||||
|
(setq args (nconc (list "-c" cfg-dir) args)))
|
||||||
|
(apply 'call-process "eww" nil 0 nil args)))
|
||||||
|
|
||||||
|
(cl-defun has-focused-window-p (&optional (server "server"))
|
||||||
|
"Return non-nil if SERVER has at least one focused window.
|
||||||
|
SERVER defaults to \"server\"."
|
||||||
|
(server-eval-at
|
||||||
|
server '(cl-some 'frame-focus-state (frame-list))))
|
||||||
|
|
||||||
|
(if (has-focused-window-p)
|
||||||
|
(server-eval-at "server" '(my/global-toggle-mozc))
|
||||||
|
(dbus-call-method :session "org.fcitx.Fcitx5" "/controller"
|
||||||
|
"org.fcitx.Fcitx.Controller1" "Toggle")
|
||||||
|
(let ((state (dbus-call-method :session "org.fcitx.Fcitx5" "/controller"
|
||||||
|
"org.fcitx.Fcitx.Controller1" "State")))
|
||||||
|
(set-eww-fcitx-state state)))
|
||||||
|
|
||||||
|
;; Local Variables:
|
||||||
|
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
|
||||||
|
;; End:
|
||||||
|
@ -1,17 +1,4 @@
|
|||||||
#!/usr/bin/env -S emacs -x
|
#!/usr/bin/env zsh
|
||||||
;;; -*- mode: emacs-lisp; lexical-binding: t -*-
|
|
||||||
(require 'server)
|
lines="${(f)$(mu find 'maildir:/protonmail/Inbox AND flag:unread' 2>/dev/null)}"
|
||||||
(princ
|
printf '%d' "${#lines}"
|
||||||
(condition-case _
|
|
||||||
(if-let ((modeline-string (server-eval-at "server" '(mu4e--modeline-string)))
|
|
||||||
((string-match "\\([0-9]+\\)\\((\\+[0-9]+)\\)?/[0-9]+ $" modeline-string))
|
|
||||||
(matched-string (match-string 1 modeline-string)))
|
|
||||||
(progn
|
|
||||||
(set-text-properties 0 (length matched-string)
|
|
||||||
nil
|
|
||||||
matched-string)
|
|
||||||
matched-string)
|
|
||||||
"0")
|
|
||||||
(error
|
|
||||||
"0")))
|
|
||||||
(terpri)
|
|
||||||
|
@ -24,10 +24,12 @@ function notify_vol {
|
|||||||
local icon
|
local icon
|
||||||
if [[ "$(pamixer --get-mute)" == 'true' ]]; then
|
if [[ "$(pamixer --get-mute)" == 'true' ]]; then
|
||||||
icon=''
|
icon=''
|
||||||
elif (( ${vol} > 50 )); then
|
elif (( ${vol} >= 50 )); then
|
||||||
icon=''
|
icon=''
|
||||||
elif (( ${vol} >= 0 )); then
|
elif ((${vol} > 0)); then
|
||||||
icon=''
|
icon=''
|
||||||
|
elif ((${vol} == 0)); then
|
||||||
|
icon=''
|
||||||
else
|
else
|
||||||
icon='?'
|
icon='?'
|
||||||
fi
|
fi
|
||||||
|
@ -14,11 +14,11 @@ function has-rootful-xwayland-p {
|
|||||||
|
|
||||||
function run {
|
function run {
|
||||||
# ensure multiple instances do not run
|
# ensure multiple instances do not run
|
||||||
mkdir -p "$(dirname "${LOCKFILE}")"
|
mkdir -p "${LOCKFILE:h}"
|
||||||
exec 4<>"${LOCKFILE}"
|
exec 4<>"${LOCKFILE}"
|
||||||
flock -n 4 || exit 0
|
flock -n 4 || exit 0
|
||||||
dunstctl set-paused true
|
dunstctl set-paused true
|
||||||
if has-rootful-xwayland-p; then
|
if [[ "${XDG_CURRENT_DESKTOP}" == 'river' ]] && has-rootful-xwayland-p; then
|
||||||
swaylock ${empty_flag} --color '#000000'
|
swaylock ${empty_flag} --color '#000000'
|
||||||
else
|
else
|
||||||
swayidle -w -C /dev/null \
|
swayidle -w -C /dev/null \
|
||||||
|
@ -2,4 +2,13 @@
|
|||||||
|
|
||||||
local resp="$(printf 'No\nYes\n' | fuzzel --dmenu --prompt 'Really Logout> ')"
|
local resp="$(printf 'No\nYes\n' | fuzzel --dmenu --prompt 'Really Logout> ')"
|
||||||
|
|
||||||
[[ "${resp}" == 'Yes' ]] && riverctl exit
|
if [[ "${resp}" == 'Yes' ]]; then
|
||||||
|
case "${XDG_CURRENT_DESKTOP}" in
|
||||||
|
Hyprland)
|
||||||
|
hyprctl dispatch exit
|
||||||
|
;;
|
||||||
|
river)
|
||||||
|
riverctl exit
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
@ -36,3 +36,9 @@ case "${choice}" in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [[ "${XDG_CURRENT_DESKTOP}" == 'river' ]]; then
|
||||||
|
eww -c "${HOME}/.config/river/config/" update swayidle="$(( ! ${choice} ))"
|
||||||
|
elif [[ "${XDG_CURRENT_DESKTOP}" == 'Hyprland' ]]; then
|
||||||
|
pkill -SIGRTMIN+1 waybar
|
||||||
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user