Things I thought I'd commited Signed-off-by: Anirudh Oppiliappan <x@icyphox.sh>
Anirudh Oppiliappan x@icyphox.sh
Thu, 19 Nov 2020 10:59:17 +0530
7 files changed,
180 insertions(+),
64 deletions(-)
M
config/fish/config.fish
→
config/fish/config.fish
@@ -1,7 +1,9 @@
set fish_greeting set -gx PATH ~/bin ~/.local/bin ~/leet/Nim/bin ~/.nimble/bin \ -/usr/local/bin /usr/bin /bin /sbin /usr/sbin /usr/X11R6/bin +/usr/local/bin /usr/bin /bin /sbin /usr/sbin /usr/X11R6/bin \ +~/bin/wm + set -gx EDITOR nvim set -gx BROWSER iridium set -gx PW_KEY x@icyphox.sh
M
config/sxhkd/sxhkdrc
→
config/sxhkd/sxhkdrc
@@ -32,15 +32,9 @@ #
# XF86MonBrightnessDown # lux -s 20 # -# Print -# scr -f -# -# ctrl + Print -# scr -w -# -# ctrl + shift + Print -# scr -s -# +ctrl + bracketright + scr -s + XF86AudioPlay cmus-remote -u
M
home/.Xresources
→
home/.Xresources
@@ -53,6 +53,15 @@ *.font: SF Mono:style=Regular:size=13:antialias=true
*.italicFont: SF Mono:style=Italic:size=13:antialias=true *.boldFont: SF Mono:style=Bold:size=13:antialias=true +! xnotify +xnotify.border: base05 +xnotify.background: base05 +xnotify.foreground: base00 +xnotify.gap: 5 +xnotify.geometry: 400x0 +xnotify.gravity: NE +xnotify.title.font: SF Mono:style=Bold:size=13:antialias=true + ! Urxvt config URxvt.font: xft:SF Mono:style=Regular:size=13:antialias=true,xft:Noto Sans:size=14:style=Medium:antialias=true URxvt.scrollBar: false
M
home/.xsession
→
home/.xsession
@@ -16,5 +16,13 @@ ~/.fehbg &
xrdb -l ~/.Xresources & syndaemon -k -i 0.5 -d xsetroot -cursor_name left_ptr + +# xnotify +XNOTIFY_FIFO="$HOME/.cache/xnotify$DISPLAY.fifo" +export XNOTIFY_FIFO +rm -f $XNOTIFY_FIFO +mkfifo $XNOTIFY_FIFO +xnotify <$XNOTIFY_FIFO 3<>$XNOTIFY_FIFO & + st & cwm
A
home/bin/notify-send
@@ -0,0 +1,12 @@
+#!/bin/sh +# mimic notify-send using xnotify + +[[ $(pgrep xnotify) == "" ]] && { + XNOTIFY_FIFO="$HOME/.cache/xnotify$DISPLAY.fifo" + export XNOTIFY_FIFO + rm -f $XNOTIFY_FIFO + mkfifo $XNOTIFY_FIFO + xnotify <$XNOTIFY_FIFO 3<>$XNOTIFY_FIFO & +} + +printf '%s\n' "$*" > $XNOTIFY_FIFO
M
weechat/weechat.conf
→
weechat/weechat.conf
@@ -390,60 +390,39 @@ title.type = window
[layout] default.buffer = "core;weechat;1" -default.buffer = "irc;server.deavmi;2" -default.buffer = "irc;deavmi.#general;3" -default.buffer = "irc;deavmi.#programming;4" -default.buffer = "irc;deavmi.*status;5" -default.buffer = "irc;server.freenode;6" -default.buffer = "irc;freenode.#cosmere;7" -default.buffer = "irc;freenode.##crustaceans;8" -default.buffer = "irc;freenode.#kisslinux;9" -default.buffer = "irc;freenode.#kubernetes;10" -default.buffer = "irc;freenode.#lobsters;11" -default.buffer = "irc;freenode.#merveilles;12" -default.buffer = "irc;freenode.#openbsd;13" -default.buffer = "irc;server.rizon;14" -default.buffer = "irc;rizon.#buddy;15" -default.buffer = "irc;rizon.#crimson;16" -default.buffer = "irc;rizon.#fsg;17" -default.buffer = "irc;rizon.#homescreen;18" -default.buffer = "irc;rizon.#rice;19" -default.buffer = "python;makera-org.slack.com;20" -default.buffer = "python;makera-org.slack.com.Abhishek,Dish,Kauts;21" -default.buffer = "python;makera-org.slack.com.Abhishek,Kauts;22" -default.buffer = "python;makera-org.slack.com.#backend;23" -default.buffer = "python;makera-org.slack.com.#bugs;24" -default.buffer = "python;makera-org.slack.com.#celebrations;25" -default.buffer = "python;makera-org.slack.com.#design;26" -default.buffer = "python;makera-org.slack.com.#dev;27" -default.buffer = "python;makera-org.slack.com.#general;28" -default.buffer = "python;makera-org.slack.com.#innerjourney;29" -default.buffer = "python;makera-org.slack.com.#legal;30" -default.buffer = "python;makera-org.slack.com.#makera;31" -default.buffer = "python;makera-org.slack.com.#random;32" -default.buffer = "python;makera-org.slack.com.#ycombinator;33" -default.buffer = "python;makera-org.slack.com.Abhishek;34" -default.buffer = "python;makera-org.slack.com.Anirudh;35" -default.buffer = "python;makera-org.slack.com.Dish;36" -default.buffer = "python;makera-org.slack.com.Kauts;37" -default.buffer = "python;makera-org.slack.com.Kavya;38" -default.buffer = "python;makera-org.slack.com.Vishesh;39" -default.buffer = "python;teamcometchat.slack.com;40" -default.buffer = "python;teamcometchat.slack.com.&breakouts-pro;41" -default.buffer = "python;teamcometchat.slack.com.&hipaa;42" -default.buffer = "python;teamcometchat.slack.com.&interns-pro;43" -default.buffer = "python;teamcometchat.slack.com.&xmpp-pro;44" -default.buffer = "python;teamcometchat.slack.com.#general;45" -default.buffer = "python;teamcometchat.slack.com.#product-releases;46" -default.buffer = "python;teamcometchat.slack.com.#random;47" -default.buffer = "python;teamcometchat.slack.com.#spotlight;48" -default.buffer = "python;teamcometchat.slack.com.AjayGajra;49" -default.buffer = "python;teamcometchat.slack.com.AjayPrabhakar;50" -default.buffer = "python;teamcometchat.slack.com.donut;51" -default.buffer = "python;teamcometchat.slack.com.KetanYekale;52" -default.buffer = "python;teamcometchat.slack.com.PrathameshMajgaonkar;53" -default.buffer = "python;teamcometchat.slack.com.RaviRanjan;54" -default.buffer = "python;teamcometchat.slack.com.standuply;55" +default.buffer = "python;makera-org.slack.com;2" +default.buffer = "python;makera-org.slack.com.Abhishek,Dish,Kauts;3" +default.buffer = "python;makera-org.slack.com.Abhishek,Kauts;4" +default.buffer = "python;makera-org.slack.com.#backend;5" +default.buffer = "python;makera-org.slack.com.#bugs;6" +default.buffer = "python;makera-org.slack.com.#celebrations;7" +default.buffer = "python;makera-org.slack.com.#design;8" +default.buffer = "python;makera-org.slack.com.#dev;9" +default.buffer = "python;makera-org.slack.com.#general;10" +default.buffer = "python;makera-org.slack.com.#innerjourney;11" +default.buffer = "python;makera-org.slack.com.#legal;12" +default.buffer = "python;makera-org.slack.com.#makera;13" +default.buffer = "python;makera-org.slack.com.#random;14" +default.buffer = "python;makera-org.slack.com.#ycombinator;15" +default.buffer = "python;makera-org.slack.com.Abhishek;16" +default.buffer = "python;makera-org.slack.com.Anirudh;17" +default.buffer = "python;makera-org.slack.com.Dish;18" +default.buffer = "python;makera-org.slack.com.Kauts;19" +default.buffer = "python;makera-org.slack.com.Kavya;20" +default.buffer = "python;makera-org.slack.com.Vishesh;21" +default.buffer = "python;teamcometchat.slack.com;22" +default.buffer = "python;teamcometchat.slack.com.&interns-pro;23" +default.buffer = "python;teamcometchat.slack.com.&xmpp-pro;24" +default.buffer = "python;teamcometchat.slack.com.#general;25" +default.buffer = "python;teamcometchat.slack.com.#product-releases;26" +default.buffer = "python;teamcometchat.slack.com.#random;27" +default.buffer = "python;teamcometchat.slack.com.#spotlight;28" +default.buffer = "python;teamcometchat.slack.com.AjayGajra;29" +default.buffer = "python;teamcometchat.slack.com.donut;30" +default.buffer = "python;teamcometchat.slack.com.KetanYekale;31" +default.buffer = "python;teamcometchat.slack.com.PrathameshMajgaonkar;32" +default.buffer = "python;teamcometchat.slack.com.RaviRanjan;33" +default.buffer = "python;teamcometchat.slack.com.standuply;34" default.window = "1;0;0;0;irc;rizon.Carp" default.current = on
A
weechat/xnotify.py
@@ -0,0 +1,112 @@
+from __future__ import unicode_literals + +import weechat as weechat +import subprocess +from os import environ, path + +xnotify_name = "xnotify" +xnotify_version = "0.3.5" +xnotify_license = "GPL3" + +# convenient table checking for bools +true = { "on": True, "off": False } + +# declare this here, will be global config() object +# but is initialized in __main__ +cfg = None + +class config(object): + def __init__(self): + # default options for xnotify + self.opts = { + "highlight": "on", + "query": "on", + "notify_away": "off", + "icon": "weechat", + } + + self.init_config() + self.check_config() + + def init_config(self): + for opt, value in self.opts.items(): + temp = weechat.config_get_plugin(opt) + if not len(temp): + weechat.config_set_plugin(opt, value) + + def check_config(self): + for opt in self.opts: + self.opts[opt] = weechat.config_get_plugin(opt) + + def __getitem__(self, key): + return self.opts[key] + +def printc(msg): + weechat.prnt("", msg) + +def handle_msg(data, pbuffer, date, tags, displayed, highlight, prefix, message): + highlight = bool(highlight) and cfg["highlight"] + query = true[cfg["query"]] + notify_away = true[cfg["notify_away"]] + buffer_type = weechat.buffer_get_string(pbuffer, "localvar_type") + away = weechat.buffer_get_string(pbuffer, "localvar_away") + x_focus = False + window_name = "" + my_nickname = "nick_" + weechat.buffer_get_string(pbuffer, "localvar_nick") + + # Check if active window is in the ignore_windows_list and skip notification + if (environ.get('DISPLAY') != None) and path.isfile("/bin/xdotool"): + cmd_pid="xdotool getactivewindow getwindowpid".split() + window_pid = subprocess.check_output(cmd_pid).decode("utf-8") + cmd_name=("ps -ho comm -p %s"%(window_pid)).split() + window_name = subprocess.check_output(cmd_name).decode("utf-8") + ignore_windows_list = [] + if window_name in ignore_windows_list: + x_focus = True + return weechat.WEECHAT_RC_OK + + if pbuffer == weechat.current_buffer() and x_focus: + return weechat.WEECHAT_RC_OK + + if away and not notify_away: + return weechat.WEECHAT_RC_OK + + if my_nickname in tags: + return weechat.WEECHAT_RC_OK + + buffer_name = weechat.buffer_get_string(pbuffer, "short_name") + + + if buffer_type == "private" and query: + notify_user(buffer_name, message) + elif buffer_type == "channel" and highlight: + notify_user("{} @ {}".format(prefix, buffer_name), message) + + return weechat.WEECHAT_RC_OK + +def process_cb(data, command, return_code, out, err): + if return_code == weechat.WEECHAT_HOOK_PROCESS_ERROR: + weechat.prnt("", "Error with command '%s'" % command) + elif return_code != 0: + weechat.prnt("", "return_code = %d" % return_code) + weechat.prnt("", "notify-send has an error") + return weechat.WEECHAT_RC_OK + +def notify_user(origin, message): + hook = weechat.hook_process_hashtable("notify-send", + { + "arg1": "WeeChat", "arg2": "", + "arg3": origin + '\t', "arg4": message, + }, + 20000, "process_cb", "") + + return weechat.WEECHAT_RC_OK + +# execute initializations in order +if __name__ == "__main__": + weechat.register(xnotify_name, "kevr", xnotify_version, xnotify_license, + "{} - A libnotify script for weechat".format(xnotify_name), "", "") + + cfg = config() + print_hook = weechat.hook_print("", "", "", 1, "handle_msg", "") +