From a92b05a51cba2f54241c35025e356048436e6284 Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Tue, 10 Feb 2026 13:47:36 -0800 Subject: [PATCH] Cleanup --- .../config/systemd/user/tracker-store.service | 1 - dotfiles/irssi/config | 415 ---- dotfiles/irssi/default.theme | 297 --- dotfiles/irssi/instantssl.crt | 26 - dotfiles/irssi/scripts/adv_windowlist.pl | 2088 ----------------- .../irssi/scripts/autorun/adv_windowlist.pl | 1 - dotfiles/irssi/scripts/autorun/cap_sasl.pl | 1 - dotfiles/irssi/scripts/cap_sasl.pl | 272 --- install.sh | 99 +- 9 files changed, 4 insertions(+), 3196 deletions(-) delete mode 120000 dotfiles/config/systemd/user/tracker-store.service delete mode 100644 dotfiles/irssi/config delete mode 100644 dotfiles/irssi/default.theme delete mode 100644 dotfiles/irssi/instantssl.crt delete mode 100644 dotfiles/irssi/scripts/adv_windowlist.pl delete mode 120000 dotfiles/irssi/scripts/autorun/adv_windowlist.pl delete mode 120000 dotfiles/irssi/scripts/autorun/cap_sasl.pl delete mode 100644 dotfiles/irssi/scripts/cap_sasl.pl diff --git a/dotfiles/config/systemd/user/tracker-store.service b/dotfiles/config/systemd/user/tracker-store.service deleted file mode 120000 index dc1dc0c..0000000 --- a/dotfiles/config/systemd/user/tracker-store.service +++ /dev/null @@ -1 +0,0 @@ -/dev/null \ No newline at end of file diff --git a/dotfiles/irssi/config b/dotfiles/irssi/config deleted file mode 100644 index 1cf48ee..0000000 --- a/dotfiles/irssi/config +++ /dev/null @@ -1,415 +0,0 @@ -servers = ( - { - address = "ircs.overthewire.org"; - chatnet = "overthewire"; - port = "6697"; - use_ssl = "yes"; - ssl_verify = "no"; - autoconnect = "yes"; - }, - { - address = "irc.secfo.org"; - chatnet = "secfo"; - port = "7000"; - use_ssl = "yes"; - ssl_verify = "no"; - autoconnect = "yes"; - }, - { - address = "irc.hackint.eu"; - chatnet = "hackint"; - port = "9999"; - use_ssl = "yes"; - ssl_verify = "no"; - autoconnect = "yes"; - }, - { - address = "irc.geekshed.net"; - chatnet = "geekshed"; - port = "6697"; - use_ssl = "yes"; - ssl_verify = "no"; - autoconnect = "no"; - }, - { - address = "irc.rpis.ec"; - chatnet = "rpisec"; - port = "6697"; - use_ssl = "yes"; - ssl_verify = "no"; - autoconnect = "yes"; - }, - { - address = "chat.freenode.net"; - chatnet = "freenode"; - port = "7000"; - use_ssl = "yes"; - ssl_cert = "~/.irssi/matir.pem"; - ssl_verify = "yes"; - ssl_capath = "/etc/ssl/certs"; - family = "inet"; - autoconnect = "yes"; - } -); - -chatnets = { - OFTC = { - type = "IRC"; - max_kicks = "1"; - max_msgs = "3"; - max_whois = "30"; - }; - overthewire = { type = "IRC"; nick = "Matir"; }; - secfo = { type = "IRC"; }; - hackint = { type = "IRC"; nick = "Matir"; }; - freenode = { - type = "IRC"; - nick = "Matir"; - username = "matir"; - realname = "Matir"; - max_kicks = "1"; - max_msgs = "4"; - max_modes = "4"; - max_whois = "1"; - }; - geekshed = { - type = "IRC"; - nick = "KF4MDV"; - username = "kf4mdv"; - realname = "David"; - }; - rpisec = { type = "IRC"; }; -}; - -channels = ( - { name = "#kali-linux"; chatnet = "freenode"; autojoin = "yes"; }, - { name = "#hak5"; chatnet = "secfo"; autojoin = "yes"; }, - { name = "#wargames"; chatnet = "overthewire"; autojoin = "yes"; }, - { name = "#social"; chatnet = "overthewire"; autojoin = "yes"; }, - { name = "#openvpn"; chatnet = "freenode"; autojoin = "yes"; }, - { name = "#amateria"; chatnet = "overthewire"; autojoin = "yes"; }, - { name = "#io"; chatnet = "overthewire"; autojoin = "yes"; }, - { name = "#radare"; chatnet = "freenode"; autojoin = "yes"; }, - { name = "#vulnhub"; chatnet = "freenode"; autojoin = "yes"; }, - { name = "#redditnet"; chatnet = "geekshed"; autojoin = "yes"; }, - { name = "#rpisec"; chatnet = "rpisec"; autojoin = "yes"; }, - { name = "#offsec"; chatnet = "freenode"; autojoin = "yes"; }, - { name = "#offtopicsec"; chatnet = "freenode"; autojoin = "yes"; } -); - -aliases = { - J = "join"; - WJOIN = "join -window"; - WQUERY = "query -window"; - LEAVE = "part"; - BYE = "quit"; - EXIT = "quit"; - SIGNOFF = "quit"; - DESCRIBE = "action"; - DATE = "time"; - HOST = "userhost"; - LAST = "lastlog"; - SAY = "msg *"; - WI = "whois"; - WII = "whois $0 $0"; - WW = "whowas"; - W = "who"; - N = "names"; - M = "msg"; - T = "topic"; - C = "clear"; - CL = "clear"; - K = "kick"; - KB = "kickban"; - KN = "knockout"; - BANS = "ban"; - B = "ban"; - MUB = "unban *"; - UB = "unban"; - IG = "ignore"; - UNIG = "unignore"; - SB = "scrollback"; - UMODE = "mode $N"; - WC = "window close"; - WN = "window new hide"; - SV = "say Irssi $J ($V) - http://irssi.org/"; - GOTO = "sb goto"; - CHAT = "dcc chat"; - RUN = "SCRIPT LOAD"; - CALC = "exec - if command -v bc >/dev/null 2>&1\\; then printf '%s=' '$*'\\; echo '$*' | bc -l\\; else echo bc was not found\\; fi"; - SBAR = "STATUSBAR"; - INVITELIST = "mode $C +I"; - Q = "QUERY"; - "MANUAL-WINDOWS" = "set use_status_window off;set autocreate_windows off;set autocreate_query_level none;set autoclose_windows off;set reuse_unused_windows on;save"; - EXEMPTLIST = "mode $C +e"; - ATAG = "WINDOW SERVER"; - UNSET = "set -clear"; - RESET = "set -default"; -}; - -statusbar = { - # formats: - # when using {templates}, the template is shown only if it's argument isn't - # empty unless no argument is given. for example {sb} is printed always, - # but {sb $T} is printed only if $T isn't empty. - - items = { - # start/end text in statusbars - barstart = "{sbstart}"; - barend = "{sbend}"; - - topicbarstart = "{topicsbstart}"; - topicbarend = "{topicsbend}"; - - # treated "normally", you could change the time/user name to whatever - time = "{sb $Z}"; - user = "{sb {sbnickmode $cumode}$N{sbmode $usermode}{sbaway $A}}"; - - # treated specially .. window is printed with non-empty windows, - # window_empty is printed with empty windows - window = "{sb $winref:$tag/$itemname{sbmode $M}}"; - window_empty = "{sb $winref{sbservertag $tag}}"; - prompt = "{prompt $[.15]itemname}"; - prompt_empty = "{prompt $winname}"; - topic = " $topic"; - topic_empty = " Irssi v$J - http://www.irssi.org"; - - # all of these treated specially, they're only displayed when needed - lag = "{sb Lag: $0-}"; - act = "{sb Act: $0-}"; - more = "-- more --"; - }; - - # there's two type of statusbars. root statusbars are either at the top - # of the screen or at the bottom of the screen. window statusbars are at - # the top/bottom of each split window in screen. - default = { - # the "default statusbar" to be displayed at the bottom of the window. - # contains all the normal items. - window = { - disabled = "yes"; - - # window, root - type = "window"; - # top, bottom - placement = "bottom"; - # number - position = "1"; - # active, inactive, always - visible = "active"; - - # list of items in statusbar in the display order - items = { - barstart = { priority = "100"; }; - time = { }; - user = { }; - window = { }; - window_empty = { }; - lag = { priority = "-1"; }; - more = { priority = "-1"; alignment = "right"; }; - barend = { priority = "100"; alignment = "right"; }; - }; - }; - - # statusbar to use in inactive split windows - window_inact = { - type = "window"; - placement = "bottom"; - position = "1"; - visible = "inactive"; - items = { - barstart = { priority = "100"; }; - window = { }; - window_empty = { }; - more = { priority = "-1"; alignment = "right"; }; - barend = { priority = "100"; alignment = "right"; }; - }; - }; - - # we treat input line as yet another statusbar :) It's possible to - # add other items before or after the input line item. - prompt = { - type = "root"; - placement = "bottom"; - # we want to be at the bottom always - position = "100"; - visible = "always"; - items = { - prompt = { priority = "-1"; }; - prompt_empty = { priority = "-1"; }; - # treated specially, this is the real input line. - input = { priority = "10"; }; - }; - }; - - # topicbar - topic = { - type = "root"; - placement = "top"; - position = "1"; - visible = "always"; - items = { - topicbarstart = { priority = "100"; }; - time = { priority = "100"; }; - topic = { }; - topic_empty = { }; - window_empty = { alignment = "right"; }; - user = { priority = "100"; alignment = "right"; }; - topicbarend = { priority = "100"; alignment = "right"; }; - }; - }; - placement = { items = { }; disabled = "yes"; }; - remove = { disabled = "yes"; }; - awl_0 = { - items = { - barstart = { priority = "100"; }; - awl_0 = { }; - barend = { priority = "100"; alignment = "right"; }; - }; - }; - awl_1 = { - items = { - barstart = { priority = "100"; }; - awl_1 = { }; - barend = { priority = "100"; alignment = "right"; }; - }; - }; - awl_2 = { - items = { - barstart = { priority = "100"; }; - awl_2 = { }; - barend = { priority = "100"; alignment = "right"; }; - }; - }; - }; -}; -settings = { - core = { - real_name = "Matir"; - user_name = "matir"; - nick = "Matir"; - log_timestamp = "%Y%m%d %H%M"; - }; - "fe-text" = { actlist_sort = "refnum"; }; - "fe-common/core" = { - autolog = "yes"; - autolog_path = "~/irclogs/%Y/%m/$tag/$0.log"; - autoclose_query = "1800"; - autocreate_own_query = "no"; - show_nickmode_empty = "no"; - term_charset = "utf-8"; - }; - "perl/core/scripts" = { - awl_shared_sbar = "OFF"; - awl_viewer = "no"; - awl_block = "-15"; - awl_maxlines = "3"; - awl_height_adjust = "2"; - awl_hide_empty = "0"; - }; -}; -windows = { - 1 = { immortal = "yes"; name = "(status)"; level = "ALL"; }; - 2 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#kali-linux"; - tag = "freenode"; - } - ); - }; - 3 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#radare"; - tag = "freenode"; - } - ); - }; - 4 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#vulnhub"; - tag = "freenode"; - } - ); - }; - 5 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#openvpn"; - tag = "freenode"; - } - ); - }; - 6 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#wargames"; - tag = "overthewire"; - } - ); - }; - 7 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#social"; - tag = "overthewire"; - } - ); - }; - 8 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#amateria"; - tag = "overthewire"; - } - ); - }; - 9 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#io"; - tag = "overthewire"; - } - ); - }; - 10 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#RedditNet"; - tag = "geekshed"; - } - ); - }; - 11 = { - items = ( - { - type = "CHANNEL"; - chat_type = "IRC"; - name = "#hak5"; - tag = "secfo"; - } - ); - }; -}; -mainwindows = { 1 = { first_line = "1"; lines = "78"; }; }; -logs = { }; diff --git a/dotfiles/irssi/default.theme b/dotfiles/irssi/default.theme deleted file mode 100644 index be5d086..0000000 --- a/dotfiles/irssi/default.theme +++ /dev/null @@ -1,297 +0,0 @@ -# When testing changes, the easiest way to reload the theme is with /RELOAD. -# This reloads the configuration file too, so if you did any changes remember -# to /SAVE it first. Remember also that /SAVE overwrites the theme file with -# old data so keep backups :) - -# TEMPLATES: - -# The real text formats that irssi uses are the ones you can find with -# /FORMAT command. Back in the old days all the colors and texts were mixed -# up in those formats, and it was really hard to change the colors since you -# might have had to change them in tens of different places. So, then came -# this templating system. - -# Now the /FORMATs don't have any colors in them, and they also have very -# little other styling. Most of the stuff you need to change is in this -# theme file. If you can't change something here, you can always go back -# to change the /FORMATs directly, they're also saved in these .theme files. - -# So .. the templates. They're those {blahblah} parts you see all over the -# /FORMATs and here. Their usage is simply {name parameter1 parameter2}. -# When irssi sees this kind of text, it goes to find "name" from abstracts -# block below and sets "parameter1" into $0 and "parameter2" into $1 (you -# can have more parameters of course). Templates can have subtemplates. -# Here's a small example: -# /FORMAT format hello {colorify {underline world}} -# abstracts = { colorify = "%G$0-%n"; underline = "%U$0-%U"; } -# When irssi expands the templates in "format", the final string would be: -# hello %G%Uworld%U%n -# ie. underlined bright green "world" text. -# and why "$0-", why not "$0"? $0 would only mean the first parameter, -# $0- means all the parameters. With {underline hello world} you'd really -# want to underline both of the words, not just the hello (and world would -# actually be removed entirely). - -# COLORS: - -# You can find definitions for the color format codes in docs/formats.txt. - -# There's one difference here though. %n format. Normally it means the -# default color of the terminal (white mostly), but here it means the -# "reset color back to the one it was in higher template". For example -# if there was /FORMAT test %g{foo}bar, and foo = "%Y$0%n", irssi would -# print yellow "foo" (as set with %Y) but "bar" would be green, which was -# set at the beginning before the {foo} template. If there wasn't the %g -# at start, the normal behaviour of %n would occur. If you _really_ want -# to use the terminal's default color, use %N. - -############################################################################# - -# default foreground color (%N) - -1 is the "default terminal color" -default_color = "-1"; - -# print timestamp/servertag at the end of line, not at beginning -info_eol = "false"; - -# these characters are automatically replaced with specified color -# (dark grey by default) -replaces = { "[]=" = "%K$*%n"; }; - -abstracts = { - ## - ## generic - ## - - # text to insert at the beginning of each non-message line - line_start = "%B-%n!%B-%n "; - - # timestamp styling, nothing by default - timestamp = "$*"; - - # any kind of text that needs hilighting, default is to bold - hilight = "%_$*%_"; - - # any kind of error message, default is bright red - error = "%R$*%n"; - - # channel name is printed - channel = "%_$*%_"; - - # nick is printed - nick = "%_$*%_"; - - # nick host is printed - nickhost = "[$*]"; - - # server name is printed - server = "%_$*%_"; - - # some kind of comment is printed - comment = "[$*]"; - - # reason for something is printed (part, quit, kick, ..) - reason = "{comment $*}"; - - # mode change is printed ([+o nick]) - mode = "{comment $*}"; - - ## - ## channel specific messages - ## - - # highlighted nick/host is printed (joins) - channick_hilight = "%C$*%n"; - chanhost_hilight = "{nickhost %c$*%n}"; - - # nick/host is printed (parts, quits, etc.) - channick = "%c$*%n"; - chanhost = "{nickhost $*}"; - - # highlighted channel name is printed - channelhilight = "%c$*%n"; - - # ban/ban exception/invite list mask is printed - ban = "%c$*%n"; - - ## - ## messages - ## - - # the basic styling of how to print message, $0 = nick mode, $1 = nick - msgnick = "%K<%n$0$1-%K>%n %|"; - - # message from you is printed. "msgownnick" specifies the styling of the - # nick ($0 part in msgnick) and "ownmsgnick" specifies the styling of the - # whole line. - - # Example1: You want the message text to be green: - # ownmsgnick = "{msgnick $0 $1-}%g"; - # Example2.1: You want < and > chars to be yellow: - # ownmsgnick = "%Y{msgnick $0 $1-%Y}%n"; - # (you'll also have to remove <> from replaces list above) - # Example2.2: But you still want to keep <> grey for other messages: - # pubmsgnick = "%K{msgnick $0 $1-%K}%n"; - # pubmsgmenick = "%K{msgnick $0 $1-%K}%n"; - # pubmsghinick = "%K{msgnick $1 $0$2-%n%K}%n"; - # ownprivmsgnick = "%K{msgnick $*%K}%n"; - # privmsgnick = "%K{msgnick %R$*%K}%n"; - - # $0 = nick mode, $1 = nick - ownmsgnick = "{msgnick $0 $1-}"; - ownnick = "%_$*%n"; - - # public message in channel, $0 = nick mode, $1 = nick - pubmsgnick = "{msgnick $0 $1-}"; - pubnick = "%N$*%n"; - - # public message in channel meant for me, $0 = nick mode, $1 = nick - pubmsgmenick = "{msgnick $0 $1-}"; - menick = "%Y$*%n"; - - # public highlighted message in channel - # $0 = highlight color, $1 = nick mode, $2 = nick - pubmsghinick = "{msgnick $1 $0$2-%n}"; - - # channel name is printed with message - msgchannel = "%K:%c$*%n"; - - # private message, $0 = nick, $1 = host - privmsg = "[%R$0%K(%r$1-%K)%n] "; - - # private message from you, $0 = "msg", $1 = target nick - ownprivmsg = "[%r$0%K(%R$1-%K)%n] "; - - # own private message in query - ownprivmsgnick = "{msgnick $*}"; - ownprivnick = "%_$*%n"; - - # private message in query - privmsgnick = "{msgnick %R$*%n}"; - - ## - ## Actions (/ME stuff) - ## - - # used internally by this theme - action_core = "%_ * $*%n"; - - # generic one that's used by most actions - action = "{action_core $*} "; - - # own action, both private/public - ownaction = "{action $*}"; - - # own action with target, both private/public - ownaction_target = "{action_core $0}%K:%c$1%n "; - - # private action sent by others - pvtaction = "%_ (*) $*%n "; - pvtaction_query = "{action $*}"; - - # public action sent by others - pubaction = "{action $*}"; - - - ## - ## other IRC events - ## - - # whois - whois = "%# $[8]0 : $1-"; - - # notices - ownnotice = "[%r$0%K(%R$1-%K)]%n "; - notice = "%K-%M$*%K-%n "; - pubnotice_channel = "%K:%m$*"; - pvtnotice_host = "%K(%m$*%K)"; - servernotice = "%g!$*%n "; - - # CTCPs - ownctcp = "[%r$0%K(%R$1-%K)] "; - ctcp = "%g$*%n"; - - # wallops - wallop = "%_$*%n: "; - wallop_nick = "%n$*"; - wallop_action = "%_ * $*%n "; - - # netsplits - netsplit = "%R$*%n"; - netjoin = "%C$*%n"; - - # /names list - names_prefix = ""; - names_nick = "[%_$0%_$1-] "; - names_nick_op = "{names_nick $*}"; - names_nick_halfop = "{names_nick $*}"; - names_nick_voice = "{names_nick $*}"; - names_users = "[%g$*%n]"; - names_channel = "%G$*%n"; - - # DCC - dcc = "%g$*%n"; - dccfile = "%_$*%_"; - - # DCC chat, own msg/action - dccownmsg = "[%r$0%K($1-%K)%n] "; - dccownnick = "%R$*%n"; - dccownquerynick = "%_$*%n"; - dccownaction = "{action $*}"; - dccownaction_target = "{action_core $0}%K:%c$1%n "; - - # DCC chat, others - dccmsg = "[%G$1-%K(%g$0%K)%n] "; - dccquerynick = "%G$*%n"; - dccaction = "%_ (*dcc*) $*%n %|"; - - ## - ## statusbar - ## - - # default background for all statusbars. You can also give - # the default foreground color for statusbar items. - sb_background = "%4%w"; - - # default backround for "default" statusbar group - #sb_default_bg = "%4"; - # background for prompt / input line - sb_prompt_bg = "%n"; - # background for info statusbar - sb_info_bg = "%8"; - # background for topicbar (same default) - #sb_topic_bg = "%4"; - - # text at the beginning of statusbars. sb-item already puts - # space there,so we don't use anything by default. - sbstart = ""; - # text at the end of statusbars. Use space so that it's never - # used for anything. - sbend = " "; - - topicsbstart = "{sbstart $*}"; - topicsbend = "{sbend $*}"; - - prompt = "[$*] "; - - sb = " %c[%n$*%c]%n"; - sbmode = "(%c+%n$*)"; - sbaway = " (%GzZzZ%n)"; - sbservertag = ":$0 (change with ^X)"; - sbnickmode = "$0"; - - # activity in statusbar - - # ',' separator - sb_act_sep = "%c$*"; - # normal text - sb_act_text = "%c$*"; - # public message - sb_act_msg = "%W$*"; - # hilight - sb_act_hilight = "%M$*"; - # hilight with specified color, $0 = color, $1 = text - sb_act_hilight_color = "$0$1-%n"; -}; -formats = { - "Irssi::Script::adv_windowlist" = { awl_display_header = ""; }; -}; diff --git a/dotfiles/irssi/instantssl.crt b/dotfiles/irssi/instantssl.crt deleted file mode 100644 index 6474e78..0000000 --- a/dotfiles/irssi/instantssl.crt +++ /dev/null @@ -1,26 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCB -lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug -Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho -dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt -SGFyZHdhcmUwHhcNOTkwNzA5MTgxMDQyWhcNMTkwNzA5MTgxOTIyWjCBlzELMAkG -A1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEe -MBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8v -d3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdh -cmUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCx98M4P7Sof885glFn -0G2f0v9Y8+efK+wNiVSZuTiZFvfgIXlIwrthdBKWHTxqctU8EGc6Oe0rE81m65UJ -M6Rsl7HoxuzBdXmcRl6Nq9Bq/bkqVRcQVLMZ8Jr28bFdtqdt++BxF2uiiPsA3/4a -MXcMmgF6sTLjKwEHOG7DpV4jvEWbe1DByTCP2+UretNb+zNAHqDVmBe8i4fDidNd -oI6yqqr2jmmIBsX6iSHzCJ1pLgkzmykNRg+MzEk0sGlRvfkGzWitZky8PqxhvQqI -DsjfPe58BEydCl5rkdbux+0ojatNh4lz0G6k0B4WixThdkQDf2Os5M1JnMWS9Ksy -oUhbAgMBAAGjgbkwgbYwCwYDVR0PBAQDAgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYD -VR0OBBYEFKFyXyYbKJhDlV0HN9WFlp1L0sNFMEQGA1UdHwQ9MDswOaA3oDWGM2h0 -dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNFUkZpcnN0LUhhcmR3YXJlLmNy -bDAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEF -BQcDBzANBgkqhkiG9w0BAQUFAAOCAQEARxkP3nTGmZev/K0oXnWO6y1n7k57K9cM -//bey1WiCuFMVGWTYGufEpytXoMs61quwOQt9ABjHbjAbPLPSbtNk28Gpgoiskli -CE7/yMgUsogWXecB5BKV5UU0s4tpvc+0hY91UZ59Ojg6FEgSxvunOxqNDYJAB+gE -CJChicsZUN/KHAG8HQQZexB2lzvukJDKxA4fFm517zP4029bHpbj4HR3dHuKom4t -3XbWOTCC8KucUvIqx69JXn7HaOWCgchqJ/kniCrVWFCVH/A7HFe7fRQ5YiuayZSS -KqMiDP+JJn1fIytH1xUdqWqeUQ0qUZ6B+dQ7XnASfxAynB67nfhmqA== ------END CERTIFICATE----- \ No newline at end of file diff --git a/dotfiles/irssi/scripts/adv_windowlist.pl b/dotfiles/irssi/scripts/adv_windowlist.pl deleted file mode 100644 index bfb6544..0000000 --- a/dotfiles/irssi/scripts/adv_windowlist.pl +++ /dev/null @@ -1,2088 +0,0 @@ -use strict; -use warnings; - -our $VERSION = '0.9b5'; -our %IRSSI = ( - authors => 'Nei', - contact => 'Nei @ anti@conference.jabber.teamidiot.de', - url => "http://anti.teamidiot.de/", - name => 'awl', - description => 'Adds a permanent advanced window list on the right or in a status bar.', - license => 'GNU GPLv2 or later', - ); - -# UPGRADE NOTE -# ============ -# for users of 0.7 or earlier series, please note that appearance -# settings have moved to /format, i.e. inside your theme! -# the fifo (screen) has been replaced by an external viewer script - -# Usage -# ===== -# copy the script to ~/.irssi/scripts/ -# -# In irssi: -# -# /run adv_windowlist -# -# In your shell (for example a tmux split): -# -# perl ~/.irssi/scripts/adv_windowlist.pl -# -# To use sbar mode instead: -# -# /toggle awl_viewer -# -# Hint: to get rid of the old [Act:] display -# /statusbar window remove act -# -# to get it back: -# /statusbar window add -after lag -priority 10 act - -# Options -# ======= -# formats can be cleared with /format -delete -# -# /format awl_display_(no)key(_active|_visible) -# * string : Format String for one window. The following $'s are expanded: -# $C : Name -# $N : Number of the Window -# $Q : meta-Keymap -# $H : Start hilighting -# $S : Stop hilighting -# /+++++++++++++++++++++++++++++++++, -# | **** I M P O R T A N T : **** | -# | | -# | don't forget to use $S if you | -# | used $H before! | -# | | -# '+++++++++++++++++++++++++++++++++/ -# key : a key binding that goes to this window could be detected in /bind -# nokey : no such key binding was detected -# active : window would receive the input you are currently typing -# visible : window is also visible on screen but not active (a split window) -# -# /format awl_name_display -# * string : Format String for window names -# -# /format awl_display_header -# * string : Format String for this header line. The following $'s are expanded: -# $C : network tag -# -# /format awl_separator(2) -# * string : Character to use between the channel entries -# variant 2 can be used for alternating separators (only in status bar -# without block display) -# -# /format awl_viewer_item_bg -# * string : Format String specifying the viewer's item background colour -# -# /set awl_prefer_name -# * this setting decides whether awl will use the active_name (OFF) or the -# window name as the name/caption in awl_display_*. -# That way you can rename windows using /window name myownname. -# -# /set awl_hide_empty -# * if visible windows without items should be hidden from the window list -# set it to 0 to show all windows -# 1 to hide visible windows without items (negative exempt -# active window) -# -# /set awl_hide_data -# * num : hide the window if its data_level is below num -# set it to 0 to basically disable this feature, -# 1 if you don't want windows without activity to be shown -# 2 to show only those windows with channel text or hilight -# 3 to show only windows with hilight (negative exempt active window) -# -# /set awl_hide_name_data -# * num : hide the name of the window if its data_level is below num -# (only works in status bar without block display) -# you will want to change your formats to add $H...$S around $Q or $N -# if you plan to use this -# -# /set awl_maxlines -# * num : number of lines to use for the window list (0 to disable, negative -# lock) -# -# /set awl_block -# * num : width of a column in viewer mode (negative values = block -# display in status bar mode) -# /+++++++++++++++++++++++++++++++++, -# | ****** W A R N I N G ! ****** | -# | | -# | If your block display looks | -# | DISTORTED, you need to add the | -# | following line to your .theme | -# | file under | -# | abstracts = { : | -# | | -# | sb_act_none = "%K$*"; | -# | | -# '+++++++++++++++++++++++++++++++++/ -# -# /set awl_sbar_maxlength -# * if you enable the maxlength setting, the block width will be used as a -# maximum length for the non-block status bar mode too. -# -# /set awl_height_adjust -# * num : how many lines to leave empty in viewer mode -# -# /set awl_sort <-data_level|-last_line|refnum> -# * you can change the window sort order with this variable -# -data_level : sort windows with hilight first -# -last_line : sort windows in order of activity -# refnum : sort windows by window number -# active/server/tag : sort by server name -# "-" reverses the sort order -# typechecks are supported via ::, e.g. active::Query or active::Irc::Query -# undefinedness can be checked with ~, e.g. ~active -# string comparison can be done with =, e.g. name=(status) -# any key in the window hash can be tested, e.g. active/chat_type=XMPP -# multiple criteria can be separated with , or +, e.g. -data_level+-last_line -# -# /set awl_placement -# /set awl_position -# * these settings correspond to /statusbar because awl will create -# status bars for you -# (see /help statusbar to learn more) -# -# /set awl_all_disable -# * if you set awl_all_disable to ON, awl will also remove the -# last status bar it created if it is empty. -# As you might guess, this only makes sense with awl_hide_data > 0 ;) -# -# /set awl_viewer -# * enable the external viewer script -# -# /set awl_shared_sbar -# * share a status bar for the first awl item, you will need to manually -# /statusbar window add -after lag -priority 10 awl_shared -# left : space in cells occupied on the left of status bar -# right : space occupied on the right -# -# /set awl_path -# * path to the file which the viewer script reads -# -# /set fancy_abbrev -# * how to shorten too long names -# no : shorten in the middle -# head : always cut off the ends -# strict : shorten repeating substrings -# fancy : combination of no+strict -# -# /set awl_custom_xform -# * specify a custom routine to transform window names -# example: s/^#// remove the #-mark of IRC channels -# the special variables $CHANNEL / $TAG / $QUERY can be tested in -# conditionals -# -# /set awl_last_line_shade -# * set timeout to shade activity base colours, to enable -# you also need to add +-last_line to awl_sort -# (requires 256 colour support) -# -# /set awl_mouse -# * enable the terminal mouse in irssi -# (use the awl-patched mouse.pl for gestures and commands if you need -# them and disable mouse_escape) -# -# /set awl_mouse_offset -# * specifies where on the screen is the awl status bar -# (0 = on top/bottom, 1 = one additional line in between, -# e.g. prompt) -# you MUST set this correctly otherwise the mouse coordinates will -# be off -# -# /set mouse_scroll -# * how many lines the mouse wheel scrolls -# -# /set mouse_escape -# * seconds to disable the mouse, when not clicked on the windowlist -# - -# Commands -# ======== -# /awl redraw -# * redraws the windowlist. There may be occasions where the -# windowlist can get destroyed so you can use this command to -# force a redraw. - -# Nei =^.^= ( anti@conference.jabber.teamidiot.de ) - -no warnings 'redefine'; -use constant IN_IRSSI => __PACKAGE__ ne 'main' || $ENV{IRSSI_MOCK}; -no if !IN_IRSSI, strict => (qw(subs refs)); -use if IN_IRSSI, Irssi => (); -use if IN_IRSSI, 'Irssi::TextUI' => (); -use v5.10; -use Encode; -use Storable (); -use IO::Socket::UNIX; -use List::Util qw(min max reduce); -use Hash::Util qw(lock_keys); - -unless (IN_IRSSI) { - local *_ = \@ARGV; - &AwlViewer::main; - exit; -} - - -use constant GLOB_QUEUE_TIMER => 100; - -our $BLOCK_ALL; # localized blocker -my @actString; # status bar texts -my @win_items; -my $currentLines = 0; -my %awins; -my $globTime; # timer to limit remake calls - -my %CHANGED; -my $VIEWER_MODE; -my $MOUSE_ON; -my %mouse_coords; -my %statusbars; -my %S; # settings -my $settings_str = ''; -my $window_sort_func; -my $custom_xform; -my ($sb_base_width, $sb_base_width_pre, $sb_base_width_post); -my $print_text_activity; -my $shade_line_timer; -my ($screenHeight, $screenWidth); -my %viewer; - -my (%keymap, %nummap, %wnmap, %specialmap, %wnmap_exp, %custom_key_map); -my %banned_channels; -my %abbrev_cache; - -sub setc () { - $IRSSI{name} -} - -sub set ($) { - setc . '_' . $_[0] -} - -sub add_statusbar { - for (@_) { - # add subs - my $l = set $_; - { - my $close = $_; - no strict 'refs'; - *{$l} = sub { awl($close, @_) }; - } - Irssi::command("statusbar $l reset"); - Irssi::command("statusbar $l enable"); - if (lc $S{placement} eq 'top') { - Irssi::command("statusbar $l placement top"); - } - if (my $x = $S{position}) { - Irssi::command("statusbar $l position $x"); - } - Irssi::command("statusbar $l add -priority 100 -alignment left barstart"); - Irssi::command("statusbar $l add $l"); - Irssi::command("statusbar $l add -priority 100 -alignment right barend"); - Irssi::command("statusbar $l disable"); - Irssi::statusbar_item_register($l, '$0', $l); - $statusbars{$_} = 1; - Irssi::command("statusbar $l enable"); - } -} - -sub remove_statusbar { - for (@_) { - my $l = set $_; - Irssi::command("statusbar $l disable"); - Irssi::command("statusbar $l reset"); - Irssi::statusbar_item_unregister($l); - { - no strict 'refs'; - undef &{$l}; - } - delete $statusbars{$_}; - } -} - -my $awl_shared_empty = sub { - return if $BLOCK_ALL; - my ($item, $get_size_only) = @_; - $item->default_handler($get_size_only, '', '', 0); -}; - -sub syncLines { - my $maxLines = $S{maxlines}; - my $newLines = ($maxLines > 0 and @actString > $maxLines) ? - $maxLines : - ($maxLines < 0) ? - -$maxLines : - @actString; - $currentLines = 1 if !$currentLines && $S{shared_sbar}; - if ($S{shared_sbar} && !$statusbars{shared}) { - my $l = set 'shared'; - { - no strict 'refs'; - *{$l} = sub { - return if $BLOCK_ALL; - my ($item, $get_size_only) = @_; - - my $text = $actString[0]; - my $pat = defined $text ? '{sb '.ucfirst(setc()).': $*}' : '{sb }'; - $text //= ''; - $item->default_handler($get_size_only, $pat, $text, 0); - }; - } - $statusbars{shared} = 1; - remove_statusbar (0) if $statusbars{0}; - } - elsif ($statusbars{shared} && !$S{shared_sbar}) { - add_statusbar (0) if $currentLines && $newLines; - delete $statusbars{shared}; - my $l = set 'shared'; - { - no strict 'refs'; - *{$l} = $awl_shared_empty; - } - } - if ($currentLines == $newLines) { return; } - elsif ($newLines > $currentLines) { - add_statusbar ($currentLines .. ($newLines - 1)); - } - else { - remove_statusbar (reverse ($newLines .. ($currentLines - 1))); - } - $currentLines = $newLines; -} - -sub awl { - return if $BLOCK_ALL; - my ($line, $item, $get_size_only) = @_; - - my $text = $actString[$line]; - my $pat = defined $text ? '{sb $*}' : '{sb }'; - $text //= ''; - $item->default_handler($get_size_only, $pat, $text, 0); -} - -# remove old statusbars -{ my %killBar; - sub get_old_status { - my ($textDest, $cont, $cont_stripped) = @_; - if ($textDest->{level} == 524288 and $textDest->{target} eq '' and !defined $textDest->{server}) { - my $name = quotemeta(set ''); - if ($cont_stripped =~ m/^$name(\d+)\s/) { $killBar{$1} = 1; } - Irssi::signal_stop; - } - } - sub killOldStatus { - %killBar = (); - Irssi::signal_add_first('print text' => 'get_old_status'); - Irssi::command('statusbar'); - Irssi::signal_remove('print text' => 'get_old_status'); - remove_statusbar(keys %killBar); - } -} - -sub get_keymap { - my ($textDest, undef, $cont_stripped) = @_; - if ($textDest->{level} == 524288 and $textDest->{target} eq '' and !defined $textDest->{server}) { - my $one_meta_or_ctrl_key = qr/((?:meta-)*?)(?:(meta-|\^)(\S)|(\w+))/; - $cont_stripped = as_uni($cont_stripped); - if ($cont_stripped =~ m/((?:$one_meta_or_ctrl_key-)*$one_meta_or_ctrl_key)\s+(.*)$/) { - my ($combo, $command) = ($1, $10); - my $map = ''; - while ($combo =~ s/(?:-|^)$one_meta_or_ctrl_key$//) { - my ($level, $ctl, $key, $nkey) = ($1, $2, $3, $4); - my $numlevel = ($level =~ y/-//); - $ctl = '' if !$ctl || $ctl ne '^'; - $map = ('-' x ($numlevel%2)) . ('+' x ($numlevel/2)) . - $ctl . (defined $key ? $key : "\01$nkey\01") . $map; - } - for ($command) { - last unless length $map; - if (/^change_window (\d+)/i) { - $nummap{$1} = $map; - } - elsif (/^command window goto (\S+)/i) { - my $window = $1; - if ($window !~ /\D/) { - $nummap{$window} = $map; - } - elsif (lc $window eq 'active') { - $specialmap{_active} = $map; - } - else { - $wnmap{$window} = $map; - } - } - elsif (/^(?:active_window|command (ack))/i) { - $specialmap{_active} = $map; - $viewer{use_ack} = !!$1; - } - elsif (/^command window last/i) { - $specialmap{_last} = $map; - } - elsif (/^(?:upper_window|command window up)/i) { - $specialmap{_up} = $map; - } - elsif (/^(?:lower_window|command window down)/i) { - $specialmap{_down} = $map; - } - elsif (/^key\s+(\w+)/i) { - $custom_key_map{$1} = $map; - } - } - } - Irssi::signal_stop; - } -} - -sub update_keymap { - %nummap = %wnmap = %specialmap = %custom_key_map = (); - Irssi::signal_remove('command bind' => 'watch_keymap'); - Irssi::signal_add_first('print text' => 'get_keymap'); - Irssi::command('bind'); - Irssi::signal_remove('print text' => 'get_keymap'); - for (keys %custom_key_map) { - if (exists $custom_key_map{$_} && - $custom_key_map{$_} =~ s/\01(\w+)\01/exists $custom_key_map{$1} ? $custom_key_map{$1} : "\02"/ge) { - if ($custom_key_map{$_} =~ /\02/) { - delete $custom_key_map{$_}; - } - else { - redo; - } - } - } - for my $keymap (\(%specialmap, %wnmap, %nummap)) { - for (keys %$keymap) { - if ($keymap->{$_} =~ s/\01(\w+)\01/exists $custom_key_map{$1} ? $custom_key_map{$1} : "\02"/ge) { - if ($keymap->{$_} =~ /\02/) { - delete $keymap->{$_}; - } - } - } - } - Irssi::signal_add('command bind' => 'watch_keymap'); - delete $viewer{client_keymap}; - &wl_changed; -} - -# watch keymap changes -sub watch_keymap { - Irssi::timeout_add_once(1000, 'update_keymap', undef); -} - -{ my %strip_table = ( - # fe-common::core::formats.c:format_expand_styles - # delete format_backs format_fores bold_fores other stuff - (map { $_ => '' } (split //, '04261537' . 'kbgcrmyw' . 'KBGCRMYW' . 'U9_8I:|FnN>#[' . 'pP')), - # escape - (map { $_ => $_ } (split //, '{}%')), - ); - sub ir_strip_codes { # strip %codes - my $o = shift; - $o =~ s/(%(%|Z.{6}|z.{6}|X..|x..|.))/exists $strip_table{$2} ? $strip_table{$2} : - $2 =~ m{x(?:0[a-f]|[1-6][0-9a-z]|7[a-x])|z[0-9a-f]{6}}i ? '' : $1/gex; - $o - } -} -## ir_parse_special -- wrapper around parse_special -## $i - input format -## $args - array ref of arguments to format -## $win - different target window (default current window) -## $flags - different kind of escape flags (default 4|8) -## returns formatted str -sub ir_parse_special { - my $o; - my $i = shift; - my $args = shift // []; - y/ /\177/ for @$args; # hack to escape spaces - my $win = shift || Irssi::active_win; - my $flags = shift // 0x4|0x8; - my @cmd_args = ($i, (join ' ', @$args), $flags); - my $server = Irssi::active_server(); - if (ref $win and ref $win->{active}) { - $o = $win->{active}->parse_special(@cmd_args); - } - elsif (ref $win and ref $win->{active_server}) { - $o = $win->{active_server}->parse_special(@cmd_args); - } - elsif (ref $server) { - $o = $server->parse_special(@cmd_args); - } - else { - $o = &Irssi::parse_special(@cmd_args); - } - $o =~ y/\177/ /; - $o -} - -sub sb_format_expand { # Irssi::current_theme->format_expand wrapper - Irssi::current_theme->format_expand( - $_[0], - ( - Irssi::EXPAND_FLAG_IGNORE_REPLACES - | - ($_[1] ? 0 : Irssi::EXPAND_FLAG_IGNORE_EMPTY) - ) - ) -} - -{ my $term_type = Irssi::version > 20040819 ? 'term_charset' : 'term_type'; - local $@; - eval { require Text::CharWidth; }; - unless ($@) { - *screen_length = sub { Text::CharWidth::mbswidth($_[0]) }; - } - else { - my $err = $@; chomp $err; $err =~ s/\sat .* line \d+\.$//; - #Irssi::print("%_$IRSSI{name}: warning:%_ Text::CharWidth module failed to load. Length calculation may be off! Error was:"); - print "%_$IRSSI{name}:%_ $err"; - *screen_length = sub { - my $temp = shift; - if (lc Irssi::settings_get_str($term_type) eq 'utf-8') { - Encode::_utf8_on($temp); - } - length($temp) - }; - } - sub as_uni { - no warnings 'utf8'; - Encode::decode(Irssi::settings_get_str($term_type), $_[0], 0) - } - sub as_tc { - Encode::encode(Irssi::settings_get_str($term_type), $_[0], 0) - } -} - -sub sb_length { - screen_length(ir_strip_codes($_[0])) -} - -sub run_custom_xform { - local $@; - eval { - $custom_xform->() - }; - if ($@) { - $@ =~ /^(.*)/; - print '%_'.(set 'custom_xform').'%_ died (disabling): '.$1; - $custom_xform = undef; - } -} - -sub remove_uniform { - my $o = shift; - $o =~ s/^xmpp:(.*?[%@]).+\.[^.]+$/$1/ or - $o =~ s#^psyc://.+\.[^.]+/([@~].*)$#$1#; - if ($custom_xform) { - run_custom_xform() for $o; - } - $o -} - -sub remove_uniform_vars { - my $win = shift; - no strict 'refs'; - my $name = __PACKAGE__ . '::custom_xform::' . $win->{active}{type} - if $win->{active} && $win->{active}{type}; - local ${$name} = 1 if $name; - remove_uniform(+shift); -} - -sub lc1459 { - my $x = shift; - $x =~ y/][\\^/}{|~/; - lc $x -} - -sub window_list { - sort $window_sort_func Irssi::windows; -} - -sub _calculate_abbrev { - my ($wins, $abbrevList) = @_; - if ($S{fancy_abbrev} !~ /^(no|off|head)/i) { - my @nameList = map { ref $_ ? remove_uniform_vars($_, as_uni($_->get_active_name) // '') : '' } @$wins; - for (my $i = 0; $i < @nameList - 1; ++$i) { - my ($x, $y) = ($nameList[$i], $nameList[$i + 1]); - s/^[+#!=]// for $x, $y; - my $res = exists $abbrev_cache{$x}{$y} ? $abbrev_cache{$x}{$y} - : $abbrev_cache{$x}{$y} = string_LCSS($x, $y); - if (defined $res) { - for ($nameList[$i], $nameList[$i + 1]) { - $abbrevList->{$_} //= int((index $_, $res) + (length $res) / 2); - } - } - } - } -} - -my %act_last_line_shades = ( - r => [qw[ 50 40 30 20 ]], - g => [qw[ 1O 1I 1C 16 ]], - y => [qw[ 5O 4I 3C 26 ]], - b => [qw[ 15 14 13 12 ]], - m => [qw[ 54 43 32 21 ]], - c => [qw[ 1S 1L 1E 17 ]], - w => [qw[ 7W 7T 7Q 3E ]], - K => [qw[ 7M 7K 27 7H ]], - R => [qw[ 60 50 40 30 ]], - G => [qw[ 1U 1O 1I 1C ]], - Y => [qw[ 6U 5O 4I 3C ]], - B => [qw[ 2B 2A 29 28 ]], - M => [qw[ 65 54 43 32 ]], - C => [qw[ 1Z 1S 1L 1E ]], - W => [qw[ 6Z 5S 7R 7O ]], - ); - -sub _format_display { - my (undef, $format, $cformat, $hilight, $name, $number, $key, $win) = @_; - if ($print_text_activity && $S{line_shade}) { - my @hilight_code = split /\177/, sb_format_expand("{$hilight \177}"), 2; - my $max_time = max(1, log($S{line_shade}) - log(1000)); - my $time_delta = min(3, min($max_time, log(max(1, time - $win->{last_line}))) / $max_time * 3); - if ($hilight_code[0] =~ /%(.)/ && exists $act_last_line_shades{$1}) { - $hilight = 'sb_act_hilight_color %X'.$act_last_line_shades{$1}[$time_delta]; - } - } - $cformat = '$0' unless defined $cformat && length $cformat; - my %map = ('$C' => $cformat, '$N' => '$1', '$Q' => '$2'); - $format =~ s<(\$.)><$map{$1}//$1>ge; - $format =~ s<\$H((?:\$.|[^\$])*?)\$S><{$hilight $1%n}>g; - my @ret = ir_parse_special(sb_format_expand($format), [$name, $number, $key], $win); - @ret -} - -sub _calculate_items { - my ($wins, $abbrevList) = @_; - - my $display_header = Irssi::current_theme->get_format(__PACKAGE__, set 'display_header'); - my $name_format = Irssi::current_theme->get_format(__PACKAGE__, set 'name_display'); - my %displays; - - my $active = Irssi::active_win; - @win_items = (); - %keymap = (%nummap, %wnmap_exp); - - my ($numPad, $keyPad) = (0, 0); - if ($VIEWER_MODE or $S{block} < 0) { - $numPad = length((sort { length $b <=> length $a } keys %keymap)[0]) // 0; - $keyPad = length((sort { length $b <=> length $a } values %keymap)[0]) // 0; - } - my $last_net; - for my $win (@$wins) { - my $global_hack_alert_tag_header; - - next unless ref $win; - - my $backup_win = Storable::dclone($win); - delete $backup_win->{active} unless ref $backup_win->{active}; - - $global_hack_alert_tag_header = - $display_header && ($last_net // '') ne ($backup_win->{active}{server}{tag} // ''); - - if ($win->{data_level} < abs $S{hide_data} - && ($win->{refnum} != $active->{refnum} || 0 <= $S{hide_data})) { - next; } - elsif (exists $awins{$win->{refnum}} && $S{hide_empty} && !$win->items - && ($win->{refnum} != $active->{refnum} || 0 <= $S{hide_empty})) { - next; } - - my $colour = $win->{hilight_color} // ''; - my $hilight = do { - if ($win->{data_level} == 0) { 'sb_act_none'; } - elsif ($win->{data_level} == 1) { 'sb_act_text'; } - elsif ($win->{data_level} == 2) { 'sb_act_msg'; } - elsif ($colour ne '') { "sb_act_hilight_color $colour"; } - elsif ($win->{data_level} == 3) { 'sb_act_hilight'; } - else { 'sb_act_special'; } - }; - my $number = $win->{refnum}; - - my ($name, $display, $cdisplay); - if ($global_hack_alert_tag_header) { - $display = $display_header; - $name = as_uni($backup_win->{active}{server}{tag}) // ''; - if ($custom_xform) { - no strict 'refs'; - local ${ __PACKAGE__ . '::custom_xform::TAG' } = 1; - run_custom_xform() for $name; - } - } - else { - my @display = ('display_nokey'); - if (defined $keymap{$number} and $keymap{$number} ne '') { - unshift @display, map { (my $cpy = $_) =~ s/_no/_/; $cpy } @display; - } - if (exists $awins{$number}) { - unshift @display, map { my $cpy = $_; $cpy .= '_visible'; $cpy } @display; - } - if ($active->{refnum} == $number) { - unshift @display, map { my $cpy = $_; $cpy .= '_active'; $cpy } - grep { !/_visible$/ } @display; - } - $display = (grep { length $_ } - map { $displays{$_} //= Irssi::current_theme->get_format(__PACKAGE__, set $_) } - @display)[0]; - $cdisplay = $name_format; - $name = as_uni($win->get_active_name) // ''; - $name = '*' if $S{banned_on} and exists $banned_channels{lc1459($name)}; - $name = remove_uniform_vars($win, $name) if $name ne '*'; - $name = as_uni($win->{name}) if $name ne '*' and $win->{name} ne '' and $S{prefer_name}; - - if (!$VIEWER_MODE && $S{block} >= 0 && $S{hide_name} - && $win->{data_level} < abs $S{hide_name} - && ($win->{refnum} != $active->{refnum} || 0 <= $S{hide_name})) { - $name = ''; - $cdisplay = ''; - } - } - - $display = "$display%n"; - my $num_ent = (' 'x($numPad - length $number)) . $number; - my $key_ent = exists $keymap{$number} ? ((' 'x($keyPad - length $keymap{$number})) . $keymap{$number}) : ' 'x$keyPad; - if ($VIEWER_MODE or $S{sbar_maxlen} or $S{block} < 0) { - my $baseLength = sb_length(_format_display( - '', $display, $cdisplay, $hilight, - 'x', # placeholder - $num_ent, - $key_ent, - $win)) - 1; - my $diff = (abs $S{block}) - (screen_length(as_tc($name)) + $baseLength); - if ($diff < 0) { # too long - my $screen_length = screen_length(as_tc($name)); - if ((abs $diff) >= $screen_length) { $name = '' } # forget it - elsif ((abs $diff) + screen_length(as_tc(substr($name, 0, 1))) >= $screen_length) { $name = substr($name, 0, 1); } - else { - my $ulen = length $name; - my $middle2 = exists $abbrevList->{$name} ? - ($S{fancy_strict}) ? - 2* $abbrevList->{$name} : - (2*($abbrevList->{$name} + $ulen) / 3) : - ($S{fancy_head}) ? - 2*$ulen : - $ulen; - my $first = 1; - while (length $name > 1) { - my $cp = $middle2 > -1 ? $middle2/2 : -1; # check position for double width - my $rm = 2; - if (screen_length(as_tc(substr $name, $cp, 1)) > 1) { - if ($first || $cp < 0) { - $rm = 1; - $first = undef; - } - } - elsif ($cp < 0) { - --$cp; - } - (substr $name, $cp, $rm) = '~'; - if ($cp > -1 && $rm > 1) { - --$middle2; - } - my $sl = screen_length(as_tc($name)); - if ($sl + $baseLength < abs $S{block}) { - (substr $name, ($middle2+1)/2, 1) = "\x{301c}"; - last; - } - elsif ($sl + $baseLength == abs $S{block}) { - last; - } - } - } - } - elsif ($VIEWER_MODE or $S{block} < 0) { - $name .= (' ' x $diff); - } - } - - push @win_items, _format_display( - '', $display, $cdisplay, $hilight, - as_tc($name), - $num_ent, - as_tc($key_ent), - $win); - - if ($global_hack_alert_tag_header) { - $last_net = $backup_win->{active}{server}{tag}; - redo; - } - - $mouse_coords{refnum}{$#win_items} = $number; - } -} - -sub _spread_items { - my $width = [Irssi::windows]->[0]{width} - $sb_base_width - 1; - my @separator = Irssi::current_theme->get_format(__PACKAGE__, set 'separator'); - if ($S{block} >= 0) { - my $sep2 = Irssi::current_theme->get_format(__PACKAGE__, set 'separator2'); - push @separator, $sep2 if length $sep2 && $sep2 ne $separator[0]; - } - $separator[0] .= '%n'; - my @sepLen = map { sb_length($_) } @separator; - - @actString = (); - my $curLine; - my $curLen = 0; - if ($S{shared_sbar}) { - $curLen += $S{shared_sbar}[0] + 2 + length setc(); - $width -= $S{shared_sbar}[2]; - } - my $mouse_header_check = 0; - for my $it (@win_items) { - my $itemLen = sb_length($it); - if ($curLen) { - if ($curLen + $itemLen + $sepLen[$mouse_header_check % @sepLen] > $width) { - $width += $S{shared_sbar}[2] - if !@actString && $S{shared_sbar}; - push @actString, $curLine; - $curLine = undef; - $curLen = 0; - } - elsif (defined $curLine) { - $curLine .= $separator[$mouse_header_check % @separator]; - $curLen += $sepLen[$mouse_header_check % @sepLen]; - } - } - $curLine .= $it; - if (exists $mouse_coords{refnum}{$mouse_header_check}) { - $mouse_coords{scalar @actString}{ $_ } = $mouse_coords{refnum}{$mouse_header_check} - for $curLen .. $curLen + $itemLen - 1; - } - $curLen += $itemLen; - } - continue { - ++$mouse_header_check; - } - $curLen -= $S{shared_sbar}[0] - if !@actString && $S{shared_sbar}; - push @actString, $curLine if $curLen; -} - -sub remake { - my %abbrevList; - my @wins = window_list(); - if ($VIEWER_MODE or $S{sbar_maxlen} or $S{block} < 0) { - _calculate_abbrev(\@wins, \%abbrevList); - } - - %mouse_coords = ( refnum => +{} ); - _calculate_items(\@wins, \%abbrevList); - - unless ($VIEWER_MODE) { - _spread_items(); - - push @actString, undef unless @actString || $S{all_disable}; - } -} - -sub update_wl { - return if $BLOCK_ALL; - remake(); - - Irssi::statusbar_items_redraw(set $_) for keys %statusbars; - - unless ($VIEWER_MODE) { - Irssi::timeout_add_once(100, 'syncLines', undef); - } - else { - syncViewer(); - } -} - -sub screenFullRedraw { - my ($window) = @_; - if (!ref $window or $window->{refnum} == Irssi::active_win->{refnum}) { - $viewer{fullRedraw} = 1 if $viewer{client}; - $settings_str = ''; - &setup_changed; - } -} - -sub start_viewer { - unlink $viewer{path} if -S $viewer{path} || -p _; - - $viewer{server} = IO::Socket::UNIX->new( - Type => SOCK_STREAM, - Local => $viewer{path}, - Listen => 1 - ); - unless ($viewer{server}) { - $viewer{msg} = $!; - $viewer{retry} = Irssi::timeout_add_once(5000, 'retry_viewer', 1); - return; - } - my ($name) = __PACKAGE__ =~ /::([^:]+)$/; - $viewer{server}->blocking(0); - $viewer{msg} = "Run $name from the shell or switch to sbar mode"; - $viewer{server_tag} = Irssi::input_add($viewer{server}->fileno, INPUT_READ, 'vi_connected', undef); -} - -sub retry_viewer { - start_viewer(); -} - -sub vi_close_client { - Irssi::input_remove(delete $viewer{client_tag}) if exists $viewer{client_tag}; - $viewer{client}->close if $viewer{client}; - delete $viewer{client}; - delete $viewer{client_keymap}; - delete $viewer{client_settings}; - delete $viewer{client_env}; - delete $viewer{fullRedraw}; -} - -sub vi_connected { - vi_close_client(); - $viewer{client} = $viewer{server}->accept or return; - $viewer{client}->blocking(0); - $viewer{client_tag} = Irssi::input_add($viewer{client}->fileno, INPUT_READ, 'vi_clientinput', undef); - syncViewer(); -} - -use constant VIEWER_BLOCK_SIZE => 1024; -sub vi_clientinput { - if ($viewer{client}->read(my $buf, VIEWER_BLOCK_SIZE)) { - $viewer{rcvbuf} .= $buf; - if ($viewer{rcvbuf} =~ s/^(?:(active|\d+)|(last|up|down))\n//igm) { - if (defined $2) { - Irssi::command("window $2"); - } - elsif (lc $1 eq 'active' && $viewer{use_ack}) { - Irssi::command("ack"); - } - else { - Irssi::command("window goto $1"); - } - } - } - else { - vi_close_client(); - Irssi::timeout_add_once(100, 'syncViewer', undef); - } -} - -sub stop_viewer { - Irssi::timeout_remove(delete $viewer{retry}) if exists $viewer{retry}; - vi_close_client(); - Irssi::input_remove(delete $viewer{server_tag}) if exists $viewer{server_tag}; - return unless $viewer{server}; - $viewer{server}->close; - delete $viewer{server}; -} -sub _encode_var { - my $str; - while (@_) { - my ($name, $var) = splice @_, 0, 2; - my $type = ref $var ? $var =~ /HASH/ ? 'map' : $var =~ /ARRAY/ ? 'list' : '' : ''; - $str .= "\n\U$name$type\_begin\n"; - if ($type eq 'map') { - no warnings 'numeric'; - $str .= " $_\n ${$var}{$_}\n" for sort { $a <=> $b || $a cmp $b } keys %$var; - } - elsif ($type eq 'list') { - $str .= " $_\n" for @$var; - } - else { - $str .= " $var\n"; - } - $str .= "\U$name$type\_end\n"; - } - $str -} -sub syncViewer { - if ($viewer{client}) { - @actString = (); - if ($currentLines) { - killOldStatus(); - $currentLines = 0; - } - my $str; - unless ($viewer{client_keymap}) { - $str .= _encode_var('key', +{ %nummap, %specialmap }); - $viewer{client_keymap} = 1; - } - unless ($viewer{client_settings}) { - $str .= _encode_var( - block => $S{block}, - ha => $S{height_adjust}, - ); - $viewer{client_settings} = 1; - } - unless ($viewer{client_env}) { - $str .= _encode_var(irssienv => +{ - (defined $ENV{TMUX_PANE} && length $ENV{TMUX_PANE}) && (defined $ENV{TMUX} && length $ENV{TMUX}) ? - (tmux_pane => $ENV{TMUX_PANE}, - tmux_srv => $ENV{TMUX}) : (), - (defined $ENV{WINDOWID} && length $ENV{WINDOWID}) ? - (xwinid => $ENV{WINDOWID}) : (), - }); - $viewer{client_env} = 1; - } - my $separator = Irssi::current_theme->get_format(__PACKAGE__, set 'separator'); - my $sepLen = sb_length($separator); - my $item_bg = Irssi::current_theme->get_format(__PACKAGE__, set 'viewer_item_bg'); - $str .= _encode_var(redraw => 1) if delete $viewer{fullRedraw}; - $str .= _encode_var(separator => $separator, - seplen => $sepLen, - itembg => $item_bg, - mouse => $mouse_coords{refnum}, - key2 => \%wnmap_exp, - win => \@win_items); - - my $was = $viewer{client}->blocking(1); - $viewer{client}->print($str); - $viewer{client}->blocking($was); - } - elsif ($viewer{server}) { - @actString = ((uc setc()).": $viewer{msg}"); - } - else { - @actString = ((uc setc()).": $viewer{msg}"); - } - if (@actString) { - Irssi::timeout_add_once(100, 'syncLines', undef); - } -} - -sub reset_awl { - Irssi::timeout_remove($shade_line_timer) if $shade_line_timer; $shade_line_timer = undef; - my $was_sort = $S{sort} // ''; - my $was_xform = $S{xform} // ''; - my $was_shared = $S{shared_sbar}; - %S = ( - sort => Irssi::settings_get_str( set 'sort'), - fancy_abbrev => Irssi::settings_get_str('fancy_abbrev'), - xform => Irssi::settings_get_str( set 'custom_xform'), - block => Irssi::settings_get_int( set 'block'), - banned_on => Irssi::settings_get_bool('banned_channels_on'), - prefer_name => Irssi::settings_get_bool(set 'prefer_name'), - hide_data => Irssi::settings_get_int( set 'hide_data'), - hide_name => Irssi::settings_get_int( set 'hide_name_data'), - hide_empty => Irssi::settings_get_int( set 'hide_empty'), - sbar_maxlen => Irssi::settings_get_bool(set 'sbar_maxlength'), - placement => Irssi::settings_get_str( set 'placement'), - position => Irssi::settings_get_int( set 'position'), - maxlines => Irssi::settings_get_int( set 'maxlines'), - all_disable => Irssi::settings_get_bool(set 'all_disable'), - height_adjust=> Irssi::settings_get_int( set 'height_adjust'), - mouse_offset => Irssi::settings_get_int( set 'mouse_offset'), - mouse_scroll => Irssi::settings_get_int( 'mouse_scroll'), - mouse_escape => Irssi::settings_get_int( 'mouse_escape'), - line_shade => Irssi::settings_get_time(set 'last_line_shade'), - ); - $S{fancy_strict} = $S{fancy_abbrev} =~ /^strict/i; - $S{fancy_head} = $S{fancy_abbrev} =~ /^head/i; - my $shared = Irssi::settings_get_str(set 'shared_sbar'); - if ($shared =~ /^(\d+)([<])(\d+)$/) { - $S{shared_sbar} = [$1, $2, $3]; - } - else { - Irssi::settings_set_str(set 'shared_sbar', 'OFF'); - $S{shared_sbar} = undef; - } - lock_keys(%S); - if ($was_sort ne $S{sort}) { - $print_text_activity = undef; - my @sort_order = grep { @$_ > 4 } map { - s/^\s*//; - my $reverse = s/^\W*\K[-!]//; - my $undef_check = s/^\W*\K~// ? 1 : undef; - my $equal_check = s/=(.*)\s?$// ? $1 : undef; - s/\s*$//; - - $print_text_activity = 1 if $_ eq 'last_line'; - - my @path = split '/'; - my $class_check = @path && $path[-1] =~ s/(::.*)$// ? $1 : undef; - - [ $reverse ? -1 : 1, $undef_check, $equal_check, $class_check, @path ] - } "$S{sort}," =~ /([^+,]*|[^+,]*=[^,]*?\s(?=\+)|[^+,]*=[^,]*)[+,]/g; - $window_sort_func = sub { - no warnings qw(numeric uninitialized); - for my $so (@sort_order) { - my @x = map { - my $ret = 0; - $ret = $_ eq $so->[2] ? 1 : -1 if defined $so->[2]; - $ret = defined $_ ? ($ret || -3) : 3 if $so->[1]; - $ret = ref $_ && $_->isa('Irssi'.$so->[3]) ? 2 : ($ret || -2) if $so->[3]; - -$ret || $_ - } - map { - reduce { return unless ref $a; $a->{$b} } $_, @{$so}[4..$#$so] - } $a, $b; - return ((($x[0] <=> $x[1] || $x[0] cmp $x[1]) * $so->[0]) || next); - } - return ($a->{refnum} <=> $b->{refnum}); - }; - } - if ($was_xform ne $S{xform}) { - if ($S{xform} !~ /\S/) { - $custom_xform = undef; - } - else { - my $script_pkg = __PACKAGE__ . '::custom_xform'; - local $@; - $custom_xform = eval qq{ -package $script_pkg; -use strict; -no warnings; -our (\$QUERY, \$CHANNEL, \$TAG); -return sub { -# line 1 @{[ set 'custom_xform' ]}\n$S{xform}}}; - if ($@) { - $@ =~ /^(.*)/; - print '%_'.(set 'custom_xform').'%_ did not compile: '.$1; - } - } - } - - my $new_settings = join "\n", $VIEWER_MODE - ? ("\\", $S{block}, $S{height_adjust}) - : ("!", $S{placement}, $S{position}); - - if ($settings_str ne $new_settings) { - @actString = (); - %abbrev_cache = (); - $currentLines = 0; - killOldStatus(); - delete $viewer{client_settings}; - $settings_str = $new_settings; - } - - my $was_mouse_mode = $MOUSE_ON; - if ($MOUSE_ON = Irssi::settings_get_bool(set 'mouse') and !$was_mouse_mode) { - install_mouse(); - } - elsif ($was_mouse_mode and !$MOUSE_ON) { - uninstall_mouse(); - } - - my $path = Irssi::settings_get_str(set 'path'); - my $was_viewer_mode = $VIEWER_MODE; - if (defined $viewer{path} && $viewer{path} ne $path && $was_viewer_mode) { - stop_viewer(); - $was_viewer_mode = 0; - } - $viewer{path} = $path; - if ($VIEWER_MODE = Irssi::settings_get_bool(set 'viewer') and !$was_viewer_mode) { - start_viewer(); - } - elsif ($was_viewer_mode and !$VIEWER_MODE) { - stop_viewer(); - } - - %banned_channels = map { lc1459(to_uni($_)) => undef } - split ' ', Irssi::settings_get_str('banned_channels'); - - my @sb_base = split /\177/, sb_format_expand("{sb \177}"), 2; - $sb_base_width_pre = sb_length($sb_base[0]); - $sb_base_width_post = sb_length($sb_base[1]); - $sb_base_width = $sb_base_width_pre + $sb_base_width_post; - - if ($print_text_activity && $S{line_shade}) { - $shade_line_timer = Irssi::timeout_add(max(10 * GLOB_QUEUE_TIMER, 100*$S{line_shade}**(1/3)), 'wl_changed', undef); - } - - $CHANGED{AWINS} = 1; -} - -sub stop_mouse_tracking { - print STDERR "\e[?1005l\e[?1000l"; -} -sub start_mouse_tracking { - print STDERR "\e[?1000h\e[?1005h"; -} -sub install_mouse { - Irssi::command_bind('mouse_xterm' => 'mouse_xterm'); - Irssi::command('^bind meta-[M command mouse_xterm'); - Irssi::signal_add_first('gui key pressed' => 'mouse_key_hook'); - start_mouse_tracking(); -} -sub uninstall_mouse { - stop_mouse_tracking(); - Irssi::signal_remove('gui key pressed' => 'mouse_key_hook'); - Irssi::command('^bind -delete meta-[M'); - Irssi::command_unbind('mouse_xterm' => 'mouse_xterm'); -} - -sub awl_mouse_event { - return if $VIEWER_MODE; - if ((($_[0] == 3 and $_[3] == 0) - || $_[0] == 64 || $_[0] == 65) and - $_[1] == $_[4] and $_[2] == $_[5]) { - my $top = lc $S{placement} eq 'top'; - my ($pos, $line) = @_[1 .. 2]; - unless ($top) { - $line -= $screenHeight; - $line += $currentLines; - $line += $S{mouse_offset}; - } - else { - $line -= $S{mouse_offset}; - } - $pos -= $sb_base_width_pre; - return if $line < 0 || $line >= $currentLines; - if ($_[0] == 64) { - Irssi::command('window up'); - } - elsif ($_[0] == 65) { - Irssi::command('window down'); - } - elsif (exists $mouse_coords{$line}{$pos}) { - my $win = $mouse_coords{$line}{$pos}; - Irssi::command('window ' . $win); - } - Irssi::signal_stop; - } -} - -sub mouse_scroll_event { - return unless $S{mouse_scroll}; - if (($_[3] == 64 or $_[3] == 65) and - $_[0] == $_[3] and $_[1] == $_[4] and $_[2] == $_[5]) { - my $cmd = 'scrollback goto ' . ($_[3] == 64 ? '-' : '+') . $S{mouse_scroll}; - Irssi::active_win->command($cmd); - Irssi::signal_stop; - } - elsif ($_[0] == 64 or $_[0] == 65) { - Irssi::signal_stop; - } -} - -sub mouse_escape { - return unless $S{mouse_escape} > 0; - if ($_[0] == 3) { - my $tm = $S{mouse_escape}; - $tm *= 1000 if $tm < 1000; - stop_mouse_tracking(); - Irssi::timeout_add_once($tm, 'start_mouse_tracking', undef); - Irssi::signal_stop; - } -} - -{ sub UNLOAD { - @actString = (); - killOldStatus(); - stop_viewer() if $VIEWER_MODE; - uninstall_mouse() if $MOUSE_ON; - } -} - -sub addPrintTextHook { # update on print text - return if $BLOCK_ALL; - return unless $print_text_activity; - return if $_[0]->{level} == 262144 and $_[0]->{target} eq '' - and !defined($_[0]->{server}); - &wl_changed; -} - -sub block_event_window_change { - Irssi::signal_stop; -} - -sub update_awins { - { - my @wins = Irssi::windows; - Irssi::signal_add_first('window changed' => 'block_event_window_change'); - local $BLOCK_ALL = 1; - my $bwin = - my $awin = Irssi::active_win; - $awin->command('window last'); - my $lwin = Irssi::active_win; - $lwin->command('window last'); - my $defer_irssi_broken_last = $lwin->{refnum} == $bwin->{refnum}; - my $awin_counter = 0; - # missing special case: more than 1 last win, so /win last; - # /win last doesn't come back to the current window. eg. after - # connect & autojoin - Irssi::signal_remove('window changed' => 'block_event_window_change'); - unless ($defer_irssi_broken_last) { - # we need to keep the fe-windows code running here - Irssi::signal_add_priority('window changed' => 'block_event_window_change', -99); - %awins = %wnmap_exp = (); - do { - Irssi::active_win->command('window up'); - $awin = Irssi::active_win; - $awins{$awin->{refnum}} = undef; - ++$awin_counter; - } until ($awin->{refnum} == $bwin->{refnum} || $awin_counter >= @wins); - Irssi::signal_remove('window changed' => 'block_event_window_change'); - - Irssi::signal_add_first('window changed' => 'block_event_window_change'); - for my $key (keys %wnmap) { - next unless Irssi::window_find_name($key) || Irssi::window_find_item($key); - $awin->command("window goto $key"); - my $cwin = Irssi::active_win; - $wnmap_exp{ $cwin->{refnum} } = $wnmap{$key}; - $cwin->command('window last') - if $cwin->{refnum} != $awin->{refnum}; - } - for my $win (reverse @wins) { # restore original window order - Irssi::active_win->command('window '.$win->{refnum}); - } - $awin->command('window '.$lwin->{refnum}); # restore last win - Irssi::active_win->command('window last'); - Irssi::signal_remove('window changed' => 'block_event_window_change'); - } - } - $CHANGED{WL} = 1; -} - -sub resizeTerm { - ($screenHeight, $screenWidth) = split ' ', `stty size 2>/dev/null`; - $CHANGED{SETUP} = 1; -} - -sub awl_refresh { - $globTime = undef; - resizeTerm() if delete $CHANGED{SIZE}; - reset_awl() if delete $CHANGED{SETUP}; - update_awins() if delete $CHANGED{AWINS}; - update_wl() if delete $CHANGED{WL}; -} - -sub termsize_changed { $CHANGED{SIZE} = 1; &queue_refresh; } -sub setup_changed { $CHANGED{SETUP} = 1; &queue_refresh; } -sub awins_changed { $CHANGED{AWINS} = 1; &queue_refresh; } -sub wl_changed { $CHANGED{WL} = 1; &queue_refresh; } - -sub window_changed { - &awins_changed if $_[1]; -} - -sub queue_refresh { - return if $BLOCK_ALL; - Irssi::timeout_remove($globTime) - if defined $globTime; # delay the update further - $globTime = Irssi::timeout_add_once(GLOB_QUEUE_TIMER, 'awl_refresh', undef); -} - -sub awl_init { - termsize_changed(); - update_keymap(); - print setc(), " is brand new beta release, please report issues and do read the upgrade notes. thanks!" - if $VERSION =~ /b/; -} - -sub runsub { - my $cmd = shift; - sub { - my ($data, $server, $item) = @_; - Irssi::command_runsub($cmd, $data, $server, $item); - }; -} - -Irssi::signal_register({ - 'gui mouse' => [qw/int int int int int int/], - }); -{ my $broken_expandos = (Irssi::version >= 20081128 && Irssi::version < 20110210) - ? sub { my $x = shift; $x =~ s/\$\{cumode_space\}/ /; $x } : undef; - Irssi::theme_register([ - map { $broken_expandos ? $broken_expandos->($_) : $_ } - set 'display_nokey' => '$N${cumode_space}$H$C$S', - set 'display_key' => '$Q${cumode_space}$H$C$S', - set 'display_nokey_visible' => '%2$N${cumode_space}$H$C$S', - set 'display_key_visible' => '%2$Q${cumode_space}$H$C$S', - set 'display_nokey_active' => '%1$N${cumode_space}$H$C$S', - set 'display_key_active' => '%1$Q${cumode_space}$H$C$S', - set 'display_header' => '%8$C|${N}', - set 'name_display' => '$0', - set 'separator' => ' ', - set 'separator2' => '', - set 'viewer_item_bg' => sb_format_expand('{sb_background}'), - ]); -} -Irssi::settings_add_bool(setc, set 'prefer_name', 0); # -Irssi::settings_add_int( setc, set 'hide_empty', 0); # -Irssi::settings_add_int( setc, set 'hide_data', 0); # -Irssi::settings_add_int( setc, set 'hide_name_data', 0); # -Irssi::settings_add_int( setc, set 'maxlines', 9); # -Irssi::settings_add_int( setc, set 'block', 15); # -Irssi::settings_add_bool(setc, set 'sbar_maxlength', 1); # -Irssi::settings_add_int( setc, set 'height_adjust', 2); # -Irssi::settings_add_str( setc, set 'sort', 'refnum'); # -Irssi::settings_add_str( setc, set 'placement', 'bottom'); # -Irssi::settings_add_int( setc, set 'position', 0); # -Irssi::settings_add_bool(setc, set 'all_disable', 1); # -Irssi::settings_add_bool(setc, set 'viewer', 1); # -Irssi::settings_add_str( setc, set 'shared_sbar', 'OFF'); # -Irssi::settings_add_bool(setc, set 'mouse', 0); # -Irssi::settings_add_str( setc, set 'path', Irssi::get_irssi_dir . '/_windowlist'); # -Irssi::settings_add_str( setc, set 'custom_xform', ''); # -Irssi::settings_add_time(setc, set 'last_line_shade', '0'); # -Irssi::settings_add_int( setc, set 'mouse_offset', 1); # -Irssi::settings_add_int( setc, 'mouse_scroll', 3); # -Irssi::settings_add_int( setc, 'mouse_escape', 1); # -Irssi::settings_add_str( setc, 'banned_channels', ''); -Irssi::settings_add_bool(setc, 'banned_channels_on', 1); -Irssi::settings_add_str( setc, 'fancy_abbrev', 'fancy'); # - -Irssi::signal_add_last({ - 'setup changed' => 'setup_changed', - 'print text' => 'addPrintTextHook', - 'terminal resized' => 'termsize_changed', - 'setup reread' => 'screenFullRedraw', - 'window hilight' => 'wl_changed', - 'command format' => 'wl_changed', -}); -Irssi::signal_add({ - 'window changed' => 'window_changed', - 'window item changed' => 'wl_changed', - 'window changed automatic' => 'window_changed', - 'window created' => 'awins_changed', - 'window destroyed' => 'awins_changed', - 'window name changed' => 'wl_changed', - 'window refnum changed' => 'wl_changed', -}); -Irssi::signal_add_last('gui mouse' => 'mouse_escape'); -Irssi::signal_add_last('gui mouse' => 'mouse_scroll_event'); -Irssi::signal_add_last('gui mouse' => 'awl_mouse_event'); -Irssi::command_bind( setc() => runsub(setc()) ); -Irssi::command_bind( setc() . ' redraw' => 'screenFullRedraw' ); - -{ - my $l = set 'shared'; - { - no strict 'refs'; - *{$l} = $awl_shared_empty; - } - Irssi::statusbar_item_register($l, '$0', $l); -} - -awl_init(); - -# Mouse script based on irssi mouse patch by mirage -{ my $mouse_status = -1; # -1:off 0,1,2:filling mouse_combo - my @mouse_combo; # 0:button 1:x 2:y - my @mouse_previous; # previous contents of mouse_combo - - sub mouse_xterm_off { - $mouse_status = -1; - } - sub mouse_xterm { - $mouse_status = 0; - Irssi::timeout_add_once(10, 'mouse_xterm_off', undef); - } - - sub mouse_key_hook { - my ($key) = @_; - if ($mouse_status != -1) { - if ($mouse_status == 0) { - @mouse_previous = @mouse_combo; - #if @mouse_combo && $mouse_combo[0] < 64; - } - $mouse_combo[$mouse_status] = $key - 32; - $mouse_status++; - if ($mouse_status == 3) { - $mouse_status = -1; - # match screen coordinates - $mouse_combo[1]--; - $mouse_combo[2]--; - Irssi::signal_emit('gui mouse', @mouse_combo[0 .. 2], @mouse_previous[0 .. 2]); - } - Irssi::signal_stop; - } - } -} - -sub string_LCSS { - my $str = join "\0", @_; - (sort { length $b <=> length $a } $str =~ /(?=(.+).*\0.*\1)/g)[0] -} - -{ package Irssi::Nick } - -UNITCHECK -{ package AwlViewer; - use strict; - use warnings; - no warnings 'redefine'; - use Encode; - use IO::Socket::UNIX; - use IO::Select; - use constant BLOCK_SIZE => 1024; - use constant RECONNECT_TIME => 5; - - my $sockpath; - - our $VERSION = '0.5'; - - our ($got_int, $resized, $timeout); - - my %vars; - my (%c2w, @seqlist); - my %mouse_coords; - my (@mouse, @last_mouse); - my ($err, $sock, $loop); - my ($keybuf, $rcvbuf); - my @screen; - my ($screenHeight, $screenWidth); - my ($disp_update, $fs_open); - - sub connect_it { - $sock = IO::Socket::UNIX->new( - Type => SOCK_STREAM, - Peer => $sockpath, - ); - unless ($sock) { - $err = $!; - return; - } - $sock->blocking(0); - $loop->add($sock); - } - - sub remove_conn { - my $fh = shift; - $loop->remove($fh); - $fh->close; - $sock = undef; - %vars = (); - @screen = (); - } - - { package Terminfo; # xterm - sub civis { "\e[?25l" } - sub sc { "\e7" } - sub cup { "\e[" . ($_[0] + 1) . ';' . ($_[1] + 1) . 'H' } - sub el { "\e[K" } - sub rc { "\e8" } - sub cnorm { "\e[?25h" } - sub setab { "\e[4" . $_[0] . 'm' } - sub setaf { "\e[3" . $_[0] . 'm' } - sub setaf16 { "\e[9" . $_[0] . 'm' } - sub setab16 { "\e[10" . $_[0] . 'm' } - sub setaf256 { "\e[38;5;" . $_[0] . 'm' } - sub setab256 { "\e[48;5;" . $_[0] . 'm' } - sub sgr0 { "\e[0m" } - sub bold { "\e[1m" } - sub it { "\e[3m" } - sub ul { "\e[4m" } - sub blink { "\e[5m" } - sub rev { "\e[7m" } - sub op { "\e[39;49m" } - sub exit_bold { "\e[22m" } - sub exit_it { "\e[23m" } - sub exit_ul { "\e[24m" } - sub exit_blink { "\e[25m" } - sub exit_rev { "\e[27m" } - sub smcup { "\e[?1049h" } - sub rmcup { "\e[?1049l" } - sub smmouse { "\e[?1000h\e[?1005h" } - sub rmmouse { "\e[?1005l\e[?1000l" } - } - - sub init { - $sockpath = shift // "$ENV{HOME}/.irssi/_windowlist"; - STDOUT->autoflush(1); - printf "\r%swaiting for %s...", Terminfo::sc, ::setc(); - - `stty -icanon -echo`; - - $loop = IO::Select->new; - STDIN->blocking(0); - $loop->add(\*STDIN); - - $SIG{INT} = sub { $got_int = 1 }; - $SIG{WINCH} = sub { $resized = 1 }; - - $resized = 3; - - $disp_update = 2; - } - - sub enter_fs { - return if $fs_open; - safe_print(Terminfo::rc, Terminfo::smcup, Terminfo::civis, Terminfo::smmouse); - $fs_open = 1; - } - - sub leave_fs { - return unless $fs_open; - safe_print(Terminfo::rmmouse, Terminfo::cnorm, Terminfo::rmcup); - safe_print(sprintf "\r%swaiting for %s...", Terminfo::sc, ::setc()) if $_[0]; - - $fs_open = 0; - } - - sub end_prog { - leave_fs(); - STDIN->blocking(1); - `stty sane`; - printf "\r%s%sthanks for using %s\n", Terminfo::rc, Terminfo::el, ::setc(); - } - - sub safe_print { - my $st = STDIN->blocking(1); - print @_; - STDIN->blocking($st); - } - - sub safe_qx { - my $st = STDIN->blocking(1); - my $ret = `$_[0]`; - STDIN->blocking($st); - $ret - } - - sub safe_print_sock { - return unless $sock; - my $was = $sock->blocking(1); - $sock->print(@_); - $sock->blocking($was); - } - - sub process_recv { - my $need = 0; - while ($rcvbuf =~ s/\n(.+)_BEGIN\n((?: .*\n)*)\1_END\n//) { - my $var = lc $1; - my $data = $2; - my @data = split "\n ", "\n$data ", -1; - shift @data; pop @data; - my $itembg = $vars{itembg}; - if ($var =~ s/list$//) { - $vars{$var} = \@data; - } - elsif ($var =~ s/map$//) { - $vars{$var} = +{ @data }; - } - else { - $vars{$var} = join "\n", @data; - } - $need = 1 if $var eq 'win'; - $need = 1 if $var eq 'redraw' && $vars{$var}; - if (($itembg//'') ne ($vars{itembg}//'')) { - $need = $vars{redraw} = 1; - } - _build_keymap() if $var eq 'key2'; - } - $need - } - - { my %ansi_table; - my ($i, $j, $k) = (0, 0, 0); - my %term_state; - sub reset_term_state { my %old_term = %term_state; %term_state = (); %old_term } - sub set_term_state { my %old_term = %term_state; %term_state = @_; %old_term } - %ansi_table = ( - # fe-common::core::formats.c:format_expand_styles - (map { my $t = $i++; ($_ => sub { my $n = $term_state{hicolor} ? \&Terminfo::setab16 : \&Terminfo::setab; - $n->($t) }) } (split //, '01234567' )), - (map { my $t = $j++; ($_ => sub { my $n = $term_state{hicolor} ? \&Terminfo::setaf16 : \&Terminfo::setaf; - $n->($t) }) } (split //, 'krgybmcw' )), - (map { my $t = $k++; ($_ => sub { my $n = $term_state{hicolor} ? \&Terminfo::setaf : \&Terminfo::setaf16; - $n->($t) }) } (split //, 'KRGYBMCW')), - # reset - n => sub { $term_state{hicolor} = 0; my $r = Terminfo::op; - for (qw(blink rev bold)) { - $r .= Terminfo->can("exit_$_")->() if delete $term_state{$_}; - } - { - local $ansi_table{n} = $ansi_table{N}; - $r .= formats_to_ansi_basic($vars{itembg}); - } - $r - }, - N => sub { reset_term_state(); Terminfo::sgr0 }, - # flash/bright - F => sub { my $n = 'blink'; my $e = ($term_state{$n} ^= 1) ? $n : "exit_$n"; Terminfo->can($e)->() }, - # reverse - 8 => sub { my $n = 'rev'; my $e = ($term_state{$n} ^= 1) ? $n : "exit_$n"; Terminfo->can($e)->() }, - # bold - "_" => sub { my $n = 'bold'; my $e = ($term_state{$n} ^= 1) ? $n : "exit_$n"; Terminfo->can($e)->() }, - # underline - U => sub { my $n = 'ul'; my $e = ($term_state{$n} ^= 1) ? $n : "exit_$n"; Terminfo->can($e)->() }, - # italic - I => sub { my $n = 'it'; my $e = ($term_state{$n} ^= 1) ? $n : "exit_$n"; Terminfo->can($e)->() }, - # bold, used as colour modifier - 9 => sub { $term_state{hicolor} ^= 1; '' }, - # delete other stuff - (map { $_ => sub { '' } } (split //, ':|>#[')), - # escape - (map { my $close = $_; $_ => sub { $close } } (split //, '{}%')), - ); - for my $base (0 .. 15) { - my $close = $base; - my $idx = ($close&8) | ($close&4)>>2 | ($close&2) | ($close&1)<<2; - $ansi_table{ (sprintf "x0%x", $close) } = - $ansi_table{ (sprintf "x0%X", $close) } = - sub { Terminfo::setab256($idx) }; - $ansi_table{ (sprintf "X0%x", $close) } = - $ansi_table{ (sprintf "X0%X", $close) } = - sub { Terminfo::setaf256($idx) }; - } - for my $plane (1 .. 6) { - for my $coord (0 .. 35) { - my $close = 16 + ($plane-1) * 36 + $coord; - my $ch = $coord < 10 ? $coord : chr( $coord - 10 + ord 'a' ); - $ansi_table{ "x$plane$ch" } = - $ansi_table{ "x$plane\U$ch" } = - sub { Terminfo::setab256($close) }; - $ansi_table{ "X$plane$ch" } = - $ansi_table{ "X$plane\U$ch" } = - sub { Terminfo::setaf256($close) }; - } - } - for my $gray (0 .. 23) { - my $close = 232 + $gray; - my $ch = chr( $gray + ord 'a' ); - $ansi_table{ "x7$ch" } = - $ansi_table{ "x7\U$ch" } = - sub { Terminfo::setab256($close) }; - $ansi_table{ "X7$ch" } = - $ansi_table{ "X7\U$ch" } = - sub { Terminfo::setaf256($close) }; - } - sub formats_to_ansi_basic { - my $o = shift; - $o =~ s/(%(X..|x..|.))/exists $ansi_table{$2} ? $ansi_table{$2}->() : $1/gex; - $o - } - } - - sub _header { - my $str = uc ::setc(); - my $space = int( ((abs $vars{block}) - length $str) / (1 + length $str)); - if ($space > 0) { - my $ss = ' ' x $space; - $str = join $ss, '', (split //, $str), ''; - } - my $pad = (abs $vars{block}) - length $str; - $str = ' ' x ($pad/2) . $str . ' ' x ($pad/2 + $pad%2); - $str - } - - sub _add_item { - my ($i, $j, $c, $wi, $screen, $mouse) = @_; - $screen->[$i][$j] = "%N%n$wi"; - if (exists $vars{mouse}{$c - 1}) { - $mouse->[$i][$j] = $vars{mouse}{$c - 1}; - } - } - sub update_screen { - $disp_update = 0; - unless ($sock && exists $vars{seplen} && exists $vars{block}) { - leave_fs(1); - return; - } - enter_fs(); - @screen = () if delete $vars{redraw}; - %mouse_coords = (); - my $ncols = int( ($screenWidth + $vars{seplen}) / ($vars{seplen} + abs $vars{block}) ); - my $xenl = $ncols > int( ($screenWidth + $vars{seplen} - 1) / ($vars{seplen} + abs $vars{block}) ); - my $nrows = $screenHeight - $vars{ha}; - my @wi = @{$vars{win}//[]}; - my $max_items = $ncols * $nrows; - my $c = 1; - my $items = @wi + $c; - my $titems = $items > $max_items ? $max_items : $items; - my $i = 0; - my $j = 0; - my @new_screen; - my @new_mouse; - $new_screen[0][0] = _header() . ' ' x $vars{seplen}; - unless ($nrows > $ncols) { # line layout - ++$j; - for my $wi (@wi) { - if ($j >= $ncols) { - $j = 0; - ++$i; - } - last if $i >= $nrows; - _add_item($i, $j, $c, $wi, \@new_screen, \@new_mouse); - if ($c + 1 < $titems && $j + 1 < $ncols) { - $new_screen[$i][$j] .= $vars{separator}; - } - ++$j; - ++$c; - } - } - else { # column layout - ++$i; - for my $wi (@wi) { - if ($i >= $nrows) { - $i = 0; - ++$j; - } - last if $j >= $ncols; - _add_item($i, $j, $c, $wi, \@new_screen, \@new_mouse); - if ($c + $nrows < $titems) { - $new_screen[$i][$j] .= $vars{separator}; - } - ++$i; - ++$c; - } - } - my $step = $vars{seplen} + abs $vars{block}; - $i = 0; - my $str = Terminfo::sc . Terminfo::sgr0; - for (my $i = 0; $i < @new_screen; ++$i) { - for (my $j = 0; $j < @{$new_screen[$i]}; ++$j) { - if (defined $new_mouse[$i] && defined $new_mouse[$i][$j]) { - my $from = $j * $step; - $mouse_coords{$i}{$_} = $new_mouse[$i][$j] - for $from .. $from + abs $vars{block}; - } - next if defined $screen[$i] && defined $screen[$i][$j] - && $screen[$i][$j] eq $new_screen[$i][$j]; - $str .= Terminfo::cup($i, $j * $step) - . formats_to_ansi_basic($new_screen[$i][$j]) - . Terminfo::sgr0; - $str .= Terminfo::el if $j == $#{$new_screen[$i]} && (!$xenl || $j + 1 != $ncols); - } - } - for (@new_screen .. $screenHeight - 1) { - if (!@screen || defined $screen[$_]) { - $str .= Terminfo::cup($_, 0) . Terminfo::sgr0 . Terminfo::el; - } - } - $str .= Terminfo::rc; - safe_print $str; - @screen = @new_screen; - } - - sub handle_resize { - ($screenHeight, $screenWidth) = split ' ', safe_qx('stty size'); - $resized = 0; - @screen = (); - $disp_update = 1; - } - - sub _build_keymap { - %c2w = reverse( %{$vars{key}}, %{$vars{key2}} ); - if (!grep { /^[+-]./ } keys %c2w) { - %c2w = (%c2w, map { ("-$_" => $c2w{$_}) } grep { !/^\^./ } keys %c2w); - } - %c2w = map { - my $key = $_; - s{^(-)?(\+)?(\^)?(.)}{ - join '', ( - ($1 ? "\e" : ''), - ($2 ? "\e\e" : ''), - ($3 ? "$4"^"@" : $4) - ) - }e; - $_ => $c2w{$key} - } keys %c2w; - @seqlist = sort { length $b <=> length $a } keys %c2w; - } - - sub process_keys { - Encode::_utf8_on($keybuf); - my $win; - my $use_mouse; - my $maybe; - KEY: while (length $keybuf && !$maybe) { - $maybe = 0; - if ($keybuf =~ s/^\e\[M(.)(.)(.)//) { - @last_mouse = @mouse;# if @mouse && $mouse[0] < 64; - @mouse = map { -32 + ord } ($1, $2, $3); - $use_mouse = 1; - next KEY; - } - for my $s (@seqlist) { - if ($keybuf =~ s/^\Q$s//) { - $win = $c2w{$s}; - $use_mouse = 0; - next KEY; - } - elsif (length $keybuf < length $s && $s =~ /^\Q$keybuf/) { - $maybe = 1; - } - } - unless ($maybe) { - substr $keybuf, 0, 1, ''; - } - } - if ($use_mouse && @mouse && @last_mouse && - $mouse[2] == $last_mouse[2] && - $mouse[1] == $last_mouse[1] && - ($mouse[0] == 3 || $mouse[0] == 64 || $mouse[0] == 65)) { - if ($mouse[0] == 64) { - $win = 'up'; - } - elsif ($mouse[0] == 65) { - $win = 'down'; - } - elsif (exists $mouse_coords{$mouse[2] - 1}{$mouse[1] - 1}) { - $win = $mouse_coords{$mouse[2] - 1}{$mouse[1] - 1}; - } - elsif ($mouse[2] == 1 && $mouse[1] <= abs $vars{block}) { - $win = $last_mouse[0] != 0 ? 'last' : 'active'; - } - else { - } - } - if (defined $win) { - $win =~ s/^_//; - safe_print_sock("$win\n"); - if (!exists $ENV{AWL_AUTOFOCUS} || $ENV{AWL_AUTOFOCUS}) { - if ((defined $ENV{TMUX} && length $ENV{TMUX}) && exists $vars{irssienv}{tmux_srv} && length $vars{irssienv}{tmux_pane} - && $ENV{TMUX} eq $vars{irssienv}{tmux_srv}) { - safe_qx("tmux selectp -t $vars{irssienv}{tmux_pane} 2>&1"); - } - elsif (exists $vars{irssienv}{xwinid}) { - safe_qx("wmctrl -ia $vars{irssienv}{xwinid} 2>/dev/null"); - } - } - } - Encode::_utf8_off($keybuf); - } - - sub main { - &init; - until ($got_int) { - $timeout = undef; - if ($resized) { - if ($resized == 1) { - $timeout = 1; - $resized++; - } - else { - handle_resize(); - } - } - unless ($sock || $timeout) { - connect_it(); - } - $timeout ||= RECONNECT_TIME unless $sock; - update_screen() if $disp_update; - while (my @read = $loop->can_read($timeout)) { - for my $fh (@read) { - if ($fh == \*STDIN) { - if (read STDIN, my $buf, BLOCK_SIZE) { - do { - $keybuf .= $buf; - } while read STDIN, $buf, BLOCK_SIZE; - } - else { - $got_int = 1; - last; - } - } - else { - if ($fh->read(my $buf, BLOCK_SIZE)) { - do { - $rcvbuf .= $buf; - } while $fh->read($buf, BLOCK_SIZE); - } - else { - $disp_update = 1; - remove_conn($fh); - $timeout ||= RECONNECT_TIME; - } - } - } - $disp_update |= process_recv() if length $rcvbuf; - process_keys() if length $keybuf; - update_screen() if $disp_update; - } - continue { - } - } - end_prog(); - } -} - -1; - -# Changelog -# ========= -# 0.9b5 -# - fix endless loop in awin detection code! -# - correct colour swap in awl_viewer -# - fix passing of alternate socket path to the viewer -# - potential undefinedness in mouse refnum hinted at by Canopus -# - fixed regression bug /exec -interactive -# -# 0.8b9 -# - replace fifo mode with external viewer script -# - remove bundled cpan modules -# - work around bogus irssi warning -# - improve mouse support -# - workaround for broken cumode in irssi 0.8.15 -# - fix handling of non-meta windows (uninitialized warning) -# - add 256 colour support, strip true colour codes -# - fix totally bogus $N padding reported by Ed S. -# - make /window goto #name mappings work but ignore non-existant ones -# - improve incomplete reads reported by bcode -# - fix single % in awl_viewer reported by bcode -# - add support for key bindings by nike and ferret -# - coerce utf8 key binds -# - add settings: custom_xform, last_line_shade, hide_name_data -# - abbreviations were broken in some cases -# - fix some misuse of / as cmdchar in mouse script reported by bcode -# - add shared status bar mode -# - ${type} variables for custom_xform setting -# - crash if custom_xform had runtime error -# - update sorting documentation -# - fix odd case in size calculation noted by lasers -# - add missing font styles to the viewer reported by ishanyx -# - add italic -# -# 0.7g -# - remove screen support and replace it with fifo support -# - add double-width support to the shortener -# - correct documentation regarding $T vs. display_header -# - add missing refresh for window item changed (thanks vague) -# - add visible windows -# - add exemptions for active window -# - workaround for hiding the window changes from trackbar -# - hack to force 16colours in screen mode -# - remember last window (reported by earthnative) -# - wrong window focus on new queries (reported by emsid) -# - dataloss bug on trying to remember last window -# -# 0.6d+ -# - add support for network headers -# - fixed regression bug /exec -interactive -# -# 0.6ca+ -# - add screen support (from nicklist.pl) -# - names can now have a max length and window names can be used -# - fixed a bug with block display in screen mode and status bar mode -# - added space handling to ir_fe and removed it again -# - now handling formats on my own -# - started to work on $tag display -# - added warning about missing sb_act_none abstract leading to -# - display*active settings -# - added warning about the bug in awl_display_(no)key_active settings -# - mouse hack -# -# 0.5d -# - add setting to also hide the last status bar if empty (awl_all_disable) -# - reverted to old utf8 code to also calculate broken utf8 length correctly -# - simplified dealing with status bars in wlreset -# - added a little tweak for the renamed term_type somewhere after Irssi 0.8.9 -# - fixed bug in handling channel #$$ -# - reset background colour at the beginning of an entry -# -# 0.4d -# - fixed order of disabling status bars -# - several attempts at special chars, without any real success -# and much more weird new bugs caused by this -# - setting to specify sort order -# - reduced timeout values -# - added awl_hide_data -# - make it so the dynamic sub is actually deleted -# - fix a bug with removing of the last separator -# - take into consideration parse_special -# -# 0.3b -# - automatically kill old status bars -# - reset on /reload -# - position/placement settings -# -# 0.2 -# - automated retrieval of key bindings (thanks grep.pl authors) -# - improved removing of status bars -# - got rid of status chop -# -# 0.1 -# - Based on chanact.pl which was apparently based on lightbar.c and -# nicklist.pl with various other ideas from random scripts. diff --git a/dotfiles/irssi/scripts/autorun/adv_windowlist.pl b/dotfiles/irssi/scripts/autorun/adv_windowlist.pl deleted file mode 120000 index d210a5c..0000000 --- a/dotfiles/irssi/scripts/autorun/adv_windowlist.pl +++ /dev/null @@ -1 +0,0 @@ -../adv_windowlist.pl \ No newline at end of file diff --git a/dotfiles/irssi/scripts/autorun/cap_sasl.pl b/dotfiles/irssi/scripts/autorun/cap_sasl.pl deleted file mode 120000 index de66395..0000000 --- a/dotfiles/irssi/scripts/autorun/cap_sasl.pl +++ /dev/null @@ -1 +0,0 @@ -../cap_sasl.pl \ No newline at end of file diff --git a/dotfiles/irssi/scripts/cap_sasl.pl b/dotfiles/irssi/scripts/cap_sasl.pl deleted file mode 100644 index 9eb443a..0000000 --- a/dotfiles/irssi/scripts/cap_sasl.pl +++ /dev/null @@ -1,272 +0,0 @@ -use strict; -use Irssi; -use vars qw($VERSION %IRSSI); -# $Id$ - -use MIME::Base64; - -$VERSION = "1.3"; - -%IRSSI = ( - authors => 'Michael Tharp and Jilles Tjoelker', - contact => 'gxti@partiallystapled.com', - name => 'cap_sasl.pl', - description => 'Implements PLAIN SASL authentication mechanism for use with charybdis ircds, and enables CAP MULTI-PREFIX', - license => 'GNU General Public License', - url => 'http://ircv3.atheme.org/extensions/sasl-3.1', -); - -my %sasl_auth = (); -my %mech = (); - -sub timeout; - -sub server_connected { - my $server = shift; - $server->send_raw_now("CAP LS"); -} - -sub event_cap { - my ($server, $args, $nick, $address) = @_; - my ($subcmd, $caps, $tosend); - - $tosend = ''; - if ($args =~ /^\S+ (\S+) :(.*)$/) { - $subcmd = uc $1; - $caps = ' '.$2.' '; - if ($subcmd eq 'LS') { - $tosend .= ' multi-prefix' if $caps =~ / multi-prefix /i; - $tosend .= ' sasl' if $caps =~ / sasl /i && defined($sasl_auth{$server->{tag}}); - $tosend =~ s/^ //; - $server->print('', "CLICAP: supported by server:$caps"); - if (!$server->{connected}) { - if ($tosend eq '') { - $server->send_raw_now("CAP END"); - } else { - $server->print('', "CLICAP: requesting: $tosend"); - $server->send_raw_now("CAP REQ :$tosend"); - } - } - Irssi::signal_stop(); - } elsif ($subcmd eq 'ACK') { - $server->print('', "CLICAP: now enabled:$caps"); - if ($caps =~ / sasl /i) { - $sasl_auth{$server->{tag}}{buffer} = ''; - if($mech{$sasl_auth{$server->{tag}}{mech}}) { - $server->send_raw_now("AUTHENTICATE " . $sasl_auth{$server->{tag}}{mech}); - Irssi::timeout_add_once(5000, \&timeout, $server->{tag}); - }else{ - $server->print('', 'SASL: attempted to start unknown mechanism "' . $sasl_auth{$server->{tag}}{mech} . '"'); - } - } - elsif (!$server->{connected}) { - $server->send_raw_now("CAP END"); - } - Irssi::signal_stop(); - } elsif ($subcmd eq 'NAK') { - $server->print('', "CLICAP: refused:$caps"); - if (!$server->{connected}) { - $server->send_raw_now("CAP END"); - } - Irssi::signal_stop(); - } elsif ($subcmd eq 'LIST') { - $server->print('', "CLICAP: currently enabled:$caps"); - Irssi::signal_stop(); - } - } -} - -sub event_authenticate { - my ($server, $args, $nick, $address) = @_; - my $sasl = $sasl_auth{$server->{tag}}; - return unless $sasl && $mech{$sasl->{mech}}; - - $sasl->{buffer} .= $args; - return if length($args) == 400; - - my $data = $sasl->{buffer} eq '+' ? '' : decode_base64($sasl->{buffer}); - my $out = $mech{$sasl->{mech}}($sasl, $data); - $out = '' unless defined $out; - $out = $out eq '' ? '+' : encode_base64($out, ''); - - while(length $out >= 400) { - my $subout = substr($out, 0, 400, ''); - $server->send_raw_now("AUTHENTICATE $subout"); - } - if(length $out) { - $server->send_raw_now("AUTHENTICATE $out"); - }else{ # Last piece was exactly 400 bytes, we have to send some padding to indicate we're done - $server->send_raw_now("AUTHENTICATE +"); - } - - $sasl->{buffer} = ''; - Irssi::signal_stop(); -} - -sub event_saslend { - my ($server, $args, $nick, $address) = @_; - - my $data = $args; - $data =~ s/^\S+ :?//; - # need this to see it, ?? -- jilles - $server->print('', $data); - if (!$server->{connected}) { - $server->send_raw_now("CAP END"); - } -} - -sub timeout { - my $tag = shift; - my $server = Irssi::server_find_tag($tag); - if(!$server->{connected}) { - $server->print('', "SASL: authentication timed out"); - $server->send_raw_now("CAP END"); - } -} - -sub cmd_sasl { - my ($data, $server, $item) = @_; - - if ($data ne '') { - Irssi::command_runsub ('sasl', $data, $server, $item); - } else { - cmd_sasl_show(@_); - } -} - -sub cmd_sasl_set { - my ($data, $server, $item) = @_; - - if (my($net, $u, $p, $m) = $data =~ /^(\S+) (\S+) (\S+) (\S+)$/) { - if($mech{uc $m}) { - $sasl_auth{$net}{user} = $u; - $sasl_auth{$net}{password} = $p; - $sasl_auth{$net}{mech} = uc $m; - Irssi::print("SASL: added $net: [$m] $sasl_auth{$net}{user} *"); - }else{ - Irssi::print("SASL: unknown mechanism $m"); - } - } elsif ($data =~ /^(\S+)$/) { - $net = $1; - if (defined($sasl_auth{$net})) { - delete $sasl_auth{$net}; - Irssi::print("SASL: deleted $net"); - } else { - Irssi::print("SASL: no entry for $net"); - } - } else { - Irssi::print("SASL: usage: /sasl set "); - } -} - -sub cmd_sasl_show { - #my ($data, $server, $item) = @_; - my $net; - my $count = 0; - - foreach $net (keys %sasl_auth) { - Irssi::print("SASL: $net: [$sasl_auth{$net}{mech}] $sasl_auth{$net}{user} *"); - $count++; - } - Irssi::print("SASL: no networks defined") if !$count; -} - -sub cmd_sasl_save { - #my ($data, $server, $item) = @_; - my $file = Irssi::get_irssi_dir()."/sasl.auth"; - open FILE, "> $file" or return; - foreach my $net (keys %sasl_auth) { - printf FILE ("%s\t%s\t%s\t%s\n", $net, $sasl_auth{$net}{user}, $sasl_auth{$net}{password}, $sasl_auth{$net}{mech}); - } - close FILE; - Irssi::print("SASL: auth saved to $file"); -} - -sub cmd_sasl_load { - #my ($data, $server, $item) = @_; - my $file = Irssi::get_irssi_dir()."/sasl.auth"; - - open FILE, "< $file" or return; - %sasl_auth = (); - while () { - chomp; - my ($net, $u, $p, $m) = split (/\t/, $_, 4); - $m ||= "PLAIN"; - if($mech{uc $m}) { - $sasl_auth{$net}{user} = $u; - $sasl_auth{$net}{password} = $p; - $sasl_auth{$net}{mech} = uc $m; - }else{ - Irssi::print("SASL: unknown mechanism $m"); - } - } - close FILE; - Irssi::print("SASL: auth loaded from $file"); -} - -sub cmd_sasl_mechanisms { - Irssi::print("SASL: mechanisms supported: " . join(" ", keys %mech)); -} - -Irssi::signal_add_first('server connected', \&server_connected); -Irssi::signal_add('event cap', \&event_cap); -Irssi::signal_add('event authenticate', \&event_authenticate); -Irssi::signal_add('event 903', 'event_saslend'); -Irssi::signal_add('event 904', 'event_saslend'); -Irssi::signal_add('event 905', 'event_saslend'); -Irssi::signal_add('event 906', 'event_saslend'); -Irssi::signal_add('event 907', 'event_saslend'); - -Irssi::command_bind('sasl', \&cmd_sasl); -Irssi::command_bind('sasl load', \&cmd_sasl_load); -Irssi::command_bind('sasl save', \&cmd_sasl_save); -Irssi::command_bind('sasl set', \&cmd_sasl_set); -Irssi::command_bind('sasl show', \&cmd_sasl_show); -Irssi::command_bind('sasl mechanisms', \&cmd_sasl_mechanisms); - -$mech{PLAIN} = sub { - my($sasl, $data) = @_; - my $u = $sasl->{user}; - my $p = $sasl->{password}; - - join("\0", $u, $u, $p); -}; - -eval { - require Crypt::OpenSSL::Bignum; - require Crypt::DH; - require Crypt::Blowfish; - require Math::BigInt; - sub bin2bi { return Crypt::OpenSSL::Bignum->new_from_bin(shift)->to_decimal } # binary to BigInt - sub bi2bin { return Crypt::OpenSSL::Bignum->new_from_decimal((shift)->bstr)->to_bin } # BigInt to binary - $mech{'DH-BLOWFISH'} = sub { - my($sasl, $data) = @_; - my $u = $sasl->{user}; - my $pass = $sasl->{password}; - - # Generate private key and compute secret key - my($p, $g, $y) = unpack("(n/a*)3", $data); - my $dh = Crypt::DH->new(p => bin2bi($p), g => bin2bi($g)); - $dh->generate_keys; - - my $secret = bi2bin($dh->compute_secret(bin2bi($y))); - my $pubkey = bi2bin($dh->pub_key); - - # Pad the password to the nearest multiple of blocksize and encrypt - $pass .= "\0"; - $pass .= chr(rand(256)) while length($pass) % 8; - - my $cipher = Crypt::Blowfish->new($secret); - my $crypted = ''; - while(length $pass) { - my $clear = substr($pass, 0, 8, ''); - $crypted .= $cipher->encrypt($clear); - } - - pack("n/a*Z*a*", $pubkey, $u, $crypted); - }; -}; - -cmd_sasl_load(); - -# vim: ts=4 diff --git a/install.sh b/install.sh index 6169fa6..6ba065a 100755 --- a/install.sh +++ b/install.sh @@ -8,98 +8,31 @@ set -o shwordsplit 2>/dev/null || true # Make zsh behave like bash HOME=${HOME:-$(cd ~ && pwd)} -case $(uname) in - Linux) - FINDTYPE="-xtype" - ;; - Darwin|*BSD) - FINDTYPE="-type" - ;; - *) - echo "Unknown OS: $(uname), guessing no GNU utils." - FINDTYPE="-type" - ;; -esac + have_command() { command -v "${1}" >/dev/null 2>&1 } -prerequisites() { - local USER=${USER:-$(id -un)} - if have_command zsh ; then - case $- in - *i*) - local shell_path - if [[ "$(uname)" = "Darwin" ]]; then - # dscl output is "UserShell: /bin/zsh" - shell_path="$(dscl . -read "/Users/${USER}" UserShell | awk '{print $2}')" - else - shell_path="$(getent passwd "${USER}" | cut -d: -f7)" - fi - case "${shell_path}" in - */zsh) - ;; - *) - echo "Your login shell is not zsh. To change it, run:" >&2 - echo "chsh -s $(command -v zsh)" >&2 - ;; - esac - ;; - esac - else - echo "ZSH not found!" >&2 - fi -} + link_directory_contents() { local SRCDIR="${1}" local DESTDIR="${2}" local PREFIX="${3}" local file - local submodule_prune="" - - # Submodule logic only applies when we are installing dotfiles (PREFIX=".") - if [[ "${PREFIX}" == "." ]]; then - submodule_prune="$(git -C "${BASEDIR}" submodule status -- "${SRCDIR}" 2>/dev/null | \ - awk '{print $2}' | \ - while read -r submod ; do - echo -n " -o -path ${BASEDIR}/${submod}" - done)" - fi # shellcheck disable=SC2086 find "${SRCDIR}" \( -name .git -o \ -name install.sh -o \ -name README.md -o \ - -name .gitignore \ - ${submodule_prune} \) \ - -prune -o ${FINDTYPE} f -print | \ + -name .gitignore \) \ + -prune -o -type f -print | \ while read -r file ; do local TARGET="${DESTDIR}/${PREFIX}${file#"${SRCDIR}"/}" mkdir -p "$(dirname "${TARGET}")" ln -s -f "${file}" "${TARGET}" done - - # Submodule logic only applies when we are installing dotfiles (PREFIX=".") - if [[ "${PREFIX}" == "." ]]; then - git -C "${BASEDIR}" submodule status -- "${SRCDIR}" 2>/dev/null | \ - awk '{print $2}' | \ - while read -r submodule ; do - local FULLNAME="${BASEDIR}/${submodule}" - local TARGET="${DESTDIR}/${PREFIX}${FULLNAME#"${SRCDIR}"/}" - mkdir -p "$(dirname "${TARGET}")" - if [[ -L "${TARGET}" ]] ; then - if [[ "$(readlink "${TARGET}")" != "${FULLNAME}" ]] ; then - echo "${TARGET} points to $(readlink "${TARGET}") not ${FULLNAME}!" >/dev/stderr - fi - elif [[ -d "${TARGET}" ]] ; then - echo "rm -rf ${TARGET}" >/dev/stderr - else - ln -s -f "${FULLNAME}" "${TARGET}" - fi - done - fi } ssh_key_already_installed() { @@ -259,7 +192,6 @@ install_main() { fi fi [[ "$MINIMAL" = 1 ]] || { - prerequisites # Install vim-plug if not already present local VIM_PLUG_URL="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" @@ -294,7 +226,6 @@ install_main() { for dotfiledir in "${BASEDIR}/dotfile_overlays/"* ; do if [[ -d "${dotfiledir}/.git" ]] ; then git -C "${dotfiledir}" pull --ff-only || true - git -C "${dotfiledir}" submodule update --init --recursive --depth 1 || true fi done fi @@ -307,24 +238,6 @@ install_main() { cleanup } -install_vim_extra() { - local DEST="${HOME}/.vim/pack/matir-extra" - local REPO="https://github.com/Matir/vim-extra.git" - - if [[ -d "${DEST}" ]] ; then - if [[ -d "${DEST}/.git" ]] ; then - # do update - git -C "${DEST}" pull --ff-only - git -C "${DEST}" submodule update --init - else - echo "${DEST} exists but does not appear to be a git repo." >&2 - return 1 - fi - else - # do clone - git clone --recurse-submodules "${REPO}" "${DEST}" - fi -} # Setup variables read_saved_prefs @@ -353,10 +266,6 @@ case $OPERATION in dotfiles) install_dotfiles ;; - vim-extra) - # Install/update extra vim modules - install_vim_extra - ;; *) echo "Unknown operation $OPERATION." >&2 exit 1