commit 0bb525e98021ee31a6dd3ef31246267036124102
Author: Simon Watson <spw01@protonmail.com>
Date: Wed Jun 30 16:01:24 2021 -0400
Inital Recommit. Migrating back to github
diff --git a/README.md b/README.md
index fe3f871..f1a3f63 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,2 @@
# dotfiles
-dotfiles
+Config files I want to keep track of
diff --git a/awesome/rc.lua b/awesome/rc.lua
new file mode 100644
index 0000000..d8c06af
--- /dev/null
+++ b/awesome/rc.lua
@@ -0,0 +1,379 @@
+-- Standard awesome library
+require("awful")
+require("awful.autofocus")
+require("awful.rules")
+-- Theme handling library
+require("beautiful")
+-- Notification library
+require("naughty")
+
+-- Load Debian menu entries
+require("debian.menu")
+
+-- {{{ Error handling
+-- Check if awesome encountered an error during startup and fell back to
+-- another config (This code will only ever execute for the fallback config)
+if awesome.startup_errors then
+ naughty.notify({ preset = naughty.config.presets.critical,
+ title = "Oops, there were errors during startup!",
+ text = awesome.startup_errors })
+end
+
+-- Handle runtime errors after startup
+do
+ local in_error = false
+ awesome.add_signal("debug::error", function (err)
+ -- Make sure we don't go into an endless error loop
+ if in_error then return end
+ in_error = true
+
+ naughty.notify({ preset = naughty.config.presets.critical,
+ title = "Oops, an error happened!",
+ text = err })
+ in_error = false
+ end)
+end
+-- }}}
+
+-- {{{ Variable definitions
+-- Themes define colours, icons, and wallpapers
+beautiful.init("/usr/share/awesome/themes/zenburn/theme.lua")
+
+-- This is used later as the default terminal and editor to run.
+terminal = "terminator"
+editor = os.getenv("EDITOR") or "editor"
+editor_cmd = terminal .. " -e " .. editor
+
+-- Default modkey.
+-- Usually, Mod4 is the key with a logo between Control and Alt.
+-- If you do not like this or do not have such a key,
+-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
+-- However, you can use another modifier like Mod1, but it may interact with others.
+modkey = "Mod4"
+
+-- Table of layouts to cover with awful.layout.inc, order matters.
+layouts =
+{
+ awful.layout.suit.floating,
+ awful.layout.suit.tile,
+ awful.layout.suit.tile.left,
+ awful.layout.suit.tile.bottom,
+ awful.layout.suit.tile.top,
+ awful.layout.suit.fair,
+ awful.layout.suit.fair.horizontal,
+ awful.layout.suit.spiral,
+ awful.layout.suit.spiral.dwindle,
+ awful.layout.suit.max,
+ awful.layout.suit.max.fullscreen,
+ awful.layout.suit.magnifier
+}
+-- }}}
+
+-- {{{ Tags
+-- Define a tag table which hold all screen tags.
+tags = {}
+for s = 1, screen.count() do
+ -- Each screen has its own tag table.
+ tags[s] = awful.tag({ "www", "term", "irc", "games", "music" }, s, layouts[1])
+end
+-- }}}
+
+-- {{{ Menu
+-- Create a laucher widget and a main menu
+myawesomemenu = {
+ { "manual", terminal .. " -e man awesome" },
+ { "edit config", editor_cmd .. " " .. awesome.conffile },
+ { "restart", awesome.restart },
+ { "quit", awesome.quit }
+}
+
+mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
+ { "Debian", debian.menu.Debian_menu.Debian },
+ { "open terminal", terminal }
+ }
+ })
+
+mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
+ menu = mymainmenu })
+-- }}}
+
+-- {{{ Wibox
+-- Create a textclock widget
+mytextclock = awful.widget.textclock({ align = "right" })
+
+-- Create a systray
+mysystray = widget({ type = "systray" })
+
+-- Create a wibox for each screen and add it
+mystatusbar = awful.wibox({ position = "bottom", screen = 1, ontop = false, width = 1, height = 16 })
+
+mywibox = {}
+mypromptbox = {}
+mylayoutbox = {}
+mytaglist = {}
+mytaglist.buttons = awful.util.table.join(
+ awful.button({ }, 1, awful.tag.viewonly),
+ awful.button({ modkey }, 1, awful.client.movetotag),
+ awful.button({ }, 3, awful.tag.viewtoggle),
+ awful.button({ modkey }, 3, awful.client.toggletag),
+ awful.button({ }, 4, awful.tag.viewnext),
+ awful.button({ }, 5, awful.tag.viewprev)
+ )
+mytasklist = {}
+mytasklist.buttons = awful.util.table.join(
+ awful.button({ }, 1, function (c)
+ if c == client.focus then
+ c.minimized = true
+ else
+ if not c:isvisible() then
+ awful.tag.viewonly(c:tags()[1])
+ end
+ -- This will also un-minimize
+ -- the client, if needed
+ client.focus = c
+ c:raise()
+ end
+ end),
+ awful.button({ }, 3, function ()
+ if instance then
+ instance:hide()
+ instance = nil
+ else
+ instance = awful.menu.clients({ width=250 })
+ end
+ end),
+ awful.button({ }, 4, function ()
+ awful.client.focus.byidx(1)
+ if client.focus then client.focus:raise() end
+ end),
+ awful.button({ }, 5, function ()
+ awful.client.focus.byidx(-1)
+ if client.focus then client.focus:raise() end
+ end))
+
+for s = 1, screen.count() do
+ -- Create a promptbox for each screen
+ mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
+ -- Create an imagebox widget which will contains an icon indicating which layout we're using.
+ -- We need one layoutbox per screen.
+ mylayoutbox[s] = awful.widget.layoutbox(s)
+ mylayoutbox[s]:buttons(awful.util.table.join(
+ awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
+ awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
+ awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
+ awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
+ -- Create a taglist widget
+ mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
+
+ -- Create a tasklist widget
+ mytasklist[s] = awful.widget.tasklist(function(c)
+ return awful.widget.tasklist.label.currenttags(c, s)
+ end, mytasklist.buttons)
+
+ -- Create the wibox
+ mywibox[s] = awful.wibox({ position = "top", screen = s })
+ -- Add widgets to the wibox - order matters
+ mywibox[s].widgets = {
+ {
+ mylauncher,
+ mytaglist[s],
+ mypromptbox[s],
+ layout = awful.widget.layout.horizontal.leftright
+ },
+ mylayoutbox[s],
+ mytextclock,
+ s == 1 and mysystray or nil,
+ mytasklist[s],
+ layout = awful.widget.layout.horizontal.rightleft
+ }
+end
+-- }}}
+
+-- {{{ Mouse bindings
+root.buttons(awful.util.table.join(
+ awful.button({ }, 3, function () mymainmenu:toggle() end),
+ awful.button({ }, 4, awful.tag.viewnext),
+ awful.button({ }, 5, awful.tag.viewprev)
+))
+-- }}}
+
+-- {{{ Key bindings
+globalkeys = awful.util.table.join(
+ awful.key({ modkey, }, "Left", awful.tag.viewprev ),
+ awful.key({ modkey, }, "Right", awful.tag.viewnext ),
+ awful.key({ modkey, }, "Escape", awful.tag.history.restore),
+
+ awful.key({ modkey, }, "j",
+ function ()
+ awful.client.focus.byidx( 1)
+ if client.focus then client.focus:raise() end
+ end),
+ awful.key({ modkey, }, "k",
+ function ()
+ awful.client.focus.byidx(-1)
+ if client.focus then client.focus:raise() end
+ end),
+ awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
+
+ -- Layout manipulation
+ awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
+ awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
+ awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
+ awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
+ awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
+ awful.key({ modkey, }, "Tab",
+ function ()
+ awful.client.focus.history.previous()
+ if client.focus then
+ client.focus:raise()
+ end
+ end),
+
+ -- Standard program
+ awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
+ awful.key({ modkey, "Control" }, "r", awesome.restart),
+ awful.key({ modkey, "Shift" }, "q", awesome.quit),
+
+ awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
+ awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
+ awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
+ awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
+ awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
+ awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
+ awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
+ awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
+
+ awful.key({ modkey, "Control" }, "n", awful.client.restore),
+
+ -- Prompt
+ awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
+
+ awful.key({ modkey }, "x",
+ function ()
+ awful.prompt.run({ prompt = "Run Lua code: " },
+ mypromptbox[mouse.screen].widget,
+ awful.util.eval, nil,
+ awful.util.getdir("cache") .. "/history_eval")
+ end)
+)
+
+clientkeys = awful.util.table.join(
+ awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
+ awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
+ awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
+ awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
+ awful.key({ modkey, }, "o", awful.client.movetoscreen ),
+ awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
+ awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
+ awful.key({ modkey, }, "n",
+ function (c)
+ -- The client currently has the input focus, so it cannot be
+ -- minimized, since minimized clients can't have the focus.
+ c.minimized = true
+ end),
+ awful.key({ modkey, }, "m",
+ function (c)
+ c.maximized_horizontal = not c.maximized_horizontal
+ c.maximized_vertical = not c.maximized_vertical
+ end)
+)
+
+-- Compute the maximum number of digit we need, limited to 9
+keynumber = 0
+for s = 1, screen.count() do
+ keynumber = math.min(9, math.max(#tags[s], keynumber));
+end
+
+-- Bind all key numbers to tags.
+-- Be careful: we use keycodes to make it works on any keyboard layout.
+-- This should map on the top row of your keyboard, usually 1 to 9.
+for i = 1, keynumber do
+ globalkeys = awful.util.table.join(globalkeys,
+ awful.key({ modkey }, "#" .. i + 9,
+ function ()
+ local screen = mouse.screen
+ if tags[screen][i] then
+ awful.tag.viewonly(tags[screen][i])
+ end
+ end),
+ awful.key({ modkey, "Control" }, "#" .. i + 9,
+ function ()
+ local screen = mouse.screen
+ if tags[screen][i] then
+ awful.tag.viewtoggle(tags[screen][i])
+ end
+ end),
+ awful.key({ modkey, "Shift" }, "#" .. i + 9,
+ function ()
+ if client.focus and tags[client.focus.screen][i] then
+ awful.client.movetotag(tags[client.focus.screen][i])
+ end
+ end),
+ awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
+ function ()
+ if client.focus and tags[client.focus.screen][i] then
+ awful.client.toggletag(tags[client.focus.screen][i])
+ end
+ end))
+end
+
+clientbuttons = awful.util.table.join(
+ awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
+ awful.button({ modkey }, 1, awful.mouse.client.move),
+ awful.button({ modkey }, 3, awful.mouse.client.resize))
+
+-- Set keys
+root.keys(globalkeys)
+-- }}}
+
+-- {{{ Rules
+awful.rules.rules = {
+ -- All clients will match this rule.
+ { rule = { },
+ properties = { border_width = beautiful.border_width,
+ border_color = beautiful.border_normal,
+ focus = true,
+ keys = clientkeys,
+ buttons = clientbuttons } },
+ { rule = { class = "MPlayer" },
+ properties = { floating = true } },
+ { rule = { class = "pinentry" },
+ properties = { floating = true } },
+ { rule = { class = "gimp" },
+ properties = { floating = true } },
+ -- Set Firefox to always map on tags number 2 of screen 1.
+ -- { rule = { class = "Firefox" },
+ -- properties = { tag = tags[1][2] } },
+}
+-- }}}
+
+-- {{{ Signals
+-- Signal function to execute when a new client appears.
+client.add_signal("manage", function (c, startup)
+ -- Add a titlebar
+ -- awful.titlebar.add(c, { modkey = modkey })
+
+ -- Enable sloppy focus
+ c:add_signal("mouse::enter", function(c)
+ if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
+ and awful.client.focus.filter(c) then
+ client.focus = c
+ end
+ end)
+
+ if not startup then
+ -- Set the windows at the slave,
+ -- i.e. put it at the end of others instead of setting it master.
+ -- awful.client.setslave(c)
+
+ -- Put windows in a smart way, only if they does not set an initial position.
+ if not c.size_hints.user_position and not c.size_hints.program_position then
+ awful.placement.no_overlap(c)
+ awful.placement.no_offscreen(c)
+ end
+ end
+end)
+
+client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
+client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
+-- }}}
diff --git a/bashrc/bashRC-11102018 b/bashrc/bashRC-11102018
new file mode 100644
index 0000000..61c8f86
--- /dev/null
+++ b/bashrc/bashRC-11102018
@@ -0,0 +1,126 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+
+# If not running interactively, don't do anything
+case $- in
+ *i*) ;;
+ *) return;;
+esac
+
+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+#shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+ debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+ xterm-color|*-256color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+#force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ # We have color support; assume it's compliant with Ecma-48
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+ # a case would tend to support setf rather than setaf.)
+ color_prompt=yes
+ else
+ color_prompt=
+ fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+ PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+ PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+ ;;
+*)
+ ;;
+esac
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ alias ls='ls --color=auto'
+ #alias dir='dir --color=auto'
+ #alias vdir='vdir --color=auto'
+
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+fi
+
+# colored GCC warnings and errors
+#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+
+# some more ls aliases
+alias ll='ls -alF'
+alias la='ls -A'
+alias l='ls -CF'
+
+alias rofirun='rofi -key-run mod4+d -key-ssh mod4+shift+x -key-window mod4+shift+w -quiet -terminal urxvt &'
+alias colors='python /home/swatson/Repos/colors.py -t'
+alias workup='nmcli --ask connection up DattoVPN'
+alias workdown='nmcli --ask connection down DattoVPN'
+
+#Pull wal config
+#/home/swatson/.local/bin/wal -r
+(cat ~/.cache/wal/sequences &)
+
+# Add an "alert" alias for long running commands. Use like so:
+# sleep 10; alert
+alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
+
+# Alias definitions.
+# You may want to put all your additions into a separate file like
+# ~/.bash_aliases, instead of adding them here directly.
+# See /usr/share/doc/bash-doc/examples in the bash-doc package.
+
+if [ -f ~/.bash_aliases ]; then
+ . ~/.bash_aliases
+fi
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+fi
diff --git a/bashrc/laptop-20190217 b/bashrc/laptop-20190217
new file mode 100644
index 0000000..ece03fd
--- /dev/null
+++ b/bashrc/laptop-20190217
@@ -0,0 +1,132 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+
+# If not running interactively, don't do anything
+case $- in
+ *i*) ;;
+ *) return;;
+esac
+
+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+#shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+ debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+ xterm-color|*-256color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+#force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ # We have color support; assume it's compliant with Ecma-48
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+ # a case would tend to support setf rather than setaf.)
+ color_prompt=yes
+ else
+ color_prompt=
+ fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+ PS1='${debian_chroot:+($debian_chroot)}\e[0;31m[\u\e[m\e[0;34m@\e[0;33m\h:\e[0;37m\w]\$ \e[m'
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+ PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+ ;;
+*)
+ ;;
+esac
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ alias ls='ls --color=auto'
+ #alias dir='dir --color=auto'
+ #alias vdir='vdir --color=auto'
+
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+fi
+
+# colored GCC warnings and errors
+#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+
+# some more ls aliases
+alias ll='ls -alF'
+alias la='ls -A'
+alias l='ls -CF'
+
+alias rofirun='rofi -key-run mod4+d -key-ssh mod4+shift+x -key-window mod4+shift+w -quiet -terminal urxvt &'
+alias colors='python /home/swatson/Repos/colors.py -t'
+alias workup='nmcli --ask connection up DattoVPN'
+alias workdown='nmcli --ask connection down DattoVPN'
+alias dfh='df -h | grep -v snap'
+export EDITOR=$(which vim)
+
+#Pull wal config
+#/home/swatson/.local/bin/wal -r
+(cat ~/.cache/wal/sequences &)
+
+export PATH=$PATH:/home/swatson/.local/bin
+PS1="[\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]]\$ "
+PS1='\[\e]1;\s\$ \W\a\e]2;\u@\h\a\]'"$PS1"
+
+# Add an "alert" alias for long running commands. Use like so:
+# sleep 10; alert
+alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
+
+# Alias definitions.
+# You may want to put all your additions into a separate file like
+# ~/.bash_aliases, instead of adding them here directly.
+# See /usr/share/doc/bash-doc/examples in the bash-doc package.
+
+if [ -f ~/.bash_aliases ]; then
+ . ~/.bash_aliases
+fi
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+fi
diff --git a/bashrc/laptop-20190709 b/bashrc/laptop-20190709
new file mode 100644
index 0000000..96ef7ff
--- /dev/null
+++ b/bashrc/laptop-20190709
@@ -0,0 +1,135 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+
+# If not running interactively, don't do anything
+case $- in
+ *i*) ;;
+ *) return;;
+esac
+
+# don't put duplicate lines or lines starting with space in the history.
+# See bash(1) for more options
+HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+HISTSIZE=1000
+HISTFILESIZE=2000
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# If set, the pattern "**" used in a pathname expansion context will
+# match all files and zero or more directories and subdirectories.
+#shopt -s globstar
+
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
+ debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+ xterm-color|*-256color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+#force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ # We have color support; assume it's compliant with Ecma-48
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+ # a case would tend to support setf rather than setaf.)
+ color_prompt=yes
+ else
+ color_prompt=
+ fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+ PS1='${debian_chroot:+($debian_chroot)}\e[0;31m[\u\e[m\e[0;34m@\e[0;33m\h:\e[0;37m\w]\$ \e[m'
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+ PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+ ;;
+*)
+ ;;
+esac
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+ test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
+ alias ls='ls --color=auto'
+ #alias dir='dir --color=auto'
+ #alias vdir='vdir --color=auto'
+
+ alias grep='grep --color=auto'
+ alias fgrep='fgrep --color=auto'
+ alias egrep='egrep --color=auto'
+fi
+
+# colored GCC warnings and errors
+#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
+
+# some more ls aliases
+alias ll='ls -alF'
+alias la='ls -A'
+alias l='ls -CF'
+
+alias rofirun='rofi -key-run mod4+d -key-ssh mod4+shift+x -key-window mod4+shift+w -quiet -terminal urxvt &'
+alias workup='nmcli --ask connection up DattoVPN'
+alias workdown='nmcli --ask connection down DattoVPN'
+alias dfh='df -h | grep -v snap'
+export EDITOR=$(which vim)
+
+#Pull wal config
+#/home/swatson/.local/bin/wal -r
+(cat ~/.cache/wal/sequences &)
+
+export PATH=/home/spesk/.local/bin:$PATH
+PS1="[\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]]\$ "
+PS1='\[\e]1;\s\$ \W\a\e]2;\u@\h\a\]'"$PS1"
+
+source /home/spesk/.wal_alias
+
+# Add an "alert" alias for long running commands. Use like so:
+# sleep 10; alert
+alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
+
+# Alias definitions.
+# You may want to put all your additions into a separate file like
+# ~/.bash_aliases, instead of adding them here directly.
+# See /usr/share/doc/bash-doc/examples in the bash-doc package.
+
+if [ -f ~/.bash_aliases ]; then
+ . ~/.bash_aliases
+fi
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if ! shopt -oq posix; then
+ if [ -f /usr/share/bash-completion/bash_completion ]; then
+ . /usr/share/bash-completion/bash_completion
+ elif [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+ fi
+fi
+
+[ -f ~/.fzf.bash ] && source ~/.fzf.bash
diff --git a/bashrc/wal_alias b/bashrc/wal_alias
new file mode 100644
index 0000000..ffa7e2c
--- /dev/null
+++ b/bashrc/wal_alias
@@ -0,0 +1,14 @@
+alias wal-gruvbox='wal -n -e --theme base16-gruvbox-soft'
+alias wal-woodland='wal -n -e --theme base16-woodland'
+alias wal-hybrid='wal -n -e --theme hybrid-material'
+alias wal-darktooth='wal -n -e --theme darktooth'
+alias wal-brewer='wal -n -e --theme base16-brewer'
+alias wal-flat='wal -n -e --theme base16-flat'
+alias wal-ashes='wal -n -e --theme base16-ashes'
+alias wal-bespin='wal -n -e --theme base16-bespin'
+alias wal-eighties='wal -n -e --theme base16-eighties'
+alias wal-monokai='wal -n -e --theme base16-monokai'
+alias wal-zenburn='wal -n -e --theme base16-zenburn'
+alias wal-chaires='wal -n -e --theme dkeg-chaires'
+alias wal-visibone='wal -n -e --theme sexy-visibone'
+alias wal-vscode='wal -n -e --theme vscode'
diff --git a/bashrc/walk_wal.pl b/bashrc/walk_wal.pl
new file mode 100755
index 0000000..7b2f5eb
--- /dev/null
+++ b/bashrc/walk_wal.pl
@@ -0,0 +1,63 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+
+# Stupid script to interactively walk through all wal themes, and save
+# a bunch of aliases of themes you like
+
+# wal --theme | grep " - " | grep -v random | sed s/^\ -\ //g
+my $wal_path = "/home/swatson/.local/bin/wal";
+my $theme_cmd = "$wal_path -n -e --theme";
+my @saved;
+my @avail_themes = split("\n", `$wal_path --theme | grep " - " | grep -v random | sed s/^\\ -\\ //g`);
+
+
+
+sub set_wal($) {
+
+ my $theme = shift;
+ system("$theme_cmd $theme");
+
+}
+
+sub gen_alias($) {
+
+ my $theme = shift;
+ my $alias = "alias wal-$theme='wal -n -e --theme $theme'";
+ return $alias;
+
+}
+
+sub dump_saved() {
+
+ foreach my $entry ( @saved ) {
+ print "$entry\n";
+ }
+
+}
+
+foreach my $theme ( @avail_themes ) {
+
+ set_wal($theme);
+ print "Theme is: $theme\n";
+ print "Hit n for next, a to add to alias list, q to quit\n";
+ my $input = <STDIN>;
+ chomp $input;
+
+ if ( $input =~ m/n/ ) {
+ next;
+ } elsif ( $input =~ m/a/ ) {
+ my $alias = gen_alias($theme);
+ push(@saved,$alias);
+ print "Saved $theme\n";
+ next;
+ } elsif ( $input =~ m/q/ ) {
+ dump_saved();
+ exit 0;
+ } else {
+ next;
+ }
+
+}
+
+dump_saved();
diff --git a/compton/compton.conf b/compton/compton.conf
new file mode 100644
index 0000000..ca34f84
--- /dev/null
+++ b/compton/compton.conf
@@ -0,0 +1,41 @@
+# Shadow
+shadow = true; # Enabled client-side shadows on windows.
+no-dock-shadow = true; # Avoid drawing shadows on dock/panel windows.
+no-dnd-shadow = true; # Don't draw shadows on DND windows.
+clear-shadow = true; # Zero the part of the shadow's mask behind the window (experimental).
+shadow-radius = 7; # The blur radius for shadows. (default 12)
+shadow-offset-x = -10; # The left offset for shadows. (default -15)
+shadow-offset-y = -10; # The top offset for shadows. (default -15)
+shadow-exclude = [ "n:e:Notification", "g:e:Synapse", "g:e:Conky", "n:w:*Firefox*", "n:w:*Chromium*", "class_g ?= 'Xfce4-notifyd'", "class_g ?= 'Xfce4-power-manager'"];
+#opacity-exclude = [ "class_g ?= 'Firefox'", "class_g ?= 'Chromium'", ];
+
+menu-opacity = 1.0;
+inactive-opacity = 0.85;
+inactive-opacity-override = true;
+
+mark-wmwin-focused = true; # Try to detect WM windows and mark them as active.
+mark-ovredir-focused = true;
+detect-rounded-corners = true;
+
+#blur-background = true;
+#blur-background-frame = true;
+#blur-kern = "3x3box";
+
+# Fading
+fading = true; # Fade windows during opacity changes.
+#fade-delta = 5; # The time between steps in a fade in milliseconds. (default 10).
+fade-in-step = 0.1; # Opacity change between steps while fading in. (default 0.028).
+fade-out-step = 0.1; # Opacity change between steps while fading out. (default 0.03).
+#no-fading-openclose = true; # Fade windows in/out when opening/closing
+
+#detect-rounded-corners = true;
+
+# Window type settings
+opacity-rule = [
+ "0:_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'"
+];
+wintypes:
+{
+ tooltip = { fade = true; shadow = false; };
+ };
+
diff --git a/conky/conkyrc b/conky/conkyrc
new file mode 100644
index 0000000..be25d6f
--- /dev/null
+++ b/conky/conkyrc
@@ -0,0 +1,69 @@
+# Conky, a system monitor, based on torsmo
+#
+# Any original torsmo code is licensed under the BSD license
+#
+# All code written since the fork of torsmo is licensed under the GPL
+#
+# Please see COPYING for details
+#
+# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
+# Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
+# All rights reserved.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+alignment bottom_middle
+background yes
+border_width 1
+cpu_avg_samples 2
+default_color 222222
+default_outline_color 222222
+draw_borders no
+draw_graph_borders yes
+draw_outline no
+draw_shades no
+use_xft yes
+xftfont Sans Mono:size=8
+gap_x 235
+gap_y 0
+minimum_size 1920
+maximum_width 1920
+net_avg_samples 2
+no_buffers yes
+out_to_console no
+out_to_stderr no
+extra_newline no
+own_window no
+own_window_class Conky
+own_window_type desktop
+own_window_transparent yes
+stippled_borders 0
+update_interval 1.0
+uppercase no
+show_graph_scale no
+show_graph_range no
+format_human_readable yes
+
+color2 DEFF9D
+color1 728BA3
+
+TEXT
+${color1}TREEBEARD \
+${color1}Load: ${color2}${loadavg 3} \
+${color1}CPU: ${color2}${cpu cpu0}% \
+${color1}CPUTEMP: ${color2}${acpitemp}C \
+${color1}URAM: ${color2}${mem} \
+${color1}FREE: ${color2}${fs_free /} \
+${color1}KERNAL: ${color2}${kernel} \
+${color1}PROCS: ${color2}${processes} \
diff --git a/firefox/chrome/userChrome.css b/firefox/chrome/userChrome.css
new file mode 100644
index 0000000..d521b76
--- /dev/null
+++ b/firefox/chrome/userChrome.css
@@ -0,0 +1,145 @@
+/*@import "scrollbars.css";*/
+
+/* New Tab Flash */
+:root{--newtab-textbox-background-color:#263238;}
+
+#browser vbox#appcontent tabbrowser,
+#content,
+#tabbrowser-tabpanels,
+browser[type=content-primary],
+browser[type=content] > html{
+ background: #263238 !important
+}
+
+.tab-line {
+display : none !important;
+}
+
+/* Toolbar buttons */
+.toolbarbutton-1 {
+ fill: #81A1C1 !important;
+ background-color: #263238 !important;
+}
+
+/* Remove border under navbar */
+#navigator-toolbox::after {
+ border-bottom: 0px !important;
+}
+
+/* remove some borders */
+#navigator-toolbox {
+ border: none !important;
+}
+
+#titlebar {
+ border: none !important;
+}
+
+#tabbrowser-tabs {
+background-color: #263238 !important;
+}
+
+/* remove lines */
+
+#navigator-toolbox::after {
+ display: none !important;
+}
+
+#nav-bar, #TabsToolbar {
+ border: none !important;
+}
+
+.tabbrowser-tab::before,
+.tabbrowser-tab::after{
+ display: none !important;
+
+}
+tab
+{
+ background-color: #263238 !important;
+ font-weight: thin !important;
+ color : #81A1C1 !important;
+}
+
+
+.tab-content[selected="true"]
+{
+ background-color: #263238 !important;
+ font-weight: bold !important;
+ color : #81A1C1 !important;
+}
+
+#nav-bar-customization-target {
+ background-color: #263238 !important;
+}
+
+
+.tabbrowser-tab{ opacity: 0.5 }
+.tabbrowser-tab:hover{ opacity: 0.75 }
+.tabbrowser-tab[selected]{ opacity: 1 }
+
+#urlbar{
+ box-shadow: none !important;
+ background-color: #263238 !important;
+ background: none !important;
+ border: none !important;
+ color : #81A1C1 !important;
+ font-weight: bold !important;
+}
+
+#urlbar:hover{
+ box-shadow: none !important;
+}
+
+#tracking-protection-icon-container,#pageActionSeparator{ border-inline-width: 0px !important; }
+.urlbar-icon,
+.urlbar-icon-wrapper,
+#tabbrowser-tabs toolbarbutton,
+toolbar toolbarbutton > .toolbarbutton-icon,
+toolbar toolbarbutton > .toolbarbutton-badge-stack,
+.titlebar-button,
+#identity-box,
+#tracking-protection-icon-container,
+.findbar-textbox~toolbarbutton,
+toolbarbutton.scrollbutton-up,
+toolbarbutton.scrollbutton-down{ background-color: transparent !important;}
+
+.tabbrowser-tab:hover > .tab-stack > .tab-background:not([selected="true"]):not([multiselected]){ background-color: transparent !important }
+
+/*Tabs below nav bar*/
+#nav-bar {
+ -moz-box-ordinal-group: 1 !important;
+}
+#PersonalToolbar {
+ -moz-box-ordinal-group: 2 !important;
+}
+#titlebar {
+ -moz-box-ordinal-group: 3 !important;
+}
+
+#navigator-toolbox{
+ margin-top: 0px;
+ padding-top:0px !important;
+}
+#toolbar-menubar{
+ position: fixed;
+ top: 0px;
+}
+/*#navigator-toolbox { --tabs-border-color: transparent !important; }*//* remove weird line*/
+
+
+
+/*Hide tabs bar if one tab is opened*/
+#tabbrowser-tabs, #tabbrowser-tabs > .tabbrowser-arrowscrollbox {
+ min-height: 0 !important;
+}
+
+#tabbrowser-tabs tab[first-visible-tab="true"][last-visible-tab="true"] {
+ visibility: collapse !important;
+}
+
+#tabbrowser-tabs #tabs-newtab-button {
+ visibility: collapse !important;
+}
+
+
diff --git a/firefox/chrome/userContent.css b/firefox/chrome/userContent.css
new file mode 100644
index 0000000..b5ea739
--- /dev/null
+++ b/firefox/chrome/userContent.css
@@ -0,0 +1,50 @@
+ @-moz-document url("about:home"),url(about:preferences),url("about:blank"),url("about:newtab"),url("about:privatebrowsing"){
+ body{background-color:#2E3440!important;--newtab-search-icon: transparent !important;}
+ a,a:visited,a:hover{color:#2E3440!important}
+ #newtab-search-text {
+ background-color: #2E3440 !important;
+ font-size: 18px !important;
+ color: #88C0D0 !important;
+ box-shadow: none !important;
+ text-align: center !important;
+ border:none !important;
+ font-weight: bold !important;
+ }
+
+.search-wrapper input {
+ --newtab-textbox-focus-boxshadow: none !important;
+ padding-left: 20px !important;
+ padding-inline-end: 13px !important;
+ }
+
+
+.search-wrapper .logo-and-wordmark .wordmark {
+ display: none!important;
+}
+
+.search-wrapper .logo-and-wordmark {
+ margin-bottom: 40px!important;
+ padding-top: 60px!important;
+ opacity:0.5!important;
+}
+
+
+
+.search-button{background:none !important;}
+
+.prefs-button button {fill: #88C0D0 !important;}
+
+.prefs-button button:hover, .prefs-button button:focus {
+ background-color: transparent !important; }
+
+ .contentSearchSuggestionTable {display: none !important;}
+
+
+}
+:root {
+
+ --in-content-border-active: #88C0D0 !important;
+ --in-content-border-active-shadow: none !important;
+ --in-content-page-background: #2E3440 !important;
+}
+
diff --git a/firefox/startpage/tree_home/README.md b/firefox/startpage/tree_home/README.md
new file mode 100644
index 0000000..d909483
--- /dev/null
+++ b/firefox/startpage/tree_home/README.md
@@ -0,0 +1 @@
+_a basic term-like startpage with tree structure_
\ No newline at end of file
diff --git a/firefox/startpage/tree_home/css/style.css b/firefox/startpage/tree_home/css/style.css
new file mode 100644
index 0000000..cf18f85
--- /dev/null
+++ b/firefox/startpage/tree_home/css/style.css
@@ -0,0 +1,111 @@
+@font-face {
+ font-family: "Roboto Mono";
+ src: url("../fonts/roboto-mono-medium.ttf");
+}
+
+:root {
+ --font: "Roboto Mono";
+ --background: #0f0e17;
+ --foreground: #fffffe;
+ --pink: #e53170;
+ --red: #f25f4c;
+ --orange: #ff8906;
+ --branch: 1px solid #a7a9be;
+}
+
+html {
+ font-size: 18px;
+}
+
+body {
+ background: var(--background);
+}
+
+.container {
+ position: absolute;
+ top: 50%;
+ left: 45%;
+ transform: translate(-50%, -50%);
+}
+
+.prompt {
+ font-family: var(--font);
+ color: var(--foreground);
+}
+
+.prompt~.prompt {
+ padding: 1.5rem 0 0.3125rem;
+}
+
+span {
+ color: var(--pink);
+}
+
+h1 {
+ display: inline;
+ font-family: var(--font);
+ font-size: 1rem;
+ font-weight: normal;
+ color: var(--red);
+}
+
+.tree > ul {
+ margin: 0;
+ padding-left: 1rem;
+}
+
+ul {
+ list-style: none;
+ padding-left: 2.5rem;
+}
+
+li {
+ position: relative;
+}
+
+li::before, li::after {
+ content: "";
+ position: absolute;
+ left: -0.75rem;
+}
+
+li::before {
+ border-top: var(--branch);
+ top: 0.75rem;
+ width: 0.5rem;
+}
+
+li::after {
+ border-left: var(--branch);
+ height: 100%;
+ top: 0.25rem;
+}
+
+li:last-child::after {
+ height: 0.5rem;
+}
+
+a {
+ font-family: var(--font);
+ font-size: 1rem;
+ color: var(--foreground);
+ text-decoration: none;
+ outline: none;
+}
+
+a:hover {
+ color: var(--background);
+ background: var(--orange);
+}
+
+form h1 {
+ padding-left: 0.125rem;
+}
+
+input {
+ font-family: var(--font);
+ font-size: 1rem;
+ color: var(--foreground);
+ background-color: var(--background);
+ border: none;
+}
diff --git a/firefox/startpage/tree_home/fonts/roboto-mono-medium.ttf b/firefox/startpage/tree_home/fonts/roboto-mono-medium.ttf
new file mode 100644
index 0000000..c496725
Binary files /dev/null and b/firefox/startpage/tree_home/fonts/roboto-mono-medium.ttf differ
diff --git a/firefox/startpage/tree_home/index.html b/firefox/startpage/tree_home/index.html
new file mode 100644
index 0000000..f6cc9e5
--- /dev/null
+++ b/firefox/startpage/tree_home/index.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <link rel="stylesheet" type="text/css" href="css/style.css">
+ <title>Home</title>
+ </head>
+ <body>
+ <div class="container">
+ <div class="prompt">[<span>swatson</span>@<span>home</span> ~]$ tree</div>
+ <div class="tree">
+ <ul>
+ <li>
+ <h1>sites</h1>
+ <ul>
+ <li><a href="https://reddit.com/r/unixporn">/r/unixporn</a></li>
+ <li><a href="https://reddit.com/r/firefoxcss">/r/firefoxcss</a></li>
+ <li><a href="https://gamingonlinux.com">GoL</a></li>
+ <li><a href="https://protonmail.com">protonmail</a></li>
+ </ul>
+ </li>
+ </ul>
+ </div>
+ </body>
+</html>
diff --git a/fonts/.fonts.conf b/fonts/.fonts.conf
new file mode 100644
index 0000000..acb7380
--- /dev/null
+++ b/fonts/.fonts.conf
@@ -0,0 +1,10 @@
+<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
+<fontconfig>
+ <selectfont>
+ <acceptfont>
+ <pattern>
+ <patelt name="family"><string>Gohufont</string></patelt>
+ </pattern>
+ </acceptfont>
+ </selectfont>
+</fontconfig>
diff --git a/i3/config.bak b/i3/config.bak
new file mode 100644
index 0000000..df74b52
--- /dev/null
+++ b/i3/config.bak
@@ -0,0 +1,157 @@
+# This file has been auto-generated by i3-config-wizard(1).
+# It will not be overwritten, so edit it as you like.
+#
+# Should you change your keyboard layout some time, delete
+# this file and re-run i3-config-wizard(1).
+#
+
+# i3 config file (v4)
+#
+# Please see http://i3wm.org/docs/userguide.html for a complete reference!
+
+set $mod Mod4
+
+# Font for window titles. Will also be used by the bar unless a different font
+# is used in the bar {} block below.
+font pango:monospace 8
+
+# This font is widely installed, provides lots of unicode glyphs, right-to-left
+# text rendering and scalability on retina/hidpi displays (thanks to pango).
+#font pango:DejaVu Sans Mono 8
+
+# Before i3 v4.8, we used to recommend this one as the default:
+# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+# The font above is very space-efficient, that is, it looks good, sharp and
+# clear in small sizes. However, its unicode glyph coverage is limited, the old
+# X core fonts rendering does not support right-to-left and this being a bitmap
+# font, it doesn’t scale on retina/hidpi displays.
+
+# Use Mouse+$mod to drag floating windows to their wanted position
+floating_modifier $mod
+
+# start a terminal
+bindsym $mod+Return exec i3-sensible-terminal
+
+# kill focused window
+bindsym $mod+Shift+q kill
+
+# start dmenu (a program launcher)
+bindsym $mod+d exec dmenu_run
+# There also is the (new) i3-dmenu-desktop which only displays applications
+# shipping a .desktop file. It is a wrapper around dmenu, so you need that
+# installed.
+# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
+
+# change focus
+bindsym $mod+j focus left
+bindsym $mod+k focus down
+bindsym $mod+l focus up
+bindsym $mod+semicolon focus right
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+Left focus left
+bindsym $mod+Down focus down
+bindsym $mod+Up focus up
+bindsym $mod+Right focus right
+
+# move focused window
+bindsym $mod+Shift+j move left
+bindsym $mod+Shift+k move down
+bindsym $mod+Shift+l move up
+bindsym $mod+Shift+semicolon move right
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+Shift+Left move left
+bindsym $mod+Shift+Down move down
+bindsym $mod+Shift+Up move up
+bindsym $mod+Shift+Right move right
+
+# split in horizontal orientation
+bindsym $mod+h split h
+
+# split in vertical orientation
+bindsym $mod+v split v
+
+# enter fullscreen mode for the focused container
+bindsym $mod+f fullscreen toggle
+
+# change container layout (stacked, tabbed, toggle split)
+bindsym $mod+s layout stacking
+bindsym $mod+w layout tabbed
+bindsym $mod+e layout toggle split
+
+# toggle tiling / floating
+bindsym $mod+Shift+space floating toggle
+
+# change focus between tiling / floating windows
+bindsym $mod+space focus mode_toggle
+
+# focus the parent container
+bindsym $mod+a focus parent
+
+# focus the child container
+#bindsym $mod+d focus child
+
+# switch to workspace
+bindsym $mod+1 workspace 1
+bindsym $mod+2 workspace 2
+bindsym $mod+3 workspace 3
+bindsym $mod+4 workspace 4
+bindsym $mod+5 workspace 5
+bindsym $mod+6 workspace 6
+bindsym $mod+7 workspace 7
+bindsym $mod+8 workspace 8
+bindsym $mod+9 workspace 9
+bindsym $mod+0 workspace 10
+
+# move focused container to workspace
+bindsym $mod+Shift+1 move container to workspace 1
+bindsym $mod+Shift+2 move container to workspace 2
+bindsym $mod+Shift+3 move container to workspace 3
+bindsym $mod+Shift+4 move container to workspace 4
+bindsym $mod+Shift+5 move container to workspace 5
+bindsym $mod+Shift+6 move container to workspace 6
+bindsym $mod+Shift+7 move container to workspace 7
+bindsym $mod+Shift+8 move container to workspace 8
+bindsym $mod+Shift+9 move container to workspace 9
+bindsym $mod+Shift+0 move container to workspace 10
+
+# reload the configuration file
+bindsym $mod+Shift+c reload
+# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
+bindsym $mod+Shift+r restart
+# exit i3 (logs you out of your X session)
+bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
+
+# resize window (you can also use the mouse for that)
+mode "resize" {
+ # These bindings trigger as soon as you enter the resize mode
+
+ # Pressing left will shrink the window’s width.
+ # Pressing right will grow the window’s width.
+ # Pressing up will shrink the window’s height.
+ # Pressing down will grow the window’s height.
+ bindsym j resize shrink width 10 px or 10 ppt
+ bindsym k resize grow height 10 px or 10 ppt
+ bindsym l resize shrink height 10 px or 10 ppt
+ bindsym semicolon resize grow width 10 px or 10 ppt
+
+ # same bindings, but for the arrow keys
+ bindsym Left resize shrink width 10 px or 10 ppt
+ bindsym Down resize grow height 10 px or 10 ppt
+ bindsym Up resize shrink height 10 px or 10 ppt
+ bindsym Right resize grow width 10 px or 10 ppt
+
+ # back to normal: Enter or Escape
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+}
+
+bindsym $mod+r mode "resize"
+
+# Start i3bar to display a workspace bar (plus the system information i3status
+# finds out, if available)
+bar {
+ status_command i3status
+ tray_output primary
+}
diff --git a/i3/i3config b/i3/i3config
new file mode 100644
index 0000000..f349060
--- /dev/null
+++ b/i3/i3config
@@ -0,0 +1,181 @@
+# This file has been auto-generated by i3-config-wizard(1).
+# It will not be overwritten, so edit it as you like.
+#
+# Should you change your keyboard layout some time, delete
+# this file and re-run i3-config-wizard(1).
+#
+
+# i3 config file (v4)
+#
+# Please see http://i3wm.org/docs/userguide.html for a complete reference!
+
+gaps inner 25
+gaps outer 10
+new_window none
+
+set $mod Mod4
+
+# Font for window titles. Will also be used by the bar unless a different font
+# is used in the bar {} block below.
+font pango:monospace 8
+
+# This font is widely installed, provides lots of unicode glyphs, right-to-left
+# text rendering and scalability on retina/hidpi displays (thanks to pango).
+#font pango:DejaVu Sans Mono 8
+
+# Before i3 v4.8, we used to recommend this one as the default:
+# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+# The font above is very space-efficient, that is, it looks good, sharp and
+# clear in small sizes. However, its unicode glyph coverage is limited, the old
+# X core fonts rendering does not support right-to-left and this being a bitmap
+# font, it doesn’t scale on retina/hidpi displays.
+
+# Use Mouse+$mod to drag floating windows to their wanted position
+floating_modifier $mod
+
+# start a terminal
+#bindsym $mod+Return exec i3-sensible-terminal
+bindsym $mod+Return exec urxvt
+
+# kill focused window
+bindsym $mod+Shift+q kill
+
+# "Minimize windows"
+bindsym $mod+Shift+minus move scratchpad
+bindsym $mod+minus scratchpad show
+
+# start dmenu (a program launcher)
+#bindsym $mod+d exec dmenu_run
+# There also is the (new) i3-dmenu-desktop which only displays applications
+# shipping a .desktop file. It is a wrapper around dmenu, so you need that
+# installed.
+# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
+
+# change focus
+bindsym $mod+j focus left
+bindsym $mod+k focus down
+bindsym $mod+l focus up
+bindsym $mod+semicolon focus right
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+Left focus left
+bindsym $mod+Down focus down
+bindsym $mod+Up focus up
+bindsym $mod+Right focus right
+
+# move focused window
+bindsym $mod+Shift+j move left
+bindsym $mod+Shift+k move down
+bindsym $mod+Shift+l move up
+bindsym $mod+Shift+semicolon move right
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+Shift+Left move left
+bindsym $mod+Shift+Down move down
+bindsym $mod+Shift+Up move up
+bindsym $mod+Shift+Right move right
+
+# split in horizontal orientation
+bindsym $mod+h split h
+
+# split in vertical orientation
+bindsym $mod+v split v
+
+# enter fullscreen mode for the focused container
+bindsym $mod+f fullscreen toggle
+
+# change container layout (stacked, tabbed, toggle split)
+bindsym $mod+s layout stacking
+bindsym $mod+w layout tabbed
+bindsym $mod+e layout toggle split
+
+# toggle tiling / floating
+bindsym $mod+Shift+space floating toggle
+
+# change focus between tiling / floating windows
+bindsym $mod+space focus mode_toggle
+
+# focus the parent container
+bindsym $mod+a focus parent
+
+# focus the child container
+#bindsym $mod+d focus child
+
+workspace 1 output DisplayPort-0
+workspace 2 output DisplayPort-0
+workspace 3 output DisplayPort-0
+workspace 4 output DisplayPort-2
+workspace 5 output DisplayPort-2
+workspace 6 output DisplayPort-2
+workspace 7 output DisplayPort-3
+workspace 8 output DisplayPort-3
+workspace 9 output DisplayPort-3
+
+# switch to workspace
+bindsym $mod+1 workspace 1
+bindsym $mod+2 workspace 2
+bindsym $mod+3 workspace 3
+bindsym $mod+4 workspace 4
+bindsym $mod+5 workspace 5
+bindsym $mod+6 workspace 6
+bindsym $mod+7 workspace 7
+bindsym $mod+8 workspace 8
+bindsym $mod+9 workspace 9
+bindsym $mod+0 workspace 10
+
+# move focused container to workspace
+bindsym $mod+Shift+1 move container to workspace 1
+bindsym $mod+Shift+2 move container to workspace 2
+bindsym $mod+Shift+3 move container to workspace 3
+bindsym $mod+Shift+4 move container to workspace 4
+bindsym $mod+Shift+5 move container to workspace 5
+bindsym $mod+Shift+6 move container to workspace 6
+bindsym $mod+Shift+7 move container to workspace 7
+bindsym $mod+Shift+8 move container to workspace 8
+bindsym $mod+Shift+9 move container to workspace 9
+bindsym $mod+Shift+0 move container to workspace 10
+
+# reload the configuration file
+bindsym $mod+Shift+c reload
+# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
+bindsym $mod+Shift+r restart
+# exit i3 (logs you out of your X session)
+bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
+
+# resize window (you can also use the mouse for that)
+mode "resize" {
+ # These bindings trigger as soon as you enter the resize mode
+
+ # Pressing left will shrink the window’s width.
+ # Pressing right will grow the window’s width.
+ # Pressing up will shrink the window’s height.
+ # Pressing down will grow the window’s height.
+ bindsym j resize shrink width 10 px or 10 ppt
+ bindsym k resize grow height 10 px or 10 ppt
+ bindsym l resize shrink height 10 px or 10 ppt
+ bindsym semicolon resize grow width 10 px or 10 ppt
+
+ # same bindings, but for the arrow keys
+ bindsym Left resize shrink width 10 px or 10 ppt
+ bindsym Down resize grow height 10 px or 10 ppt
+ bindsym Up resize shrink height 10 px or 10 ppt
+ bindsym Right resize grow width 10 px or 10 ppt
+
+ # back to normal: Enter or Escape
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+}
+
+bindsym $mod+r mode "resize"
+
+# Start i3bar to display a workspace bar (plus the system information i3status
+# finds out, if available)
+bar {
+ output DisplayPort-2
+ status_command i3status
+ #status_command exec /home/swatson/.config/i3/scripts/bar.sh
+ colors {
+ background #001014
+ statusline #1da049
+ }
+}
diff --git a/i3/i3laptop b/i3/i3laptop
new file mode 100644
index 0000000..aace499
--- /dev/null
+++ b/i3/i3laptop
@@ -0,0 +1,177 @@
+# This file has been auto-generated by i3-config-wizard(1).
+# It will not be overwritten, so edit it as you like.
+#
+# Should you change your keyboard layout some time, delete
+# this file and re-run i3-config-wizard(1).
+#
+
+# i3 config file (v4)
+#
+# Please see http://i3wm.org/docs/userguide.html for a complete reference!
+
+gaps inner 25
+gaps outer 10
+new_window none
+
+set $mod Mod4
+
+bindsym XF86AudioRaiseVolume exec "amixer -q set Master 2dB+ unmute; notify-send 'Volume Up'"
+bindsym XF86AudioLowerVolume exec "amixer -q set Master 2dB- unmute; notify-send 'Volume Down'"
+bindsym XF86AudioMute exec "amixer -q set Master toggle; amixer -q set Speaker toggle"
+
+bindsym XF86MonBrightnessUp exec "light -A 10; notify-send 'Brightness Up'"
+bindsym XF86MonBrightnessDown exec "light -U 10; notify-send 'Brightness Down'"
+
+# Font for window titles. Will also be used by the bar unless a different font
+# is used in the bar {} block below.
+font pango:monospace 8
+
+# This font is widely installed, provides lots of unicode glyphs, right-to-left
+# text rendering and scalability on retina/hidpi displays (thanks to pango).
+#font pango:DejaVu Sans Mono 8
+
+# Before i3 v4.8, we used to recommend this one as the default:
+# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
+# The font above is very space-efficient, that is, it looks good, sharp and
+# clear in small sizes. However, its unicode glyph coverage is limited, the old
+# X core fonts rendering does not support right-to-left and this being a bitmap
+# font, it doesn’t scale on retina/hidpi displays.
+
+# Use Mouse+$mod to drag floating windows to their wanted position
+floating_modifier $mod
+
+# start a terminal
+#bindsym $mod+Return exec i3-sensible-terminal
+bindsym $mod+Return exec urxvt
+
+# kill focused window
+bindsym $mod+Shift+q kill
+
+# "Minimize windows"
+bindsym $mod+Shift+minus move scratchpad
+bindsym $mod+minus scratchpad show
+
+# start dmenu (a program launcher)
+#bindsym $mod+d exec dmenu_run
+# There also is the (new) i3-dmenu-desktop which only displays applications
+# shipping a .desktop file. It is a wrapper around dmenu, so you need that
+# installed.
+# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
+
+# change focus
+bindsym $mod+j focus left
+bindsym $mod+k focus down
+bindsym $mod+l focus up
+bindsym $mod+semicolon focus right
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+Left focus left
+bindsym $mod+Down focus down
+bindsym $mod+Up focus up
+bindsym $mod+Right focus right
+
+# move focused window
+bindsym $mod+Shift+j move left
+bindsym $mod+Shift+k move down
+bindsym $mod+Shift+l move up
+bindsym $mod+Shift+semicolon move right
+
+# alternatively, you can use the cursor keys:
+bindsym $mod+Shift+Left move left
+bindsym $mod+Shift+Down move down
+bindsym $mod+Shift+Up move up
+bindsym $mod+Shift+Right move right
+
+# split in horizontal orientation
+bindsym $mod+h split h
+
+# split in vertical orientation
+bindsym $mod+v split v
+
+# enter fullscreen mode for the focused container
+bindsym $mod+f fullscreen toggle
+
+# change container layout (stacked, tabbed, toggle split)
+bindsym $mod+s layout stacking
+bindsym $mod+w layout tabbed
+bindsym $mod+e layout toggle split
+
+# toggle tiling / floating
+bindsym $mod+Shift+space floating toggle
+
+# change focus between tiling / floating windows
+bindsym $mod+space focus mode_toggle
+
+# focus the parent container
+bindsym $mod+a focus parent
+
+# focus the child container
+#bindsym $mod+d focus child
+
+# switch to workspace
+bindsym $mod+1 workspace 1
+bindsym $mod+2 workspace 2
+bindsym $mod+3 workspace 3
+bindsym $mod+4 workspace 4
+bindsym $mod+5 workspace 5
+bindsym $mod+6 workspace 6
+bindsym $mod+7 workspace 7
+bindsym $mod+8 workspace 8
+bindsym $mod+9 workspace 9
+bindsym $mod+0 workspace 10
+
+# move focused container to workspace
+bindsym $mod+Shift+1 move container to workspace 1
+bindsym $mod+Shift+2 move container to workspace 2
+bindsym $mod+Shift+3 move container to workspace 3
+bindsym $mod+Shift+4 move container to workspace 4
+bindsym $mod+Shift+5 move container to workspace 5
+bindsym $mod+Shift+6 move container to workspace 6
+bindsym $mod+Shift+7 move container to workspace 7
+bindsym $mod+Shift+8 move container to workspace 8
+bindsym $mod+Shift+9 move container to workspace 9
+bindsym $mod+Shift+0 move container to workspace 10
+
+# reload the configuration file
+bindsym $mod+Shift+c reload
+# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
+bindsym $mod+Shift+r restart
+# exit i3 (logs you out of your X session)
+bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
+
+# resize window (you can also use the mouse for that)
+mode "resize" {
+ # These bindings trigger as soon as you enter the resize mode
+
+ # Pressing left will shrink the window’s width.
+ # Pressing right will grow the window’s width.
+ # Pressing up will shrink the window’s height.
+ # Pressing down will grow the window’s height.
+ bindsym j resize shrink width 10 px or 10 ppt
+ bindsym k resize grow height 10 px or 10 ppt
+ bindsym l resize shrink height 10 px or 10 ppt
+ bindsym semicolon resize grow width 10 px or 10 ppt
+
+ # same bindings, but for the arrow keys
+ bindsym Left resize shrink width 10 px or 10 ppt
+ bindsym Down resize grow height 10 px or 10 ppt
+ bindsym Up resize shrink height 10 px or 10 ppt
+ bindsym Right resize grow width 10 px or 10 ppt
+
+ # back to normal: Enter or Escape
+ bindsym Return mode "default"
+ bindsym Escape mode "default"
+}
+
+bindsym $mod+r mode "resize"
+
+# Start i3bar to display a workspace bar (plus the system information i3status
+# finds out, if available)
+bar {
+ status_command i3status
+ #status_command exec /home/swatson/.config/i3/scripts/bar.sh
+ colors {
+ background #001014
+ statusline #1da049
+ }
+}
diff --git a/i3/i3status/checkExpress.sh b/i3/i3status/checkExpress.sh
new file mode 100755
index 0000000..a6eb0a3
--- /dev/null
+++ b/i3/i3status/checkExpress.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+expressValue=$(expressvpn status | grep Connected 2>&1 > /dev/null; echo $?)
+
+if [[ "$expressValue" -ne 0 ]]; then
+ echo "ExpressVPN not connected"
+elif [[ "$expressValue" -eq 0 ]]; then
+ echo "ExpressVPN connected"
+else
+ echo "Could not determine ExpressVPN status"
+fi
diff --git a/i3/i3status/config b/i3/i3status/config
new file mode 100644
index 0000000..48ab9c0
--- /dev/null
+++ b/i3/i3status/config
@@ -0,0 +1,77 @@
+# i3status configuration file.
+# see "man i3status" for documentation.
+
+# It is important that this file is edited as UTF-8.
+# The following line should contain a sharp s:
+# ß
+# If the above line is not correctly displayed, fix your editor first!
+
+general {
+ colors = true
+ color_good = "#a8c2ed"
+ color_bad = "#a56d82"
+ color_degraded = "#c17d97"
+ interval = 5
+}
+
+order += "disk /"
+order += "wireless _first_"
+order += "ethernet _first_"
+order += "battery 0"
+order += "load"
+order += "volume master"
+order += "cpu_temperature 0"
+order += "tztime local"
+
+volume master {
+ format = " ♪: %volume "
+ device = "default"
+ mixer = "Master"
+ mixer_idx = 0
+}
+
+wireless _first_ {
+ format_up = " W: (%quality at %essid) %ip "
+ format_down = " W: down "
+}
+
+ethernet _first_ {
+ # if you use %speed, i3status requires root privileges
+ format_up = " E: %ip (%speed) "
+ format_down = "E Down"
+}
+
+battery 0 {
+ format = " %status %percentage %remaining "
+ format_down = " No battery "
+ status_chr = " ⚡ CHR "
+ status_bat = "BAT "
+ status_full = " ☻ FULL "
+ path = "/sys/class/power_supply/BAT%d/uevent"
+ low_threshold = 10
+}
+
+run_watch DHCP {
+ pidfile = "/var/run/dhclient*.pid"
+}
+
+run_watch VPNC {
+ pidfile = "/var/run/vpnc/pid"
+}
+
+tztime local {
+ format = " %Y-%m-%d %H:%M:%S "
+}
+
+load {
+ format = " %1min "
+}
+
+disk "/" {
+ format = "Free / : %avail "
+}
+
+cpu_temperature 0 {
+ format = " %degrees °C "
+ path = "/sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input"
+}
diff --git a/i3/i3status/config.rafi b/i3/i3status/config.rafi
new file mode 100644
index 0000000..46a8ed3
--- /dev/null
+++ b/i3/i3status/config.rafi
@@ -0,0 +1,91 @@
+# github.com/rafi i3status config
+
+# i3status configuration file
+# see "man i3status" for documentation.
+
+# It is important that this file is edited as UTF-8.
+# The following line should contain a sharp s:
+# ß
+# If the above line is not correctly displayed, fix your editor first!
+
+general {
+ colors = true
+ color_good = "#BBBBBB"
+ color_bad = "#CC1616"
+ color_degraded = "#55858E"
+ interval = 2
+}
+
+order += "volume master"
+order += "load"
+order += "cpu_usage"
+order += "disk /"
+order += "disk /media/media"
+order += "ethernet eth0"
+order += "tztime local"
+#order += "ipv6"
+#order += "run_watch DHCP"
+#order += "run_watch VPN"
+#order += "wireless wlan0"
+
+volume master {
+# format = " ♪: %volume "
+ device = "default"
+ mixer = "Master"
+ mixer_idx = 0
+ # termsyn font
+ format = "À %volume "
+}
+
+load {
+# format = " Δ: %1min "
+ # termsyn font
+ format = " Î %1min"
+}
+
+cpu_usage {
+ format = "%usage "
+}
+
+#cpu_temperature 0 {
+# format = " ± %degrees°"
+# path = "/sys/devices/platform/coretemp.0/temp2_input"
+# max_threshold = 95
+#}
+
+disk "/" {
+ format = " ¨ %avail:/ "
+}
+
+disk "/media/media" {
+ format = " ¨ %avail:m "
+}
+
+wireless wlan0 {
+ format_up = " W: (%quality at %essid) %ip "
+ format_down = " ☡ WiFi "
+}
+
+ethernet eth0 {
+ # if you use %speed, i3status requires root privileges
+# format_up = " Ω: %ip "
+# format_down = " ∅ eth0 "
+
+ # termsyn font
+ format_up = " %ip "
+ format_down = " Ð eth0 "
+}
+
+run_watch DHCP {
+ pidfile = "/var/run/dhclient*.pid"
+}
+
+run_watch VPN {
+ pidfile = "/var/run/vpnc/pid"
+}
+
+tztime local {
+# format = " %h-%d %H:%M ☰ "
+ # termsyn font
+ format = " %h-%d É %H:%M ¸ ÈÈÈ È "
+}
diff --git a/i3/i3status/i3status b/i3/i3status/i3status
new file mode 100644
index 0000000..d4a618e
--- /dev/null
+++ b/i3/i3status/i3status
@@ -0,0 +1,77 @@
+# i3status configuration file.
+# see "man i3status" for documentation.
+
+# It is important that this file is edited as UTF-8.
+# The following line should contain a sharp s:
+# ß
+# If the above line is not correctly displayed, fix your editor first!
+
+general {
+ colors = true
+ color_good = "#a8c2ed"
+ color_bad = "#a56d82"
+ color_degraded = "#c17d97"
+ interval = 5
+}
+
+order += "disk /"
+order += "wireless _first_"
+order += "ethernet _first_"
+order += "battery 0"
+order += "load"
+order += "volume master"
+order += "cpu_temperature 0"
+order += "tztime local"
+
+volume master {
+ format = " ♪: %volume "
+ device = "default"
+ mixer = "Master"
+ mixer_idx = 0
+}
+
+wireless _first_ {
+ format_up = " W: (%quality at %essid) %ip "
+ format_down = " W: down "
+}
+
+ethernet _first_ {
+ # if you use %speed, i3status requires root privileges
+ format_up = " E: %ip (%speed) "
+ format_down = " E: down "
+}
+
+battery 0 {
+ format = " %status %percentage %remaining "
+ format_down = " No battery "
+ status_chr = " ⚡ CHR "
+ status_bat = " BAT "
+ status_full = " ☻ FULL "
+ path = "/sys/class/power_supply/BAT%d/uevent"
+ low_threshold = 10
+}
+
+run_watch DHCP {
+ pidfile = "/var/run/dhclient*.pid"
+}
+
+run_watch VPN {
+ pidfile = "/var/run/vpnc/pid"
+}
+
+tztime local {
+ format = " %Y-%m-%d %H:%M:%S "
+}
+
+load {
+ format = " %1min "
+}
+
+disk "/" {
+ format = " %avail "
+}
+
+cpu_temperature 0 {
+ format = " %degrees °C "
+ path = "/sys/devices/platform/coretemp.0/hwmon/hwmon3/temp1_input"
+}
diff --git a/i3/i3status/statusCommand.sh b/i3/i3status/statusCommand.sh
new file mode 100755
index 0000000..2ead51f
--- /dev/null
+++ b/i3/i3status/statusCommand.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+/usr/bin/i3status | while :
+do
+ read line
+ expressVPN=`/home/swatson/.config/i3status/checkExpress.sh`
+ echo "$expressVPN | $line" || exit 1
+done
diff --git a/i3/lock.sh b/i3/lock.sh
new file mode 100755
index 0000000..1bdb50a
--- /dev/null
+++ b/i3/lock.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+scrot /tmp/screen.png
+convert /tmp/screen.png -scale 10% -scale 1000% /tmp/screen.png
+[[ -f $1 ]] && convert /tmp/screen.png $1 -gravity center -composite -matte /tmp/screen.png
+#dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop
+i3lock -u -i /tmp/screen.png
+rm /tmp/screen.png
diff --git a/irssi/config b/irssi/config
new file mode 100644
index 0000000..4d2573d
--- /dev/null
+++ b/irssi/config
@@ -0,0 +1,432 @@
+servers = (
+ {
+ address = "irc.ubuntu.com";
+ chatnet = "Ubuntu";
+ port = "6697";
+ use_tls = "yes";
+ tls_verify = "yes";
+ },
+ { address = "irc.dal.net"; chatnet = "DALnet"; port = "6667"; },
+ {
+ address = "ssl.efnet.org";
+ chatnet = "EFNet";
+ port = "9999";
+ use_tls = "yes";
+ },
+ {
+ address = "irc.esper.net";
+ chatnet = "EsperNet";
+ port = "6697";
+ use_tls = "yes";
+ tls_verify = "yes";
+ },
+ {
+ address = "chat.freenode.net";
+ chatnet = "Freenode";
+ port = "6697";
+ use_tls = "yes";
+ tls_verify = "yes";
+ autoconnect = "yes";
+ },
+ {
+ address = "irc.gamesurge.net";
+ chatnet = "GameSurge";
+ port = "6667";
+ },
+ {
+ address = "eu.irc6.net";
+ chatnet = "IRCnet";
+ port = "6667";
+ use_tls = "yes";
+ },
+ { address = "open.ircnet.net"; chatnet = "IRCnet"; port = "6667"; },
+ {
+ address = "irc.ircsource.net";
+ chatnet = "IRCSource";
+ port = "6667";
+ },
+ { address = "irc.netfuze.net"; chatnet = "NetFuze"; port = "6667"; },
+ {
+ address = "irc.oftc.net";
+ chatnet = "OFTC";
+ port = "6697";
+ use_tls = "yes";
+ tls_verify = "yes";
+ },
+ {
+ address = "irc.quakenet.org";
+ chatnet = "QuakeNet";
+ port = "6667";
+ },
+ {
+ address = "irc.rizon.net";
+ chatnet = "Rizon";
+ port = "6697";
+ use_tls = "yes";
+ tls_verify = "yes";
+ },
+ { address = "silc.silcnet.org"; chatnet = "SILC"; port = "706"; },
+ {
+ address = "irc.undernet.org";
+ chatnet = "Undernet";
+ port = "6667";
+ }
+);
+
+chatnets = {
+ Ubuntu = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "4";
+ max_whois = "1";
+ };
+ DALnet = {
+ type = "IRC";
+ max_kicks = "4";
+ max_msgs = "20";
+ max_whois = "30";
+ };
+ EFNet = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "4";
+ max_whois = "1";
+ };
+ EsperNet = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "4";
+ max_whois = "1";
+ };
+ Freenode = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "4";
+ max_whois = "1";
+ sasl_mechanism = "PLAIN";
+ sasl_username = "REDACTED";
+ sasl_password = "REDACTED";
+ };
+ GameSurge = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "1";
+ max_whois = "1";
+ };
+ IRCnet = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "1";
+ max_whois = "1";
+ };
+ IRCSource = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "4";
+ max_whois = "1";
+ };
+ NetFuze = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "1";
+ max_whois = "1";
+ };
+ OFTC = { type = "IRC"; max_kicks = "1"; max_msgs = "1"; max_whois = "1"; };
+ QuakeNet = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "1";
+ max_whois = "1";
+ };
+ Rizon = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "1";
+ max_whois = "1";
+ };
+ SILC = { type = "SILC"; };
+ Undernet = {
+ type = "IRC";
+ max_kicks = "1";
+ max_msgs = "1";
+ max_whois = "1";
+ };
+};
+
+channels = (
+ { name = "#lobby"; chatnet = "EsperNet"; autojoin = "No"; },
+ { name = "#freenode"; chatnet = "Freenode"; autojoin = "No"; },
+ { name = "#irssi"; chatnet = "Freenode"; autojoin = "No"; },
+ { name = "#gamesurge"; chatnet = "GameSurge"; autojoin = "No"; },
+ { name = "#irssi"; chatnet = "IRCNet"; autojoin = "No"; },
+ { name = "#ircsource"; chatnet = "IRCSource"; autojoin = "No"; },
+ { name = "#netfuze"; chatnet = "NetFuze"; autojoin = "No"; },
+ { name = "#oftc"; chatnet = "OFTC"; autojoin = "No"; },
+ { name = "silc"; chatnet = "SILC"; autojoin = "No"; }
+);
+
+aliases = {
+ ATAG = "WINDOW SERVER";
+ ADDALLCHANS = "SCRIPT EXEC foreach my \\$channel (Irssi::channels()) { Irssi::command(\"CHANNEL ADD -auto \\$channel->{name} \\$channel->{server}->{tag} \\$channel->{key}\")\\;}";
+ B = "BAN";
+ BACK = "AWAY";
+ BANS = "BAN";
+ BYE = "QUIT";
+ C = "CLEAR";
+ CALC = "EXEC - if command -v bc >/dev/null 2>&1\\; then printf '%s=' '$*'\\; echo '$*' | bc -l\\; else echo bc was not found\\; fi";
+ CHAT = "DCC CHAT";
+ CUBES = "SCRIPT EXEC Irssi::active_win->print(\"%_bases\", MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print( do { join '', map { \"%x0\\${_}0\\$_\" } '0'..'9','A'..'F' }, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print(\"%_cubes\", MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print( do { my \\$y = \\$_*6 \\; join '', map { my \\$x = \\$_ \\; map { \"%x\\$x\\$_\\$x\\$_\" } @{['0'..'9','A'..'Z']}[\\$y .. \\$y+5] } 1..6 }, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) for 0..5 \\; Irssi::active_win->print(\"%_grays\", MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print( do { join '', map { \"%x7\\${_}7\\$_\" } 'A'..'X' }, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) \\; Irssi::active_win->print(\"%_mIRC extended colours\", MSGLEVEL_CLIENTCRAP) \\; my \\$x \\; \\$x .= sprintf \"\00399,%02d%02d\",\\$_,\\$_ for 0..15 \\; Irssi::active_win->print(\\$x, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) \\; for my \\$z (0..6) { my \\$x \\; \\$x .= sprintf \"\00399,%02d%02d\",\\$_,\\$_ for 16+(\\$z*12)..16+(\\$z*12)+11 \\; Irssi::active_win->print(\\$x, MSGLEVEL_NEVER | MSGLEVEL_CLIENTCRAP) }";
+ DATE = "TIME";
+ DEHIGHLIGHT = "DEHILIGHT";
+ DESCRIBE = "ACTION";
+ DHL = "DEHILIGHT";
+ EXEMPTLIST = "MODE $C +e";
+ EXIT = "QUIT";
+ GOTO = "SCROLLBACK GOTO";
+ HIGHLIGHT = "HILIGHT";
+ HL = "HILIGHT";
+ HOST = "USERHOST";
+ INVITELIST = "MODE $C +I";
+ J = "JOIN";
+ K = "KICK";
+ KB = "KICKBAN";
+ KN = "KNOCKOUT";
+ LAST = "LASTLOG";
+ LEAVE = "PART";
+ M = "MSG";
+ MUB = "UNBAN *";
+ N = "NAMES";
+ NMSG = "^MSG";
+ P = "PART";
+ Q = "QUERY";
+ RESET = "SET -default";
+ RUN = "SCRIPT LOAD";
+ SAY = "MSG *";
+ SB = "SCROLLBACK";
+ SBAR = "STATUSBAR";
+ SIGNOFF = "QUIT";
+ SV = "MSG * Irssi $J ($V) - http://www.irssi.org";
+ T = "TOPIC";
+ UB = "UNBAN";
+ UMODE = "MODE $N";
+ UNSET = "SET -clear";
+ W = "WHO";
+ WC = "WINDOW CLOSE";
+ WG = "WINDOW GOTO";
+ WJOIN = "JOIN -window";
+ WI = "WHOIS";
+ WII = "WHOIS $0 $0";
+ WL = "WINDOW LIST";
+ WN = "WINDOW NEW HIDDEN";
+ WQUERY = "QUERY -window";
+ WW = "WHOWAS";
+ 1 = "WINDOW GOTO 1";
+ 2 = "WINDOW GOTO 2";
+ 3 = "WINDOW GOTO 3";
+ 4 = "WINDOW GOTO 4";
+ 5 = "WINDOW GOTO 5";
+ 6 = "WINDOW GOTO 6";
+ 7 = "WINDOW GOTO 7";
+ 8 = "WINDOW GOTO 8";
+ 9 = "WINDOW GOTO 9";
+ 10 = "WINDOW GOTO 10";
+ 11 = "WINDOW GOTO 11";
+ 12 = "WINDOW GOTO 12";
+ 13 = "WINDOW GOTO 13";
+ 14 = "WINDOW GOTO 14";
+ 15 = "WINDOW GOTO 15";
+ 16 = "WINDOW GOTO 16";
+ 17 = "WINDOW GOTO 17";
+ 18 = "WINDOW GOTO 18";
+ 19 = "WINDOW GOTO 19";
+ 20 = "WINDOW GOTO 20";
+ 21 = "WINDOW GOTO 21";
+ 22 = "WINDOW GOTO 22";
+ 23 = "WINDOW GOTO 23";
+ 24 = "WINDOW GOTO 24";
+ 25 = "WINDOW GOTO 25";
+ 26 = "WINDOW GOTO 26";
+ 27 = "WINDOW GOTO 27";
+ 28 = "WINDOW GOTO 28";
+ 29 = "WINDOW GOTO 29";
+ 30 = "WINDOW GOTO 30";
+ 31 = "WINDOW GOTO 31";
+ 32 = "WINDOW GOTO 32";
+ 33 = "WINDOW GOTO 33";
+ 34 = "WINDOW GOTO 34";
+ 35 = "WINDOW GOTO 35";
+ 36 = "WINDOW GOTO 36";
+ 37 = "WINDOW GOTO 37";
+ 38 = "WINDOW GOTO 38";
+ 39 = "WINDOW GOTO 39";
+ 40 = "WINDOW GOTO 40";
+ 41 = "WINDOW GOTO 41";
+ 42 = "WINDOW GOTO 42";
+ 43 = "WINDOW GOTO 43";
+ 44 = "WINDOW GOTO 44";
+ 45 = "WINDOW GOTO 45";
+ 46 = "WINDOW GOTO 46";
+ 47 = "WINDOW GOTO 47";
+ 48 = "WINDOW GOTO 48";
+ 49 = "WINDOW GOTO 49";
+ 50 = "WINDOW GOTO 50";
+ 51 = "WINDOW GOTO 51";
+ 52 = "WINDOW GOTO 52";
+ 53 = "WINDOW GOTO 53";
+ 54 = "WINDOW GOTO 54";
+ 55 = "WINDOW GOTO 55";
+ 56 = "WINDOW GOTO 56";
+ 57 = "WINDOW GOTO 57";
+ 58 = "WINDOW GOTO 58";
+ 59 = "WINDOW GOTO 59";
+ 60 = "WINDOW GOTO 60";
+ 61 = "WINDOW GOTO 61";
+ 62 = "WINDOW GOTO 62";
+ 63 = "WINDOW GOTO 63";
+ 64 = "WINDOW GOTO 64";
+ 65 = "WINDOW GOTO 65";
+ 66 = "WINDOW GOTO 66";
+ 67 = "WINDOW GOTO 67";
+ 68 = "WINDOW GOTO 68";
+ 69 = "WINDOW GOTO 69";
+ 70 = "WINDOW GOTO 70";
+ 71 = "WINDOW GOTO 71";
+ 72 = "WINDOW GOTO 72";
+ 73 = "WINDOW GOTO 73";
+ 74 = "WINDOW GOTO 74";
+ 75 = "WINDOW GOTO 75";
+ 76 = "WINDOW GOTO 76";
+ 77 = "WINDOW GOTO 77";
+ 78 = "WINDOW GOTO 78";
+ 79 = "WINDOW GOTO 79";
+ 80 = "WINDOW GOTO 80";
+ 81 = "WINDOW GOTO 81";
+ 82 = "WINDOW GOTO 82";
+ 83 = "WINDOW GOTO 83";
+ 84 = "WINDOW GOTO 84";
+ 85 = "WINDOW GOTO 85";
+ 86 = "WINDOW GOTO 86";
+ 87 = "WINDOW GOTO 87";
+ 88 = "WINDOW GOTO 88";
+ 89 = "WINDOW GOTO 89";
+ 90 = "WINDOW GOTO 90";
+ 91 = "WINDOW GOTO 91";
+ 92 = "WINDOW GOTO 92";
+ 93 = "WINDOW GOTO 93";
+ 94 = "WINDOW GOTO 94";
+ 95 = "WINDOW GOTO 95";
+ 96 = "WINDOW GOTO 96";
+ 97 = "WINDOW GOTO 97";
+ 98 = "WINDOW GOTO 98";
+ 99 = "WINDOW GOTO 99";
+};
+
+statusbar = {
+
+ items = {
+
+ barstart = "{sbstart}";
+ barend = "{sbend}";
+
+ topicbarstart = "{topicsbstart}";
+ topicbarend = "{topicsbend}";
+
+ time = "{sb $Z}";
+ user = "{sb {sbnickmode $cumode}$N{sbmode $usermode}{sbaway $A}}";
+
+ 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";
+
+ lag = "{sb Lag: $0-}";
+ act = "{sb Act: $0-}";
+ more = "-- more --";
+ };
+
+ default = {
+
+ window = {
+
+ disabled = "no";
+ type = "window";
+ placement = "bottom";
+ position = "1";
+ visible = "active";
+
+ items = {
+ barstart = { priority = "100"; };
+ time = { };
+ user = { };
+ window = { };
+ window_empty = { };
+ lag = { priority = "-1"; };
+ act = { priority = "10"; };
+ more = { priority = "-1"; alignment = "right"; };
+ barend = { priority = "100"; alignment = "right"; };
+ };
+ };
+
+ 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"; };
+ };
+ };
+
+ prompt = {
+
+ type = "root";
+ placement = "bottom";
+ position = "100";
+ visible = "always";
+
+ items = {
+ prompt = { priority = "-1"; };
+ prompt_empty = { priority = "-1"; };
+ input = { priority = "10"; };
+ };
+ };
+
+ topic = {
+
+ type = "root";
+ placement = "top";
+ position = "1";
+ visible = "always";
+
+ items = {
+ topicbarstart = { priority = "100"; };
+ topic = { };
+ topic_empty = { };
+ topicbarend = { priority = "100"; alignment = "right"; };
+ };
+ };
+ };
+};
+settings = {
+ core = {
+ real_name = "REDACTED";
+ user_name = "REDACTED";
+ nick = "REDACTED";
+ };
+ "fe-text" = { actlist_sort = "refnum"; };
+ "fe-common/core" = { theme = "default"; };
+};
+ignores = (
+ { level = "JOINS PARTS QUITS NICKS"; channels = ( "#suckless" ); },
+ { level = "JOINS PARTS QUITS NICKS"; channels = ( "#aptly" ); }
+);
diff --git a/irssi/default.theme b/irssi/default.theme
new file mode 100644
index 0000000..6b6aeab
--- /dev/null
+++ b/irssi/default.theme
@@ -0,0 +1,294 @@
+# 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. "ownnick" 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";
+};
diff --git a/irssi/elpi.theme b/irssi/elpi.theme
new file mode 100644
index 0000000..9aae356
--- /dev/null
+++ b/irssi/elpi.theme
@@ -0,0 +1,91 @@
+default_color = "-1";
+info_eol = "false";
+replaces = { "[]=" = "%p$*%n"; };
+abstracts = {
+ line_start = " %5%w %n ";
+ timestamp = "$*";
+ hilight = "%_$*%_";
+ error = "%R$*%n";
+ channel = "%_$*%_";
+ nick = "%_$*%_";
+ nickhost = "[$*]";
+ server = "%_$*%_";
+ comment = "[$*]";
+ reason = "{comment $*}";
+ mode = "{comment $*}";
+ channick_hilight = "%C$*%n";
+ chanhost_hilight = "{nickhost %c$*%n}";
+ channick = "%c$*%n";
+ chanhost = "{nickhost $*}";
+ channelhilight = "%c$*%n";
+ ban = "%c$*%n";
+ msgnick = "%c<%n$0$1-%c>%n %|";
+ ownmsgnick = "{msgnick $0 $1-}";
+ ownnick = "%U$*%n";
+ pubmsgnick = "{msgnick $0 $1-}";
+ pubnick = "%N$*%n";
+ pubmsgmenick = "{msgnick $0 $1-}";
+ menick = "%C$*%n";
+ pubmsghinick = "{msgnick $1 $0$2-%n}";
+ msgchannel = "%K:%c$*%n";
+ privmsg = "[%W$0%K(%w$1-%K)%n] ";
+ ownprivmsg = "[%C$0%K(%c$1-%K)%n] ";
+ ownprivmsgnick = "{msgnick $*}";
+ ownprivnick = "%W$*%n";
+ privmsgnick = "{msgnick %C$*%n}";
+ action_core = "%c* %n$*";
+ action = "{action_core $*} ";
+ ownaction = "{action %U$*%n}";
+ ownaction_target = "{action_core $0}%K:%c$1%n ";
+ pvtaction = "%W (*) $*%n ";
+ pvtaction_query = "{action $*}";
+ pubaction = "{action $*}";
+ ownnotice = "[%C$0%K(%c$1-%K)]%n ";
+ notice = "%K-%M$*%K-%n ";
+ pubnotice_channel = "%K:%m$*";
+ pvtnotice_host = "%K(%m$*%K)";
+ servernotice = "%P!$*%n ";
+ ownctcp = "[%r$0%K(%R$1-%K)] ";
+ ctcp = "%g$*%n";
+ wallop = "%W$*%n: ";
+ wallop_nick = "%n$*";
+ wallop_action = "%W * $*%n ";
+ netsplit = "%R$*%n";
+ netjoin = "%C$*%n";
+ 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 = "%g$*%n";
+ dccfile = "%_$*%_";
+ dccownmsg = "[%r$0%K($1-%K)%n] ";
+ dccownnick = "%R$*%n";
+ dccownquerynick = "%W$*%n";
+ dccownaction = "{action $*}";
+ dccownaction_target = "{action_core $0}%K:%c$1%n ";
+ dccmsg = "[%G$1-%K(%g$0%K)%n] ";
+ dccquerynick = "%G$*%n";
+ dccaction = "%W (*dcc*) $*%n %|";
+ sb_background = "%p";
+ sb_prompt_bg = "%p";
+ sb_info_bg = "%8";
+ sb_topic_bg = "%5";
+ sbstart = "%5 %n";
+ sbend = " ";
+ topicsbstart = "{sbstart $*}";
+ topicsbend = "{sbend $*}";
+ prompt = "$* ";
+ sb = "%c.%n$* ";
+ sbmode = "%c+%n$*";
+ sbaway = " %gzZzZ%n";
+ sbservertag = "%c:%n$0";
+ sbnickmode = "$0";
+ sb_act_sep = "%c$*";
+ sb_act_text = "%c$*";
+ sb_act_msg = "%w$*";
+ sb_act_hilight = "%W$*";
+ sb_act_hilight_color = "$0$1-%n";
+};
diff --git a/irssi/epic.theme b/irssi/epic.theme
new file mode 100644
index 0000000..39f2c59
--- /dev/null
+++ b/irssi/epic.theme
@@ -0,0 +1,304 @@
+# 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 = "*** ";
+
+ # 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 = "$*";
+
+ # 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 = "$*";
+ chanhost_hilight = "{nickhost $*}";
+
+ # nick/host is printed (parts, quits, etc.)
+ channick = "$*";
+ chanhost = "{nickhost $*}";
+
+ # highlighted channel name is printed
+ channelhilight = "$*";
+
+ # ban/ban exception/invite list mask is printed
+ ban = "$*";
+
+ ##
+ ## messages
+ ##
+
+ # the basic styling of how to print message, $0 = nick mode, $1 = nick
+ msgnick = "<$1> ";
+
+ # 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 = "%W$*%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 = "*$0* ";
+
+ # private message from you, $0 = "msg", $1 = target nick
+ ownprivmsg = "-> *$1* ";
+
+ # own private message in query
+ ownprivmsgnick = "-> *$1* ";
+ ownprivnick = "-> *$0* ";
+
+ # private message in query
+ privmsgnick = "*$0* ";
+
+ ##
+ ## Actions (/ME stuff)
+ ##
+
+ # used internally by this theme
+ action_core = "* $*";
+
+ # 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}:$1%n ";
+
+ # private action sent by others
+ pvtaction = "(*) $* ";
+ pvtaction_query = "{action $*}";
+
+ # public action sent by others
+ pubaction = "{action $*}";
+
+
+ ##
+ ## other IRC events
+ ##
+
+ # whois
+ whois = "%# $[8]0 : $1-";
+
+ # notices
+ ownnotice = "[$0($1-)] ";
+ notice = "-$*- ";
+ pubnotice_channel = ":$*";
+ pvtnotice_host = "";
+ servernotice = "!$* ";
+
+ # CTCPs
+ ownctcp = "[$0($1-)] ";
+ ctcp = "*** $*";
+
+ # wallops
+ wallop = "$*: ";
+ wallop_nick = "$*";
+ wallop_action = " * $*%n ";
+
+ # netsplits
+ netsplit = "$*";
+ netjoin = "$*";
+
+ # /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 = "[$*]";
+ names_channel = "$*";
+
+ # DCC
+ dcc = "$*";
+ dccfile = "$*";
+
+ # DCC chat, own msg/action
+ dccownmsg = "[$0($1-)] ";
+ dccownnick = "$*";
+ dccownquerynick = "$*";
+ dccownaction = "{action $*}";
+ dccownaction_target = "{action_core $0}:$1 ";
+
+ # DCC chat, others
+ dccmsg = "[$1-($0)] ";
+ dccquerynick = "%G$*%n";
+ dccaction = "%W (*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 = " [$*]";
+ sbmode = "(+$*)";
+ sbaway = " (zZzZ)";
+ sbservertag = ":$0 ";
+
+ # activity in statusbar
+
+ # ',' separator
+ sb_act_sep = "$*";
+ # normal text
+ sb_act_text = "$*";
+ # public message
+ sb_act_msg = "$*";
+ # hilight
+ sb_act_hilight = "$*";
+ # hilight with specified color, $0 = color, $1 = text
+ sb_act_hilight_color = "$0$1-%n";
+};
+formats = {
+ "fe-common/core" = {
+ timestamp = "{$Z}";
+ own_msg_private_query = "{ownprivnick $0}$1";
+ };
+ "fe-common/irc" = {
+ ctcp_reply = "{ctcp CTCP {hilight $0} reply from {nick $1}: $2 }";
+ ctcp_reply_channel = "{ctcp CTCP {hilight $0} reply from {nick $1} in channel {channel $3}: $2 }";
+ ctcp_ping_reply = "{ctcp CTCP {hilight PING} reply from {nick $0}: $1.$[-3.0]2 seconds }";
+ };
+};
diff --git a/irssi/ignore.txt b/irssi/ignore.txt
new file mode 100644
index 0000000..57a1699
--- /dev/null
+++ b/irssi/ignore.txt
@@ -0,0 +1 @@
+/IGNORE * JOINS PARTS QUITS
diff --git a/irssi/ksiadz.theme b/irssi/ksiadz.theme
new file mode 100644
index 0000000..bd02470
--- /dev/null
+++ b/irssi/ksiadz.theme
@@ -0,0 +1,81 @@
+############ksiadz-theme################
+
+default_color = "3";
+default_real_color = "15";
+replaces = { "[]<>=" = "%m$0-%c"; };
+abstracts = {
+ line_start = " %B(%c!%B)%n ";
+ timestamp = "%B(%c$0-%B)%n";
+ hilight = "%_$0-%_";
+ error = "%R$0-%n";
+ channel = "%G$0-%_";
+ nick = "%c$0-%n";
+ nickhost = "[%C$*-]";
+ server = "%B$0-%B";
+ comment = "[$0-]";
+ reason = "{comment $0-}";
+ mode = "{comment %B$0-}";
+ channick_hilight = "%G$0-%G";
+ chanhost_hilight = "{nickhost %G$0-%G}";
+ channick = "%C$0-%C";
+ chanhost = "{%Cnickhost $0-}";
+ channelhilight = "%c$0-%n";
+ ban = "%Y$0-%n";
+ msgnick = "%b<%C$0$1-%b>%n %|";
+ ownmsgnick = "{msgnick $0 $1-}";
+ ownnick = "%B$0-%B";
+ pubmsgnick = "{msgnick $0 $1-}";
+ pubnick = "%c$0-%n";
+ pubmsgmenick = "{msgnick $0 $1-}";
+ menick = "%F$0-%n";
+ pubmsghinick = "{msgnick $1 $0$2-%n}";
+ msgchannel = "%K:%c$0-%n";
+ privmsg = "%m(%B$0%K!%c$1-%m)%n ";
+ ownprivmsg = "[%c$0%K(%B$1-%K)%n] ";
+ ownprivmsgnick = "{msgnick $0-}";
+ ownprivnick = "%c$0-%n";
+ privmsgnick = "{msgnick $0-}";
+ action_core = "%B * %C$0-%n";
+ action = "{action_core $0-} ";
+ ownaction = "{action $0-}";
+ ownaction_target = "{action_core $0}%K:%c$1%n ";
+ pvtaction = "%W (*) $0-%n ";
+ pvtaction_query = "{action $0-}";
+ pubaction = "{action $0-}";
+ ownnotice = "[%r$0%K(%R$1-%K)]%n ";
+ notice = "%K-%M$0-%K-%n ";
+ pubnotice_channel = "%K:%m$0-";
+ pvtnotice_host = "%K(%m$0-%K)";
+ servernotice = "%g!$0-%n ";
+ ownctcp = "[%r$0%K(%R$1-%K)] ";
+ ctcp = "%B$0-%B";
+ wallop = "%W$0-%n: ";
+ wallop_nick = "%n$0-";
+ wallop_action = "%W * $0-%n ";
+ netsplit = "%R$0-%n";
+ netjoin = "%Y$0-%n";
+ names_nick = "[%B$0%C$1-] ";
+ names_users = "[%g$0-%n]";
+ names_channel = "%G$0-%n";
+ dcc = "%g$0-%n";
+ dccfile = "%_$0-%_";
+ dccownmsg = "[%r$0%K($1-%K)%n] ";
+ dccownnick = "%R$0-%n";
+ dccownaction = "{action $0-}";
+ dccownaction_target = "{action_core $0}%K:%c$1%n ";
+ dccmsg = "[%G$1-%K(%g$0%K)%n] ";
+ dccquerynick = "%G$0-%n";
+ dccaction = "%W (*dcc*) $0-%n %|";
+ sb_background = "%4";
+ sb = "%m[%n$0-%m]%n";
+ sbmode = "%m(%c+%n$0-%m)%n";
+ sbaway = " %m(%CzZzZ%n%m)%n";
+ sbservertag = "%c:%n$0 (change with ^X)";
+ sbmore = "%_-- more --%_";
+ sblag = "{sb Lag: $0-}";
+ sbmail = "{sb Mail: $0-}";
+ sbact = "{sb {sbact_act $0}{sbact_det $1}}";
+ sbact_act = "Act: $0-";
+ sbact_det = " Det: $0-";
+
+};
diff --git a/irssi/scripts/adv_windowlist.pl b/irssi/scripts/adv_windowlist.pl
new file mode 100644
index 0000000..e652ae7
--- /dev/null
+++ b/irssi/scripts/adv_windowlist.pl
@@ -0,0 +1,2879 @@
+use strict;
+use warnings;
+
+our $VERSION = '1.8'; # 63feb35d8b0a8b6
+our %IRSSI = (
+ authors => 'Nei',
+ contact => 'Nei @ anti@conference.jabber.teamidiot.de',
+ url => "http://anti.teamidiot.de/",
+ name => 'adv_windowlist',
+ description => 'Adds a permanent advanced window list on the right or in a status bar.',
+ sbitems => 'awl_shared',
+ 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>
+# * 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>
+# * string : Format String for window names
+# $0 : name as formatted by the settings
+#
+# /format awl_display_header <string>
+# * string : Format String for this header line. The following $'s are expanded:
+# $C : network tag
+#
+# /format awl_separator(2) <string>
+# * 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_abbrev_chars <string>
+# * string : Character to use when shortening long names. The second character
+# will be used if two blocks need to be filled.
+#
+# /format awl_title <string>
+# * string : Text to display in the title string or title bar
+#
+# /format awl_viewer_item_bg <string>
+# * string : Format String specifying the viewer's item background colour
+#
+# /set awl_prefer_name <ON|OFF>
+# * 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 <num>
+# * 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_detach <list>
+# * list of windows that should be hidden from the window list. you
+# can also use /awl detach and /awl attach to manage this
+# setting. an optional data_level can be specified with ",num"
+#
+# /set awl_detach_data <num>
+# * num : hide the detached window if its data_level is below num
+#
+# /set awl_detach_aht <ON|OFF>
+# * if enabled, also detach all windows listed in the
+# activity_hide_targets setting
+#
+# /set awl_hide_data <num>
+# * 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>
+# * 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>
+# * num : number of lines to use for the window list (0 to disable, negative
+# lock)
+#
+# /set awl_maxcolumns <num>
+# * num : number of columns to use for the window list when using the
+# tmux integration (0 to disable)
+#
+# /set awl_block <num>
+# * 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 <ON|OFF>
+# * 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>
+# * 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
+# lru : sort windows with the last recently used last
+# "-" 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)
+# to make sort case insensitive, use #i, e.g. name#i
+# 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 <top|bottom>
+# /set awl_position <num>
+# * these settings correspond to /statusbar because awl will create
+# status bars for you
+# (see /help statusbar to learn more)
+#
+# /set awl_all_disable <ON|OFF>
+# * 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 <ON|OFF>
+# * enable the external viewer script
+#
+# /set awl_viewer_launch <ON|OFF>
+# * try to auto-launch the viewer under tmux or with a shell command
+# /awl restart is required all auto-launch related settings to take
+# effect
+#
+# /set awl_viewer_tmux_position <left|top|right|bottom|custom>
+# * try to split in this direction when using tmux for the viewer
+# custom : use custom_command setting
+#
+# /set awl_viewer_xwin_command <shell command>
+# * custom command to run in order to start the viewer when irssi is
+# running under X
+# %A - gets replaced by the command to run the viewer
+# %qA - additionally quote the command
+#
+# /set awl_viewer_custom_command <shell command>
+# * custom command to run in order to start the viewer
+#
+# /set awl_viewer_launch_env <string>
+# * specific environment settings for use on viewer auto-launch,
+# without the AWL_ prefix
+#
+# /set awl_shared_sbar <left<right|OFF>
+# * 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
+# Note: you need to replace "left" AND "right" with the appropriate numbers!
+#
+# /set awl_path <path>
+# * path to the file which the viewer script reads
+#
+# /set fancy_abbrev <no|head|strict|fancy>
+# * 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 <perl code>
+# * specify a custom routine to transform window names
+# example: s/^#// remove the #-mark of IRC channels
+# the special flags $CHANNEL / $TAG / $QUERY / $NAME can be
+# tested in conditionals
+#
+# /set awl_last_line_shade <timeout>
+# * 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_no_mode_hint <ON|OFF>
+# * whether to show the hint of running the viewer script in the
+# status bar
+#
+# /set awl_mouse <ON|OFF>
+# * 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 <num>
+# * 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 <num>
+# * how many lines the mouse wheel scrolls
+#
+# /set mouse_escape <num>
+# * seconds to disable the mouse, when not clicked on the windowlist
+#
+
+# Commands
+# ========
+# /awl detach <num>
+# * hide the current window from the window list. num specifies the
+# data_level (optional)
+#
+# /awl attach
+# * unhide the current window from the window list
+#
+# /awl ack
+# * change to the next window with activity, ignoring detached windows
+#
+# /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.
+#
+# /awl restart
+# * restart the connection to the viewer script.
+
+# Viewer script
+# =============
+# When run from the command line, adv_windowlist acts as the viewer
+# script to be used together with the irssi script to display the
+# window list in a sidebar/terminal of its own.
+#
+# One optional parameter is accepted, the awl_path
+#
+# The viewer can be configured by three environment variables:
+#
+# AWL_HI9=1
+# * interpret %9 as high-intensity toggle instead of bold. This had
+# been the default prior to version 0.9b8
+#
+# AWL_AUTOFOCUS=0
+# * disable auto-focus behaviour when activating a window
+#
+# AWL_NOTITLE=1
+# * disable the title bar
+
+# Nei =^.^= ( anti@conference.jabber.teamidiot.de )
+
+no warnings 'redefine';
+use constant IN_IRSSI => __PACKAGE__ ne 'main' || $ENV{IRSSI_MOCK};
+use constant SCRIPT_FILE => __FILE__;
+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);
+use Text::ParseWords qw(shellwords);
+
+BEGIN {
+ if ($] < 5.012) {
+ *CORE::GLOBAL::length = *CORE::GLOBAL::length = sub (_) {
+ defined $_[0] ? CORE::length($_[0]) : undef
+ };
+ }
+ *Irssi::active_win = {}; # hide incorrect warning
+}
+
+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 = '1';
+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 %detach_map;
+my %abbrev_cache;
+
+use constant setc => 'awl';
+
+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 $title = _get_format(set 'title');
+ if (length $title) {
+ $title =~ s{\\(.)|(.)}{
+ defined $2 ? quotemeta $2
+ : $1 eq 'V' ? '\u'
+ : $1 eq ':' ? quotemeta ':%n'
+ : $1 =~ /^[uUFQE]$/ ? "\\$1"
+ : quotemeta "\\$1"
+ }sge;
+ $title = eval qq{"$title"};
+ $title .= ' ';
+ }
+ my $pat = defined $text ? "{sb $title\$*}" : '{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 _add_map {
+ my ($type, $target, $map) = @_;
+ ($type->{$target}) = sort { length $a <=> length $b || $a cmp $b }
+ $map, exists $type->{$target} ? $type->{$target} : ();
+}
+
+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) {
+ _add_map(\%nummap, $1, $map);
+ }
+ elsif (/^(?:command window goto|change_window) (\S+)/i) {
+ my $window = $1;
+ if ($window !~ /\D/) {
+ _add_map(\%nummap, $window, $map);
+ }
+ elsif (lc $window eq 'active') {
+ _add_map(\%specialmap, '_active', $map);
+ }
+ else {
+ _add_map(\%wnmap, $window, $map);
+ }
+ }
+ elsif (/^(?:active_window|command ((awl )?ack))/i) {
+ _add_map(\%specialmap, '_active', $map);
+ $viewer{use_ack} = $1;
+ }
+ elsif (/^command window last/i) {
+ _add_map(\%specialmap, '_last', $map);
+ }
+ elsif (/^(?:upper_window|command window up)/i) {
+ _add_map(\%specialmap, '_up', $map);
+ }
+ elsif (/^(?:lower_window|command window down)/i) {
+ _add_map(\%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';
+ if (Irssi->can('string_width')) {
+ *screen_length = sub { Irssi::string_width($_[0]) };
+ }
+ else {
+ 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;
+ my $name = __PACKAGE__ . '::custom_xform::' . $win->{active}{type}
+ if ref $win->{active} && $win->{active}{type};
+ no strict 'refs';
+ local ${$name} = 1 if $name;
+ remove_uniform(+shift);
+}
+
+sub lc1459 {
+ my $x = shift;
+ $x =~ y/][\\^/}{|~/;
+ lc $x
+}
+
+sub window_list {
+ my $i = 0;
+ map { $_->[1] } sort $window_sort_func map { [ $i++, $_ ] } 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 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 _get_format {
+ Irssi::current_theme->get_format(__PACKAGE__, @_)
+}
+
+sub _is_detached {
+ my ($win, $active_number) = @_;
+ my $level = $win->{data_level} // 0;
+ my $number = $win->{refnum};
+ my $name = lc1459( as_uni($win->{name}) );
+ my $active = lc1459( as_uni($win->get_active_name) // '' );
+ my $tag = $win->{active} && $win->{active}{server} ? lc1459( as_uni($win->{active}{server}{tag}) // '' ) : '';
+ my @cond = ($number);
+ push @cond, "$name" if length $name;
+ push @cond, "$tag/$active" if length $tag && length $active;
+ push @cond, "$active" if length $active;
+ push @cond, "$tag/*", "$tag/::all" if length $tag;
+ push @cond, "*", "::all";
+ for my $cond (@cond) {
+ if (exists $detach_map{ $cond }) {
+ my $dd = $detach_map{ $cond } // $S{detach_data};
+ return $win->{data_level} < abs $dd
+ && ($number != $active_number || 0 <= $dd);
+ }
+ }
+ return;
+}
+
+sub _calculate_items {
+ my ($wins, $abbrevList) = @_;
+
+ my $display_header = _get_format(set 'display_header');
+ my $name_format = _get_format(set 'name_display');
+ my $abbrev_chars = as_uni(_get_format(set 'abbrev_chars'));
+
+ 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;
+ my ($abbrev1, $abbrev2) = $abbrev_chars =~ /(\X)(.*)/;
+ my @abbrev_chars = ('~', "\x{301c}");
+ unless (defined $abbrev1 && screen_length(as_tc($abbrev1)) == 1) { $abbrev1 = $abbrev_chars[0] }
+ unless (length $abbrev2) {
+ $abbrev2 = $abbrev1;
+ if ($abbrev1 eq $abbrev_chars[0]) {
+ $abbrev2 = $abbrev_chars[1];
+ }
+ else {
+ $abbrev2 = $abbrev1;
+ }
+ }
+ if (screen_length(as_tc($abbrev2)) == 1) {
+ $abbrev2 x= 2;
+ }
+ while (screen_length(as_tc($abbrev2)) > 2) {
+ chop $abbrev2;
+ }
+ unless (screen_length(as_tc($abbrev2)) == 2) {
+ $abbrev2 = $abbrev_chars[1];
+ }
+ for my $win (@$wins) {
+ my $global_tag_header_mode;
+
+ next unless ref $win;
+
+ my $backup_win = Storable::dclone($win);
+ delete $backup_win->{active} unless ref $backup_win->{active};
+
+ $global_tag_header_mode =
+ $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; }
+ elsif (_is_detached($win, $active->{refnum})) {
+ 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_tag_header_mode) {
+ $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{$_} //= _get_format(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 '*';
+ if ($name ne '*' and $win->{name} ne '' and $S{prefer_name}) {
+ $name = as_uni($win->{name});
+ if ($custom_xform) {
+ no strict 'refs';
+ local ${ __PACKAGE__ . '::custom_xform::NAME' } = 1;
+ run_custom_xform() for $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 max(0,$numPad - length $number)) . $number;
+ my $key_ent = exists $keymap{$number} ? ((' 'x max(0,$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 >= 0 ? $middle2/2 : -1; # clearing position
+ my $rm = 2;
+ # if character at end is wider than 1 cell -> replace it with ~
+ if (screen_length(as_tc(substr $name, $cp, 1)) > 1) {
+ if ($first || $cp < 0) {
+ $rm = 1;
+ $first = undef;
+ }
+ }
+ elsif ($cp < 0) { # elsif at end -> replace last 2 characters
+ --$cp;
+ }
+ (substr $name, $cp, $rm) = $abbrev1;
+ 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) = $abbrev2;
+ 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_tag_header_mode) {
+ $last_net = $backup_win->{active}{server}{tag};
+ redo;
+ }
+
+ $mouse_coords{refnum}{$#win_items} = $number;
+ }
+}
+
+sub _spread_items {
+ my $width = $screenWidth - $sb_base_width - 1;
+ my @separator = _get_format(set 'separator');
+ if ($S{block} >= 0) {
+ my $sep2 = _get_format(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;
+ $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 restartViewerServer {
+ if ($VIEWER_MODE) {
+ stop_viewer();
+ start_viewer();
+ }
+}
+
+sub _simple_quote {
+ my @r = map {
+ my $x = $_;
+ $x =~ s/'/'"'"'/g;
+ $x = "'$x'";
+ } @_;
+ wantarray ? @r : shift @r
+}
+
+sub _viewer_command_replace_format {
+ my ($ecmd, @args) = @_;
+ my $file = _simple_quote(SCRIPT_FILE());
+ my $path = _simple_quote($viewer{path});
+ my @env;
+ for my $env (shellwords($S{viewer_launch_env})) {
+ if ($env =~ /^(\w+)(?:=(.*))$/) {
+ push @env, "AWL_$1=$2"
+ }
+ }
+ my $cmd = join ' ',
+ (@env ? ('env', _simple_quote(@env)) : ()),
+ 'perl', $file, '-1', _simple_quote(@args), $path;
+ $ecmd =~ s{%(%|\w+)}{
+ my $sub = $1;
+ if ($sub eq '%') {
+ '%'
+ }
+ elsif ($sub =~ /^(q*)A(.*)/) {
+ my $ret = $cmd;
+ for (1..length $1) {
+ $ret = _simple_quote($ret);
+ }
+ "$ret$2"
+ }
+ else {
+ "%$sub"
+ }
+ }gex;
+ $ecmd
+}
+
+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: $!";
+ $viewer{retry} = Irssi::timeout_add_once(5000, 'retry_viewer', 1);
+ return;
+ }
+ $viewer{server}->blocking(0);
+ set_viewer_mode_hint();
+ $viewer{server_tag} = Irssi::input_add($viewer{server}->fileno, INPUT_READ, 'vi_connected', undef);
+
+ if ($S{viewer_launch}) {
+ if (length $ENV{TMUX_PANE} && length $ENV{TMUX} && lc $S{viewer_tmux_position} ne 'custom') {
+ my $cmd = _viewer_command_replace_format('%qA', '-p', lc $S{viewer_tmux_position});
+ Irssi::command("exec - tmux neww -d $cmd 2>&1 &");
+ }
+ elsif (length $ENV{WINDOWID} && length $ENV{DISPLAY} && length $S{viewer_xwin_command} && $S{viewer_xwin_command} =~ /\S/) {
+ my $cmd = _viewer_command_replace_format($S{viewer_xwin_command});
+ Irssi::command("exec - $cmd 2>&1 &");
+ }
+ elsif (length $S{viewer_custom_command} && $S{viewer_custom_command} =~ /\S/) {
+ my $cmd = _viewer_command_replace_format($S{viewer_custom_command});
+ Irssi::command("exec - $cmd 2>&1 &");
+ }
+ }
+}
+
+sub set_viewer_mode_hint {
+ return unless $viewer{server};
+ if ($S{no_mode_hint}) {
+ $viewer{msg} = undef;
+ }
+ else {
+ my ($name) = __PACKAGE__ =~ /::([^:]+)$/;
+ $viewer{msg} = "Run $name from the shell or switch to sbar mode";
+ }
+}
+
+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($viewer{use_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},
+ mc => $S{maxcolumns},
+ ml => $S{maxlines},
+ );
+ $viewer{client_settings} = 1;
+ }
+ unless ($viewer{client_env}) {
+ $str .= _encode_var(irssienv => +{
+ length $ENV{TMUX_PANE} && length $ENV{TMUX} ?
+ (tmux_pane => $ENV{TMUX_PANE},
+ tmux_srv => $ENV{TMUX}) : (),
+ length $ENV{WINDOWID} ?
+ (xwinid => $ENV{WINDOWID}) : (),
+ });
+ $viewer{client_env} = 1;
+ }
+ my $separator = _get_format(set 'separator');
+ my $sepLen = sb_length($separator);
+ my $item_bg = _get_format(set 'viewer_item_bg');
+ my $title = _get_format(set 'title');
+ if (length $title) {
+ $title =~ s{\\(.)|(.)}{
+ defined $2 ? quotemeta $2
+ : $1 eq 'V' ? '\U'
+ : $1 eq ':' ? quotemeta '%N'
+ : $1 =~ /^[uUFQE]$/ ? "\\$1"
+ : quotemeta "\\$1"
+ }sge;
+ $title = eval qq{"$title"};
+ }
+ $str .= _encode_var(redraw => 1) if delete $viewer{fullRedraw};
+ $str .= _encode_var(separator => $separator,
+ seplen => $sepLen,
+ itembg => $item_bg,
+ title => $title,
+ 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}) {
+ if (defined $viewer{msg}) {
+ @actString = ((uc setc()).": $viewer{msg}");
+ }
+ else {
+ @actString = ();
+ }
+ }
+ elsif (defined $viewer{msg}) {
+ @actString = ((uc setc()).": $viewer{msg}");
+ }
+ if (@actString) {
+ Irssi::timeout_add_once(100, 'syncLines', undef);
+ }
+ elsif ($currentLines) {
+ killOldStatus();
+ $currentLines = 0;
+ }
+}
+
+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};
+ my $was_no_hint = $S{no_mode_hint};
+ %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'),
+ detach => Irssi::settings_get_str( set 'detach'),
+ detach_data => Irssi::settings_get_int( set 'detach_data'),
+ detach_aht => Irssi::settings_get_bool(set 'detach_aht'),
+ 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'),
+ maxcolumns => Irssi::settings_get_int( set 'maxcolumns'),
+ 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'),
+ no_mode_hint => Irssi::settings_get_bool(set 'no_mode_hint'),
+ viewer_launch => Irssi::settings_get_bool(set 'viewer_launch'),
+ viewer_launch_env => Irssi::settings_get_str(set 'viewer_launch_env'),
+ viewer_xwin_command => Irssi::settings_get_str(set 'viewer_xwin_command'),
+ viewer_custom_command => Irssi::settings_get_str(set 'viewer_custom_command'),
+ viewer_tmux_position => Irssi::settings_get_str(set 'viewer_tmux_position'),
+ );
+ $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*$//;
+ my $ignore_case = s/#i$// ? 1 : undef;
+
+ $print_text_activity = 1 if $_ eq 'last_line';
+
+ my @path = split '/';
+ my $class_check = @path && $path[-1] =~ s/(::.*)$// ? $1 : undef;
+ my $lru = "@path" eq 'lru';
+
+ [ $reverse ? -1 : 1, $undef_check, $equal_check, $class_check, $ignore_case, $lru, @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;
+ $_ = lc1459($_) if defined $_ && !ref $_ && $so->[4];
+ $ret = $_ eq ($so->[4] ? lc1459($so->[2]) : $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 {
+ $so->[5] ? $_->[0] : reduce { return unless ref $a; $a->{$b} } $_->[1], @{$so}[6..$#$so]
+ } $a, $b;
+ return ((($x[0] <=> $x[1] || $x[0] cmp $x[1]) * $so->[0]) || next);
+ }
+ return ($a->[1]{refnum} <=> $b->[1]{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, \$NAME);
+return sub {
+# line 1 @{[ set 'custom_xform' ]}\n$S{xform}\n}};
+ if ($@) {
+ $@ =~ /^(.*)/;
+ print '%_'.(set 'custom_xform').'%_ did not compile: '.$1;
+ }
+ }
+ }
+
+ my $new_settings = join "\n", $VIEWER_MODE
+ ? ("\\", $S{block}, $S{height_adjust}, $S{maxlines}, $S{maxcolumns})
+ : ("!", $S{placement}, $S{position});
+
+ my $first_viewer = $settings_str eq '1';
+ 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();
+ }
+
+ unless ($first_viewer) {
+ my $path = Irssi::settings_get_str(set 'path');
+ my $was_viewer_mode = $VIEWER_MODE;
+ if ($was_viewer_mode &&
+ defined $viewer{path} && $viewer{path} ne $path) {
+ stop_viewer();
+ $was_viewer_mode = 0;
+ }
+ elsif ($was_viewer_mode && $S{no_mode_hint} != $was_no_hint + 0) {
+ set_viewer_mode_hint();
+ }
+ $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(as_uni($_)) => undef }
+ split ' ', Irssi::settings_get_str('banned_channels');
+
+ %detach_map = ($S{detach_aht}
+ ? (map { ( lc1459(as_uni($_)) => undef ) }
+ split ' ', Irssi::settings_get_str('activity_hide_targets')) : (),
+ (map { my ($k, $v) = (split /(?:,(-?\d+))$/, $_)[0, 1];
+ ( lc1459(as_uni($k)) => $v ) }
+ split ' ', $S{detach}));
+
+ my @sb_base = split /\177/, sb_format_expand("{sbstart}{sb \177}{sbend}"), 2;
+ $sb_base_width_pre = sb_length($sb_base[0]);
+ $sb_base_width_post = max 0, sb_length($sb_base[1])-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 hide_window {
+ my ($data) = @_;
+ my $ent;
+
+ $data =~ s/\s*$//;
+ my $win = Irssi::active_win;
+ my $number = $win->{refnum};
+ my $name = as_uni($win->{name});
+ my $active = as_uni($win->get_active_name) // '';
+ my $tag = $win->{active} && $win->{active}{server} ? as_uni($win->{active}{server}{tag}) // '' : '';
+ if (length $name) {
+ $ent = "$name";
+ }
+ elsif (length $tag && length $active) {
+ $ent = "$tag/$active";
+ }
+ else {
+ $ent = "$number";
+ }
+
+ my $found = 0;
+ my @setting;
+ for my $s (split ' ', $S{detach}) {
+ my ($k, $v) = (split /(?:,(-?\d+))$/, $s)[0, 1];
+ if (lc1459(as_uni($k)) eq lc1459($ent)) {
+ unless ($found) {
+ if ($data =~ /^(-?\d+)$/) {
+ $ent .= ",$1";
+ }
+ if (defined $v && 0 == abs $v) {
+ $win->print("Hiding window $ent");
+ }
+ push @setting, as_tc($ent);
+ $found = 1;
+ }
+ }
+ else {
+ push @setting, defined $v ? "$k,$v" : $k;
+ }
+ }
+ unless ($found) {
+ $win->print("Hiding window $ent");
+ if ($data =~ /^(-?\d+)$/) {
+ $ent .= ",$1";
+ }
+ push @setting, as_tc($ent);
+ }
+
+ if (@setting) {
+ Irssi::command("^set ".(set 'detach')." @setting");
+ } else {
+ Irssi::command("^set -clear ".(set 'detach'));
+ }
+}
+
+sub unhide_window {
+ my ($data, $server, $witem) = @_;
+ my $win = Irssi::active_win;
+ my $number = $win->{refnum};
+ my $name = as_uni($win->{name});
+ my $active = as_uni($win->get_active_name) // '';
+ my $tag = $win->{active} && $win->{active}{server} ? as_uni($win->{active}{server}{tag}) // '' : '';
+
+ my %detach_aht;
+ if ($S{detach_aht}) {
+ %detach_aht = (map { ( lc1459(as_uni($_)) => undef ) }
+ split ' ', Irssi::settings_get_str('activity_hide_targets'));
+ }
+ my @setting;
+ my @kills = (length $name ? $name : undef,
+ length $tag && length $active ? "$tag/$active" : undef,
+ length $active ? $active : undef,
+ $number);
+ my @was_unhidden = (0) x @kills;
+ for my $s (split ' ', $S{detach}) {
+ my ($k, $v) = (split /(?:,(-?\d+))$/, $s)[0, 1];
+ my $k2 = lc1459(as_uni($k));
+ my $kill;
+ for my $ki (0..$#kills) {
+ if (defined $kills[$ki] && $k2 eq lc1459($kills[$ki])) {
+ $kill = $ki;
+ }
+ }
+
+ if (defined $kill) {
+ if (defined $v && 0 == abs $v) {
+ $was_unhidden[$kill] = 1;
+ push @setting, defined $v ? "$k,$v" : $k;
+ } else {
+ $win->print("Unhiding window $kills[$kill]");
+ }
+ }
+ else {
+ push @setting, defined $v ? "$k,$v" : $k;
+ }
+ }
+ my @is_hidden = (defined $kills[0] && (exists $detach_map{"*"} || exists $detach_map{"::all"}),
+ defined $kills[1] && (exists $detach_map{lc1459("$tag/*")} || exists $detach_map{lc1459("$tag/::all")}
+ || exists $detach_map{"*"} || exists $detach_map{"::all"}),
+ defined $kills[2] && (exists $detach_map{"*"} || exists $detach_map{"::all"}),
+ (exists $detach_map{"*"} || exists $detach_map{"::all"})
+ );
+ for my $ki (1, 2, 0, 3) {
+ if ($is_hidden[$ki]) {
+ unless ($was_unhidden[$ki]) {
+ $win->print("Unhiding window $kills[$ki]");
+ push @setting, "$kills[$ki],0";
+ $was_unhidden[$ki] = 1;
+ }
+ last;
+ }
+ }
+ my @is_hidden_aht = (defined $kills[0] && (exists $detach_aht{lc1459($name)}
+ || exists $detach_aht{"*"} || exists $detach_aht{"::all"}),
+ defined $kills[1] && (exists $detach_aht{lc1459("$tag/$active")}
+ || exists $detach_aht{lc1459($active)}
+ || exists $detach_aht{lc1459("$tag/*")} || exists $detach_aht{lc1459("$tag/::all")}
+ || exists $detach_aht{"*"} || exists $detach_aht{"::all"}),
+ defined $kills[2] && (exists $detach_aht{lc1459($active)}
+ || exists $detach_aht{"*"} || exists $detach_aht{"::all"}),
+ (exists $detach_aht{$number} || exists $detach_aht{"*"} || exists $detach_aht{"::all"})
+ );
+ for my $ki (1, 2, 0, 3) {
+ if ($is_hidden_aht[$ki]) {
+ unless ($was_unhidden[$ki]) {
+ $win->print("Unhiding window $kills[$ki], it is hidden because ".(set 'detach_aht')." is ON");
+ push @setting, "$kills[$ki],0";
+ $was_unhidden[$ki] = 1;
+ }
+ last;
+ }
+ }
+
+ if (@setting) {
+ Irssi::command("^set ".(set 'detach')." @setting");
+ } else {
+ Irssi::command("^set -clear ".(set 'detach'));
+ }
+}
+
+sub ack_window {
+ my ($data, $server, $witem) = @_;
+ my $win = Irssi::active_win;
+ my $number = $win->{refnum};
+ if (grep { $_->{cmd} eq 'ack' } Irssi::commands) {
+ my $Orig_Irssi_windows = \&Irssi::windows;
+ local *Irssi::windows = sub () { grep { !_is_detached($_, $number) } $Orig_Irssi_windows->() };
+ Irssi::command("ack" . (length $data ? " $data" : ""));
+ } else {
+ my $ignore_refnum = Irssi::settings_get_bool('active_window_ignore_refnum');
+ my $max_win;
+ my $max_act = 0;
+ my $max_ref = 0;
+ for my $rec (Irssi::windows) {
+ next if _is_detached($rec, $number);
+
+ # ignore refnum
+ if ($ignore_refnum &&
+ $rec->{data_level} > 0 && $max_act < $rec->{data_level}) {
+ $max_act = $rec->{data_level};
+ $max_win = $rec;
+ }
+
+ # windows with lower refnums break ties
+ elsif (!$ignore_refnum &&
+ $rec->{data_level} > 0 &&
+ ($rec->{data_level} > $max_act ||
+ ($rec->{data_level} == $max_act && $rec->{refnum} < $max_ref))) {
+ $max_act = $rec->{data_level};
+ $max_win = $rec;
+ $max_ref = $rec->{refnum};
+ }
+ }
+ $max_win->set_active if defined $max_win;
+ }
+}
+
+sub refnum_changed {
+ my ($win, $old_refnum) = @_;
+ my @old_setting = split ' ', $S{detach};
+ my @setting = map {
+ my ($k, $v) = (split /(?:,(-?\d+))$/, $_)[0, 1];
+ if ($k eq $old_refnum) {
+ $win->{refnum} . (defined $v ? ",$v" : "")
+ }
+ else {
+ $_
+ }
+ } @old_setting;
+ if ("@old_setting" ne "@setting") {
+ $S{detach} = "@setting";
+ Irssi::settings_set_str(set 'detach', "@setting");
+ &setup_changed;
+ }
+ else {
+ &wl_changed;
+ }
+}
+
+sub window_destroyed {
+ my ($win) = @_;
+ my @old_setting = split ' ', $S{detach};
+ my @setting = grep {
+ my ($k, $v) = (split /(?:,(-?\d+))$/, $_)[0, 1];
+ if ($k eq $win->{refnum}) {
+ 0;
+ }
+ else {
+ 1;
+ }
+ } @old_setting;
+ if ("@old_setting" ne "@setting") {
+ $S{detach} = "@setting";
+ Irssi::settings_set_str(set 'detach', "@setting");
+ &setup_changed;
+ }
+ else {
+ &awins_changed;
+ }
+}
+
+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 unless defined $^S;
+ 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;
+ local $BLOCK_ALL = 1;
+ Irssi::signal_add_first('window changed' => 'block_event_window_change');
+ my $bwin =
+ my $awin = Irssi::active_win;
+ my $lwin;
+ my $defer_irssi_broken_last;
+ unless ($wins[0]{refnum} == $awin->{refnum}) {
+ # special case: more than 1 last win, so /win last;
+ # /win last doesn't come back to the current window. eg. after
+ # connect & autojoin; we can't handle this situation, bail out
+ $defer_irssi_broken_last = 1;
+ }
+ else {
+ $awin->command('window last');
+ $lwin = Irssi::active_win;
+ $lwin->command('window last');
+ $defer_irssi_broken_last = $lwin->{refnum} == $bwin->{refnum};
+ }
+ my $awin_counter = 0;
+ 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 {
+ if (defined (my $r = `stty size 2>/dev/null`)) {
+ ($screenHeight, $screenWidth) = split ' ', $r;
+ $CHANGED{SETUP} = 1;
+ }
+ else {
+ $CHANGED{SIZE} = 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();
+ setup_changed();
+ update_keymap();
+ Irssi::timeout_remove($globTime)
+ if defined $globTime;
+ awl_refresh();
+ termsize_changed();
+}
+
+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 'abbrev_chars' => "~\x{301c}",
+ set 'viewer_item_bg' => sb_format_expand('{sb_background}'),
+ set 'title' => '\V'.setc().'\:',
+ ]);
+}
+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_str( setc, set 'detach', ''); #
+Irssi::settings_add_int( setc, set 'detach_data', -3); #
+Irssi::settings_add_bool(setc, set 'detach_aht', 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 'maxcolumns', 4); #
+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::settings_add_bool(setc, set 'no_mode_hint', 0); #
+Irssi::settings_add_bool(setc, set 'viewer_launch', 1); #
+Irssi::settings_add_str( setc, set 'viewer_launch_env', ''); #
+Irssi::settings_add_str( setc, set 'viewer_tmux_position', 'left'); #
+Irssi::settings_add_str( setc, set 'viewer_xwin_command', 'xterm +sb -e %A'); #
+Irssi::settings_add_str( setc, set 'viewer_custom_command', ''); #
+
+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' => 'window_destroyed',
+ 'window name changed' => 'wl_changed',
+ 'window refnum changed' => 'refnum_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' );
+Irssi::command_bind( setc() . ' restart' => 'restartViewerServer' );
+Irssi::command_bind( setc() . ' attach' => 'unhide_window' );
+Irssi::command_bind( setc() . ' detach' => 'hide_window' );
+Irssi::command_bind( setc() . ' ack' => 'ack_window' );
+
+{
+ 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]
+}
+
+# workaround for issue #271
+{ package Irssi::Nick }
+
+# workaround for issue #572
+@Irssi::UI::Exec::ISA = 'Irssi::Windowitem'
+ if Irssi::version >= 20140822 && Irssi::version <= 20161101 && !@Irssi::UI::Exec::ISA;
+
+UNITCHECK
+{ package AwlViewer;
+ use strict;
+ use warnings;
+ no warnings 'redefine';
+ use Encode;
+ use IO::Socket::UNIX;
+ use IO::Select;
+ use List::Util qw(max);
+ use constant BLOCK_SIZE => 1024;
+ use constant RECONNECT_TIME => 5;
+
+ my $sockpath;
+
+ our $VERSION = '0.8';
+
+ 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, $one_shot_integration, $one_shot_resize);
+ my $integration_position;
+ my $show_title_bar;
+
+ 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, $::IRSSI{name};
+
+ `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;
+
+ $show_title_bar = 1;
+ }
+
+ 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, $::IRSSI{name}) 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, $::IRSSI{name};
+ }
+
+ 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 if AWL_HI9 is set
+ 9 => $ENV{AWL_HI9} ? sub { $term_state{hicolor} ^= 1; '' }
+ : sub { my $n = 'bold'; my $e = ($term_state{$n} ^= 1) ? $n : "exit_$n"; Terminfo->can($e)->() },
+ # 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 = $vars{title} // uc ::setc();
+ my $ccs = qr/%(?:X(?:[1-6][0-9A-Z]|7[A-X])|[0-9BCFGIKMNRUWY_])/i;
+ (my $stripstr = $str) =~ s/($ccs)//g;
+ my $space = int( ((abs $vars{block}) - length $stripstr) / (1 + length $stripstr));
+ if ($space > 0) {
+ my $ss = ' ' x $space;
+ my @x = $str =~ /((?:$ccs)*\X(?:(?:$ccs)*$)?)/g;
+ $str = join $ss, '', @x, '';
+ }
+ ($stripstr = $str) =~ s/($ccs)//g;
+ my $pad = max 0, (abs $vars{block}) - length $stripstr;
+ $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 = ($vars{seplen} + abs $vars{block}) ?
+ int( ($screenWidth + $vars{seplen}) / ($vars{seplen} + abs $vars{block}) ) : 0;
+ my $xenl = ($vars{seplen} + abs $vars{block})
+ && $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 = $show_title_bar ? 1 : 0;
+ 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}
+ if $show_title_bar;
+ unless ($nrows > $ncols) { # line layout
+ ++$j if $show_title_bar;
+ for my $wi (@wi) {
+ if ($j >= $ncols) {
+ $j = 0;
+ ++$i;
+ }
+ last if $i >= $nrows;
+ _add_item($i, $j, $show_title_bar ? $c : $c + 1,
+ $wi, \@new_screen, \@new_mouse);
+ if ($c + 1 < $titems && $j + 1 < $ncols) {
+ $new_screen[$i][$j] .= $vars{separator};
+ }
+ ++$j;
+ ++$c;
+ }
+ }
+ else { # column layout
+ ++$i if $show_title_bar;
+ for my $wi (@wi) {
+ if ($i >= $nrows) {
+ $i = 0;
+ ++$j;
+ }
+ last if $j >= $ncols;
+ _add_item($i, $j, $show_title_bar ? $c : $c + 1,
+ $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 {
+ if (defined (my $r = safe_qx('stty size'))) {
+ ($screenHeight, $screenWidth) = split ' ', $r;
+ $resized = 0;
+ @screen = ();
+ $disp_update = 1;
+ if ($one_shot_integration == 2) {
+ $one_shot_resize--;
+ }
+ }
+ else {
+ }
+ }
+
+ 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 _match_tmux {
+ length $ENV{TMUX} && exists $vars{irssienv}{tmux_srv} && length $vars{irssienv}{tmux_pane}
+ && $ENV{TMUX} eq $vars{irssienv}{tmux_srv}
+ }
+
+ 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 (_match_tmux()) {
+ 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 check_integration {
+ return unless $vars{irssienv};
+ return unless $sock && exists $vars{seplen} && exists $vars{block};
+ if ($one_shot_integration == 1) {
+ my $nrows = $screenHeight - $vars{ha};
+ my $ncols = ($vars{seplen} + abs $vars{block}) ? int( ($screenWidth + $vars{seplen}) / ($vars{seplen} + abs $vars{block}) ) : 0;
+ my $items = ($show_title_bar ? 1 : 0) + @{$vars{win}//[]};
+ my $dcols_required = $nrows ? int($items/$nrows) + !!($items%$nrows) : 0;
+ my $rows_required = $ncols ? int($items/$ncols) + !!($items%$ncols) : 0;
+ $rows_required = abs $vars{ml}
+ if ($vars{ml} < 0 || ($vars{ml} > 0 && $rows_required > $vars{ml}));
+ $dcols_required = abs $vars{mc}
+ if ($vars{mc} < 0 || ($vars{mc} > 0 && $dcols_required > $vars{mc}));
+ my $rows = $rows_required + $vars{ha};
+ my $cols = ($dcols_required * ($vars{seplen} + abs $vars{block})) - $vars{seplen};
+ if (_match_tmux()) {
+ # int( ($screenWidth + $vars{seplen}) / ($vars{seplen} + abs $vars{block}) );
+ my ($pos_flag, $before);
+ if ($integration_position eq 'left') {
+ $pos_flag = 'h';
+ $before = 1;
+ }
+ elsif ($integration_position eq 'top') {
+ $pos_flag = 'v';
+ $before = 1;
+ }
+ elsif ($integration_position eq 'right') {
+ $pos_flag = 'h';
+ }
+ else {
+ $pos_flag = 'v';
+ }
+ my @cmd = "joinp -d$pos_flag -s $ENV{TMUX_PANE} -t $vars{irssienv}{tmux_pane}";
+ push @cmd, "swapp -d -t $ENV{TMUX_PANE} -s $vars{irssienv}{tmux_pane}"
+ if $before;
+ $cols = max($cols, 2);
+ $rows = max($rows, 2);
+
+ safe_qx("tmux " . (join " \\\; ", @cmd) . " 2>&1");
+ }
+ else {
+ $resized = 1;
+ #safe_qx("resize -s $screenHeight $cols 2>&1")
+ # if $cols > 0;
+ }
+ $one_shot_integration++;
+ if ($resized == 1) {
+ handle_resize();
+ resize_integration();
+ }
+ }
+ elsif ($one_shot_integration == 2) {
+ resize_integration(1);
+ }
+ }
+
+ sub resize_integration {
+ return unless $one_shot_integration;
+ return unless ($one_shot_resize//0) < 0 || shift;
+ return if ($one_shot_resize//0) > 0;
+
+ my $nrows = $screenHeight - $vars{ha};
+ my $ncols = ($vars{seplen} + abs $vars{block}) ? int( ($screenWidth + $vars{seplen}) / ($vars{seplen} + abs $vars{block}) ) : 0;
+ my $items = ($show_title_bar ? 1 : 0) + @{$vars{win}//[]};
+ my $dcols_required = $nrows ? (int($items/$nrows) + !!($items%$nrows)) : 0;
+ my $rows_required = $ncols ? int($items/$ncols) + !!($items%$ncols) : 0;
+ $rows_required = abs $vars{ml}
+ if ($vars{ml} < 0 || ($vars{ml} > 0 && $rows_required > $vars{ml}));
+ $dcols_required = abs $vars{mc}
+ if ($vars{mc} < 0 || ($vars{mc} > 0 && $dcols_required > $vars{mc}));
+ my $rows = $rows_required + $vars{ha};
+ my $cols = ($dcols_required * ($vars{seplen} + abs $vars{block})) - $vars{seplen};
+ if (_match_tmux()) {
+ my $pos_flag;
+ my $before = 0;
+ if ($integration_position eq 'left') {
+ $pos_flag = 'h';
+ $before = 1;
+ }
+ elsif ($integration_position eq 'top') {
+ $pos_flag = 'v';
+ $before = 1;
+ }
+ elsif ($integration_position eq 'right') {
+ $pos_flag = 'h';
+ }
+ else {
+ $pos_flag = 'v';
+ }
+ my @cmd;
+ # hard tmux limits
+ $cols = max($cols, 2);
+ $rows = max($rows, 2);
+ if ($pos_flag eq 'h' && $cols != $screenWidth) {
+ my $change = $screenWidth - $cols;
+ my $dir = ($before ^ ($change<0)) ? 'L' : 'R';
+ push @cmd, "resizep -$dir -t $ENV{TMUX_PANE} @{[abs $change]}";
+ #push @cmd, "resizep -x $cols -t $ENV{TMUX_PANE}";
+ $one_shot_resize = 1;
+ }
+ if ($pos_flag eq 'v' && $rows != $screenHeight) {
+ #push @cmd, "resizep -y $rows -t $ENV{TMUX_PANE}";
+ my $change = $screenHeight - $rows;
+ my $dir = ($before ^ ($change<0)) ? 'U' : 'D';
+ push @cmd, "resizep -$dir -t $ENV{TMUX_PANE} @{[abs $change]}";
+ $one_shot_resize = 1;
+ }
+
+ safe_qx("tmux " . (join " \\\; ", @cmd) . " 2>&1")
+ if @cmd;
+ }
+ else {
+ $cols = max($cols, 1);
+ $rows = max($rows, 1);
+ unless ($nrows > $ncols) { # line layout
+ if ($rows != $screenHeight) {
+ safe_qx("resize -s $rows $screenWidth 2>&1");
+ $one_shot_resize = 1;
+ }
+ }
+ else {
+ if ($cols != $screenWidth) {
+ safe_qx("resize -s $screenHeight $cols 2>&1");
+ $one_shot_resize = 1;
+ }
+ }
+ }
+ if ($resized == 1) {
+ handle_resize();
+ }
+ }
+
+ sub init_integration {
+ return unless $one_shot_integration;
+ if (_match_tmux()) {
+ }
+ else {
+ }
+ safe_print("\e]2;".(uc ::setc())."\e\\");
+ }
+
+ sub main {
+ require Getopt::Std;
+ my %opts;
+ Getopt::Std::getopts('1p:', \%opts);
+ my $one_shot = $opts{1};
+ $integration_position = $opts{p};
+ $one_shot_integration = 0+!!$one_shot;
+ #shift if @_ && $_[0] eq '--';
+ &init;
+ $show_title_bar = 0 if $ENV{AWL_NOTITLE};
+ init_integration();
+ until ($got_int) {
+ $timeout = undef;
+ if ($resized) {
+ if ($resized == 1) {
+ $timeout = 1;
+ $resized++;
+ }
+ else {
+ handle_resize();
+ resize_integration();
+ }
+ }
+ unless ($sock || $timeout) {
+ connect_it();
+ }
+ $timeout ||= RECONNECT_TIME unless $sock;
+ update_screen() if $disp_update;
+ SELECT: 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 SELECT;
+ }
+ }
+ else {
+ if ($fh->read(my $buf, BLOCK_SIZE)) {
+ do {
+ $rcvbuf .= $buf;
+ } while $fh->read($buf, BLOCK_SIZE);
+ }
+ else {
+ $disp_update = 1;
+ remove_conn($fh);
+ if ($one_shot) {
+ $got_int = 1;
+ last SELECT;
+ }
+ $timeout ||= RECONNECT_TIME;
+ }
+ }
+ }
+ $disp_update |= process_recv() if length $rcvbuf;
+ process_keys() if length $keybuf;
+ check_integration() if $one_shot;
+ update_screen() if $disp_update;
+ }
+ continue {
+ }
+ }
+ end_prog();
+ }
+}
+
+1;
+
+# Changelog
+# =========
+# 1.8
+# - use string_width in Irssi 1.2.0
+#
+# 1.7
+# - fix crash on invalid /set awl_sort, introduced in 1.6, reported by
+# tpetazzoni
+# - delay viewer initialisation
+# - improve race condition on tmux resize integration
+#
+# 1.6
+# - add detach setting to hide windows
+# - fix race condition when loading the script, reported by madduck
+# - improve compatibility with irssi 1.2
+# - add special value lru to awl_sort to sort windows by usage
+#
+# 1.5
+# - improve compat. with sideways splits
+#
+# 1.4
+# - fix line wrapping in some themes, reported by justanotherbody
+# - fix named window key detection, reported by madduck
+# - make title (in viewer and shared_sbar) configurable
+#
+# 1.3
+# - workaround for irssi issue #572
+#
+# 1.2
+# - new format to choose abbreviation character
+#
+# 1.1
+# - infinite loop on shortening certain window names reported by Kalan
+#
+# 1.0
+# - new awl_viewer_launch setting and an array of related settings
+# - fixed regression bug /exec -interactive
+# - fixed some warnings in perl 5.10 reported by kl3
+# - workaround for crash due to infinite recursion in irssi's Perl
+# error handling
+#
+# 0.9
+# - 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
+# - add case-insensitive modifier to awl_sort
+# - run custom_xform on awl_prefer_name also
+# - avoid inconsistent active window state after awin detection
+# reported by ss
+# - revert %9-hack in the viewer prompted by discussion with pierrot
+# - fix new warning in perl 5.22
+#
+# 0.8
+# - 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/launchers/BitwardenLaunch b/launchers/BitwardenLaunch
new file mode 100755
index 0000000..825987b
--- /dev/null
+++ b/launchers/BitwardenLaunch
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+/home/swatson/Software/Bitwarden-1.10.0-x86_64.AppImage
diff --git a/launchers/SF3d_Launch b/launchers/SF3d_Launch
new file mode 100755
index 0000000..69d9ef3
--- /dev/null
+++ b/launchers/SF3d_Launch
@@ -0,0 +1,4 @@
+#!/bin/bash
+cd /opt/Simplify3D-4.0.1/
+export LD_LIBRARY_PATH=.
+/opt/Simplify3D-4.0.1/Simplify3D "$@"
diff --git a/lemonbar/desktop/bar.sh b/lemonbar/desktop/bar.sh
new file mode 100755
index 0000000..160bc9b
--- /dev/null
+++ b/lemonbar/desktop/bar.sh
@@ -0,0 +1,137 @@
+#!/bin/bash
+
+div="%{F#0092ff}<>%{F-}%{B-}"
+
+Clock() {
+ DATETIME=$(date "+%a %b %d, %T")
+
+ echo -n "$DATETIME"
+}
+
+cpuTemp() {
+
+ CPUTEMP=$(sensors k10temp-pci-00c3 | grep Tdie | awk '{print $2}' | grep -o [0-9][0-9]||[0-9][0-9][0-9])
+ GPUTEMP=$(sensors amdgpu-pci-1d00 | grep temp1 | awk '{print $2}' | grep -o [0-9][0-9]||[0-9][0-9][0-9])
+ GPUFAN=$(sensors amdgpu-pci-1d00 | grep fan1 | awk '{print $2}')
+ if [[ $CPUTEMP -gt 70 ]]; then
+ CPUTEMP="%{F#ff5b00}$CPUTEMP%{F-}%{B-}"
+ else
+ CPUTEMP="%{F#ff9966}$CPUTEMP%{F-}%{B-}"
+ fi
+
+ if [[ $GPUTEMP -gt 70 ]]; then
+ GPUTEMP="%{F#ff5b00}$GPUTEMP%{F-}%{B-}"
+ else
+ GPUTEMP="%{F#ff9966}$GPUTEMP%{F-}%{B-}"
+ fi
+
+ CPUFREQ=$(lscpu | grep MHz | head -n1 | awk '{print $3}')
+
+ echo -n "CPU Temp: $CPUTEMP° CPU Freq: $CPUFREQ $div GPU Temp: $GPUTEMP° $div GPU FAN: $GPUFAN RPM"
+
+}
+
+batteryInfo() {
+
+ capacityRemaining=$(cat /sys/class/power_supply/BAT0/capacity)
+ batteryStatus=$(cat /sys/class/power_supply/BAT0/status)
+
+ if [[ $capacityRemaining -lt 25 ]]; then
+ capacityRemaining="%{F#ff5b00}$capacityRemaining %{F-}%{B-}"
+ fi
+
+ if [[ "$batteryStatus" == "Charging" ]]; then
+ batteryStatus="%{F#ff9966}$batteryStatus%{F-}%{B-}"
+ fi
+
+ capacityRemaining=$capacityRemaining%
+ echo -n "Battery: $capacityRemaining $batteryStatus"
+
+}
+
+wifiInfo() {
+
+ connectionName=$(nmcli -f GENERAL,WIFI-PROPERTIES dev show wlp26s0 | grep GENERAL.CONNECTION: | awk '{print $2}')
+ connectionStrength=$(nmcli dev wifi | tail -n1 | awk '{print $7}')
+
+ echo -n "Wifi: $connectionName $connectionStrength%"
+
+}
+
+ethPort() {
+
+ linkDetected=$(cat /sys/class/net/enp24s0/carrier)
+ if [[ $linkDetected -eq 0 ]]; then
+ connected="eth0: down"
+ elif [[ $linkDetected -eq 1 ]]; then
+ connected="eth0: up"
+ fi
+
+ echo -n "$connected"
+
+}
+
+diskFree() {
+
+ freeNVME=$(df -h /dev/mapper/ubuntu--vg-root | awk '{print $4}' | tail -n1)
+ freeHDD=$(df -h /dev/mapper/hddVolume | awk '{print $4}' | tail -n1)
+
+ echo -n "NVMe Free: $freeNVME $div HDD Free: $freeHDD"
+
+}
+
+loadAvg() {
+
+ la=$(uptime | grep -o :\ [0-9].* | sed s/://g | awk '{print $1}' | sed s/,//g)
+
+ if (( $(echo "$la > 8" |bc -l) )); then
+ la="%{F#ff5b00}$la%{F-}%{B-}"
+ else
+ la="%{F#ff9966}$la%{F-}%{B-}"
+ fi
+
+
+ echo -n "Load: $la"
+
+}
+
+soundState() {
+
+ muted=$(pactl list sinks | grep Mute: | awk '{print $2}')
+ if [[ "$muted" == yes ]]; then
+ state="Volume: 0%"
+ else
+ level=$(pactl list sinks | grep Volume: | awk '{print $5}' | head -n1)
+ state="Volume: $level"
+ fi
+
+ echo -n $state
+
+}
+
+expressVpn() {
+
+ expressValue=$(expressvpn status | grep Connected 2>&1 > /dev/null; echo $?)
+ if [[ "$expressValue" -ne 0 ]]; then
+ echo -n "%{F#ff5b00}EVPN Down%{F-}%{B-}"
+ elif [[ "$expressValue" -eq 0 ]]; then
+ echo -n "%{F#ff9966}EVPN Up%{F-}%{B-}"
+ else
+ echo -n "Could not determine ExpressVPN status"
+ fi
+}
+
+
+now_playing() {
+
+ artist=$(cmus-remote -Q | grep "tag artist " | sed s/^tag\ artist\ //g)
+ title=$(cmus-remote -Q | grep "tag title " | sed s/^tag\ title\ //g)
+ album=$(cmus-remote -Q | grep "tag album " | sed s/^tag\ album\ //g)
+ echo -n "Now Playing: $artist - $album - %{F#ff9966}$title%{F-}%{B-}"
+}
+
+while true; do
+ sleep 1
+ echo "%{l} $(Clock) $div $(cpuTemp) $div $(loadAvg) $div $(wifiInfo) $div $(ethPort) $div $(diskFree) $div $(soundState) $div $(expressVpn) $div $(now_playing)"
+ sleep 0.5
+done
diff --git a/lemonbar/desktop/startLemon.sh b/lemonbar/desktop/startLemon.sh
new file mode 100755
index 0000000..58294dd
--- /dev/null
+++ b/lemonbar/desktop/startLemon.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+/home/swatson/.config/lemonbar/bar.sh | /usr/bin/lemonbar -b -p -g 1920x15+0+0
+#/home/swatson/.config/lemonbar/bar.sh | /usr/bin/lemonbar
diff --git a/lemonbar/laptop/bar.sh b/lemonbar/laptop/bar.sh
new file mode 100755
index 0000000..80e85f8
--- /dev/null
+++ b/lemonbar/laptop/bar.sh
@@ -0,0 +1,113 @@
+#!/bin/bash
+
+div="%{F#ff9966}<>%{F-}"
+
+# Define the clock
+Clock() {
+ DATETIME=$(date "+%a %b %d, %T")
+
+ echo -n "$DATETIME"
+}
+
+cpuTemp() {
+
+ TEMP=$(sensors | grep CPU: | awk '{print $2}' );
+ nakedTemp=$(echo $TEMP | grep -o [0-9][0-9])
+ if [[ $nakedTemp -gt 60 ]]; then
+ TEMP="%{F#A54242}$TEMP%{F-}%{B-}"
+ fi
+
+ FREQ=$(lscpu | grep "CPU MHz" | awk '{print $3}')
+ echo -n "Temp: $TEMP >> Freq: $FREQ"
+
+}
+
+batteryInfo() {
+
+ capacityRemaining=$(cat /sys/class/power_supply/BAT0/capacity)
+ batteryStatus=$(cat /sys/class/power_supply/BAT0/status)
+
+ if [[ $capacityRemaining -lt 25 ]]; then
+ capacityRemaining="%{F#A54242}$capacityRemaining %{F-}%{B-}"
+ fi
+
+ if [[ "$batteryStatus" == "Charging" ]]; then
+ batteryStatus="%{F#5E9440}$batteryStatus%{F-}%{B-}"
+ fi
+
+ capacityRemaining=$capacityRemaining%
+ echo -n "Battery: $capacityRemaining $batteryStatus"
+
+}
+
+wifiInfo() {
+
+ connectionName=$(nmcli -f GENERAL,WIFI-PROPERTIES dev show wlp60s0 | grep GENERAL.CONNECTION: | awk '{print $2}')
+ connectionStrength=$(cat /proc/net/wireless | grep wlp60s0 | awk '{print $3}' | sed s/.$//g)
+
+ echo -n "Wifi: $connectionName $connectionStrength%"
+
+}
+
+ethPort() {
+
+ linkDetected=$(cat /sys/class/net/enp59s0/carrier)
+ if [[ $linkDetected -eq 0 ]]; then
+ connected="eth0: down"
+ elif [[ $linkDetected -eq 1 ]]; then
+ connected="eth0: up"
+ fi
+
+ echo -n "$connected"
+
+}
+
+diskFree() {
+
+ freeSSD=$(df -h /dev/mapper/ubuntu--vg-root | awk '{print $4}' | tail -n1)
+ #freeHDD=$(df -h /dev/sdb1 | awk '{print $4}' | tail -n1)
+
+ echo -n "SSD Free: $freeSSD >> HDD Free: $freeHDD"
+
+}
+
+loadAvg() {
+
+ la=$(uptime | grep -o :\ [0-9].* | sed s/://g | awk '{print $1}' | sed s/,//g)
+
+ echo -n "Load: $la"
+
+}
+
+soundState() {
+
+ muted=$(pactl list sinks | grep Mute: | awk '{print $2}')
+ if [[ "$muted" == yes ]]; then
+ state="Volume: 0%"
+ else
+ level=$(pactl list sinks | grep Volume: | awk '{print $5}' | head -n1)
+ state="Volume: $level"
+ fi
+
+ echo -n $state
+
+}
+
+expressVpn() {
+
+ expressValue=$(expressvpn status | grep Connected 2>&1 > /dev/null; echo $?)
+ if [[ "$expressValue" -ne 0 ]]; then
+ echo -n "ExpressVPN not connected"
+ elif [[ "$expressValue" -eq 0 ]]; then
+ echo -n "ExpressVPN connected"
+ else
+ echo -n "Could not determine ExpressVPN status"
+ fi
+}
+
+
+while true; do
+ sleep 1
+ echo "%{l} $(Clock) $div $(cpuTemp) $div $(loadAvg) $div $(batteryInfo) $div $(wifiInfo) $div $(ethPort) $div $(diskFree) $div $(soundState) $div $(expressVpn) "
+ sleep 0.5
+done
diff --git a/lemonbar/laptop/startLemon.sh b/lemonbar/laptop/startLemon.sh
new file mode 100755
index 0000000..8aa9f47
--- /dev/null
+++ b/lemonbar/laptop/startLemon.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+#/home/swatson/Repos/dotfiles/lemonbarConf/bar.sh | /usr/bin/lemonbar -b -p -g 1920x15+0+30
+/home/swatson/Repos/dotfiles/lemonbarConf/bar.sh | /usr/bin/lemonbar
diff --git a/lemonbar/laptop/workspaces.sh b/lemonbar/laptop/workspaces.sh
new file mode 100755
index 0000000..cd4f1e3
--- /dev/null
+++ b/lemonbar/laptop/workspaces.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+i3-msg -t get_workspaces \
+ | jq '.[] | select(.focused==true).name' \
+ | cut -d"\"" -f2
diff --git a/openbox/desktop/autostart b/openbox/desktop/autostart
new file mode 100755
index 0000000..2b35957
--- /dev/null
+++ b/openbox/desktop/autostart
@@ -0,0 +1,24 @@
+#
+# These things are run when an Openbox X Session is started.
+# You may place a similar script in $HOME/.config/openbox/autostart
+# to run user-specific things.
+#
+
+# If you want to use GNOME config tools...
+#
+#if test -x /usr/lib/x86_64-linux-gnu/gnome-settings-daemon >/dev/null; then
+# /usr/lib/x86_64-linux-gnu/gnome-settings-daemon &
+#elif which gnome-settings-daemon >/dev/null 2>&1; then
+# gnome-settings-daemon &
+#fi
+
+# If you want to use XFCE config tools...
+#
+#xfce-mcs-manager &
+nitrogen --restore
+tint2 &
+/home/swatson/.config/lemonbar/startLemon.sh &
+nm-applet &
+compton -b &
+dunst &
+expressvpn connect &
diff --git a/openbox/desktop/environment b/openbox/desktop/environment
new file mode 100755
index 0000000..3311bd6
--- /dev/null
+++ b/openbox/desktop/environment
@@ -0,0 +1,10 @@
+#
+# Set system-wide environment variables here for Openbox
+# User-specific variables should be placed in $HOME/.config/openbox/environment
+#
+
+# To set your language for displaying messages and time/date formats, use the following:
+#LANG=en_CA.UTF8
+
+# To set your keyboard layout, you need to modify your X config:
+# http://www.google.com/search?q=how+to+set+keyboard+layout+xorg
diff --git a/openbox/desktop/menu.xml b/openbox/desktop/menu.xml
new file mode 100644
index 0000000..b3cf8bf
--- /dev/null
+++ b/openbox/desktop/menu.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/ file:///usr/share/openbox/menu.xsd">
+ <menu id="root-menu" label="Openbox 3">
+ <item label="Terminal emulator">
+ <action name="Execute">
+ <execute>urxvt</execute>
+ </action>
+ </item>
+ <item label="Web browser">
+ <action name="Execute">
+ <execute>x-www-browser</execute>
+ </action>
+ </item>
+ <!-- This requires the presence of the 'openbox-menu' package to work -->
+ <separator/>
+ <menu execute="/usr/bin/obamenu" id="applications-menu" label="Applications"/>
+ <separator/>
+ <item label="ObConf">
+ <action name="Execute">
+ <execute>obconf</execute>
+ </action>
+ </item>
+ <item label="Reconfigure">
+ <action name="Reconfigure"/>
+ </item>
+ <item label="Restart">
+ <action name="Restart"/>
+ </item>
+ <separator/>
+ <item label="Exit">
+ <action name="Exit"/>
+ </item>
+ </menu>
+</openbox_menu>
diff --git a/openbox/desktop/rc.xml b/openbox/desktop/rc.xml
new file mode 100644
index 0000000..4de2da1
--- /dev/null
+++ b/openbox/desktop/rc.xml
@@ -0,0 +1,832 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Do not edit this file, it will be overwritten on install.
+ Copy the file to $HOME/.config/openbox/ instead. -->
+<openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <resistance>
+ <strength>10</strength>
+ <screen_edge_strength>20</screen_edge_strength>
+ </resistance>
+ <focus>
+ <focusNew>yes</focusNew>
+ <!-- always try to focus new windows when they appear. other rules do
+ apply -->
+ <followMouse>no</followMouse>
+ <!-- move focus to a window when you move the mouse into it -->
+ <focusLast>yes</focusLast>
+ <!-- focus the last used window when changing desktops, instead of the one
+ under the mouse pointer. when followMouse is enabled -->
+ <underMouse>no</underMouse>
+ <!-- move focus under the mouse, even when the mouse is not moving -->
+ <focusDelay>200</focusDelay>
+ <!-- when followMouse is enabled, the mouse must be inside the window for
+ this many milliseconds (1000 = 1 sec) before moving focus to it -->
+ <raiseOnFocus>no</raiseOnFocus>
+ <!-- when followMouse is enabled, and a window is given focus by moving the
+ mouse into it, also raise the window -->
+ </focus>
+ <placement>
+ <policy>Smart</policy>
+ <!-- 'Smart' or 'UnderMouse' -->
+ <center>yes</center>
+ <!-- whether to place windows in the center of the free area found or
+ the top left corner -->
+ <monitor>Primary</monitor>
+ <!-- with Smart placement on a multi-monitor system, try to place new windows
+ on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where
+ the active window is, 'Primary' - only on the primary monitor -->
+ <primaryMonitor>1</primaryMonitor>
+ <!-- The monitor where Openbox should place popup dialogs such as the
+ focus cycling popup, or the desktop switch popup. It can be an index
+ from 1, specifying a particular monitor. Or it can be one of the
+ following: 'Mouse' - where the mouse is, or
+ 'Active' - where the active window is -->
+ </placement>
+ <theme>
+ <name>Clearlooks</name>
+ <titleLayout>NLIMC</titleLayout>
+ <!--
+ available characters are NDSLIMC, each can occur at most once.
+ N: window icon
+ L: window label (AKA title).
+ I: iconify
+ M: maximize
+ C: close
+ S: shade (roll up/down)
+ D: omnipresent (on all desktops).
+ -->
+ <keepBorder>yes</keepBorder>
+ <animateIconify>yes</animateIconify>
+ <font place="ActiveWindow">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Bold</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="InactiveWindow">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Bold</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="MenuHeader">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Normal</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="MenuItem">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Normal</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="ActiveOnScreenDisplay">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Bold</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="InactiveOnScreenDisplay">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Bold</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ </theme>
+ <desktops>
+ <!-- this stuff is only used at startup, pagers allow you to change them
+ during a session
+
+ these are default values to use when other ones are not already set
+ by other applications, or saved in your session
+
+ use obconf if you want to change these without having to log out
+ and back in -->
+ <number>4</number>
+ <firstdesk>1</firstdesk>
+ <names>
+ <!-- set names up here if you want to, like this:
+ <name>desktop 1</name>
+ <name>desktop 2</name>
+ -->
+ </names>
+ <popupTime>875</popupTime>
+ <!-- The number of milliseconds to show the popup for when switching
+ desktops. Set this to 0 to disable the popup. -->
+ </desktops>
+ <resize>
+ <drawContents>yes</drawContents>
+ <popupShow>Nonpixel</popupShow>
+ <!-- 'Always', 'Never', or 'Nonpixel' (xterms and such) -->
+ <popupPosition>Center</popupPosition>
+ <!-- 'Center', 'Top', or 'Fixed' -->
+ <popupFixedPosition>
+ <!-- these are used if popupPosition is set to 'Fixed' -->
+ <x>10</x>
+ <!-- positive number for distance from left edge, negative number for
+ distance from right edge, or 'Center' -->
+ <y>10</y>
+ <!-- positive number for distance from top edge, negative number for
+ distance from bottom edge, or 'Center' -->
+ </popupFixedPosition>
+ </resize>
+ <!-- You can reserve a portion of your screen where windows will not cover when
+ they are maximized, or when they are initially placed.
+ Many programs reserve space automatically, but you can use this in other
+ cases. -->
+ <margins>
+ <top>0</top>
+ <bottom>0</bottom>
+ <left>0</left>
+ <right>0</right>
+ </margins>
+ <dock>
+ <position>BottomRight</position>
+ <!-- (Top|Bottom)(Left|Right|)|Top|Bottom|Left|Right|Floating -->
+ <floatingX>0</floatingX>
+ <floatingY>0</floatingY>
+ <noStrut>no</noStrut>
+ <stacking>Above</stacking>
+ <!-- 'Above', 'Normal', or 'Below' -->
+ <direction>Horizontal</direction>
+ <!-- 'Vertical' or 'Horizontal' -->
+ <autoHide>no</autoHide>
+ <hideDelay>300</hideDelay>
+ <!-- in milliseconds (1000 = 1 second) -->
+ <showDelay>300</showDelay>
+ <!-- in milliseconds (1000 = 1 second) -->
+ <moveButton>Middle</moveButton>
+ <!-- 'Left', 'Middle', 'Right' -->
+ </dock>
+ <keyboard>
+ <chainQuitKey>C-g</chainQuitKey>
+ <!-- Keybindings for desktop switching -->
+ <keybind key="C-A-Left">
+ <action name="GoToDesktop">
+ <to>left</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="C-A-Right">
+ <action name="GoToDesktop">
+ <to>right</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="C-A-Up">
+ <action name="GoToDesktop">
+ <to>up</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="C-A-Down">
+ <action name="GoToDesktop">
+ <to>down</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="S-A-Left">
+ <action name="SendToDesktop">
+ <to>left</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="S-A-Right">
+ <action name="SendToDesktop">
+ <to>right</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="S-A-Up">
+ <action name="SendToDesktop">
+ <to>up</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="S-A-Down">
+ <action name="SendToDesktop">
+ <to>down</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="W-F1">
+ <action name="GoToDesktop">
+ <to>1</to>
+ </action>
+ </keybind>
+ <keybind key="W-F2">
+ <action name="GoToDesktop">
+ <to>2</to>
+ </action>
+ </keybind>
+ <keybind key="W-F3">
+ <action name="GoToDesktop">
+ <to>3</to>
+ </action>
+ </keybind>
+ <keybind key="W-F4">
+ <action name="GoToDesktop">
+ <to>4</to>
+ </action>
+ </keybind>
+ <keybind key="W-e">
+ <action name="ToggleShowDesktop"/>
+ </keybind>
+ <!-- Keybindings for windows -->
+ <keybind key="W-S-q">
+ <action name="Close"/>
+ </keybind>
+ <keybind key="A-Escape">
+ <action name="Lower"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ </keybind>
+ <keybind key="A-space">
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </keybind>
+ <!-- Take a screenshot of the current window with scrot when Alt+Print are pressed -->
+ <keybind key="A-Print">
+ <action name="Execute">
+ <command>scrot -s</command>
+ </action>
+ </keybind>
+ <!-- Keybindings for window switching -->
+ <keybind key="A-Tab">
+ <action name="NextWindow">
+ <finalactions>
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </finalactions>
+ </action>
+ </keybind>
+ <keybind key="A-S-Tab">
+ <action name="PreviousWindow">
+ <finalactions>
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </finalactions>
+ </action>
+ </keybind>
+ <keybind key="C-A-Tab">
+ <action name="NextWindow">
+ <panels>yes</panels>
+ <desktop>yes</desktop>
+ <finalactions>
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </finalactions>
+ </action>
+ </keybind>
+ <!-- Keybindings for window switching with the arrow keys -->
+ <keybind key="W-S-Right">
+ <action name="DirectionalCycleWindows">
+ <direction>right</direction>
+ </action>
+ </keybind>
+ <keybind key="W-S-Left">
+ <action name="DirectionalCycleWindows">
+ <direction>left</direction>
+ </action>
+ </keybind>
+ <keybind key="W-S-Up">
+ <action name="DirectionalCycleWindows">
+ <direction>up</direction>
+ </action>
+ </keybind>
+ <keybind key="W-S-Down">
+ <action name="DirectionalCycleWindows">
+ <direction>down</direction>
+ </action>
+ </keybind>
+ <!-- Keybindings for running applications -->
+ <keybind key="W-d">
+ <action name="Execute">
+ <command>rofi -show run</command>
+ </action>
+ </keybind>
+ <keybind key="W-S-d">
+ <action name="Execute">
+ <command>rofi -show window</command>
+ </action>
+ </keybind>
+ <keybind key="W-Return">
+ <action name="Execute">
+ <command>urxvt</command>
+ </action>
+ </keybind>
+ <keybind key="XF86AudioRaiseVolume">
+ <action name="Execute">
+ <command>amixer -q set Master 2dB+ unmute</command>
+ </action>
+ </keybind>
+ <keybind key="XF86AudioLowerVolume">
+ <action name="Execute">
+ <command>amixer -q set Master 2dB- unmute</command>
+ </action>
+ </keybind>
+ <keybind key="XF86AudioMute">
+ <action name="Execute">
+ <command>amixer -q set Speaker toggle; amixer -q set Master toggle</command>
+ </action>
+ </keybind>
+ <keybind key="XF86MonBrightnessUp">
+ <action name="Execute">
+ <command>sudo light -A 10</command>
+ </action>
+ </keybind>
+ <keybind key="XF86MonBrightnessDown">
+ <action name="Execute">
+ <command>sudo light -U 10</command>
+ </action>
+ </keybind>
+ <!-- Launch scrot when Print is pressed -->
+ <keybind key="Print">
+ <action name="Execute">
+ <command>scrot</command>
+ </action>
+ </keybind>
+ </keyboard>
+ <mouse>
+ <dragThreshold>1</dragThreshold>
+ <!-- number of pixels the mouse must move before a drag begins -->
+ <doubleClickTime>500</doubleClickTime>
+ <!-- in milliseconds (1000 = 1 second) -->
+ <screenEdgeWarpTime>400</screenEdgeWarpTime>
+ <!-- Time before changing desktops when the pointer touches the edge of the
+ screen while moving a window, in milliseconds (1000 = 1 second).
+ Set this to 0 to disable warping -->
+ <screenEdgeWarpMouse>false</screenEdgeWarpMouse>
+ <!-- Set this to TRUE to move the mouse pointer across the desktop when
+ switching due to hitting the edge of the screen -->
+ <context name="Frame">
+ <mousebind button="A-Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="A-Left" action="Click">
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="W-Left" action="Drag">
+ <action name="Move"/>
+ </mousebind>
+ <mousebind button="A-Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="W-Right" action="Drag">
+ <action name="Resize"/>
+ </mousebind>
+ <mousebind button="A-Middle" action="Press">
+ <action name="Lower"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ </mousebind>
+ <mousebind button="A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="C-A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="C-A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-S-Up" action="Click">
+ <action name="SendToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-S-Down" action="Click">
+ <action name="SendToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Titlebar">
+ <mousebind button="Left" action="Drag">
+ <action name="Move"/>
+ </mousebind>
+ <mousebind button="Left" action="DoubleClick">
+ <action name="ToggleMaximize"/>
+ </mousebind>
+ <mousebind button="Up" action="Click">
+ <action name="if">
+ <shaded>no</shaded>
+ <then>
+ <action name="Shade"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ <action name="Lower"/>
+ </then>
+ </action>
+ </mousebind>
+ <mousebind button="Down" action="Click">
+ <action name="if">
+ <shaded>yes</shaded>
+ <then>
+ <action name="Unshade"/>
+ <action name="Raise"/>
+ </then>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Titlebar Top Right Bottom Left TLCorner TRCorner BRCorner BLCorner">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Middle" action="Press">
+ <action name="Lower"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Top">
+ <mousebind button="Left" action="Drag">
+ <action name="Resize">
+ <edge>top</edge>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Left">
+ <mousebind button="Left" action="Drag">
+ <action name="Resize">
+ <edge>left</edge>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Right">
+ <mousebind button="Left" action="Drag">
+ <action name="Resize">
+ <edge>right</edge>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Bottom">
+ <mousebind button="Left" action="Drag">
+ <action name="Resize">
+ <edge>bottom</edge>
+ </action>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </mousebind>
+ </context>
+ <context name="TRCorner BRCorner TLCorner BLCorner">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Left" action="Drag">
+ <action name="Resize"/>
+ </mousebind>
+ </context>
+ <context name="Client">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Middle" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ </context>
+ <context name="Icon">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </mousebind>
+ </context>
+ <context name="AllDesktops">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="ToggleOmnipresent"/>
+ </mousebind>
+ </context>
+ <context name="Shade">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="ToggleShade"/>
+ </mousebind>
+ </context>
+ <context name="Iconify">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="Iconify"/>
+ </mousebind>
+ </context>
+ <context name="Maximize">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Middle" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="ToggleMaximize"/>
+ </mousebind>
+ <mousebind button="Middle" action="Click">
+ <action name="ToggleMaximize">
+ <direction>vertical</direction>
+ </action>
+ </mousebind>
+ <mousebind button="Right" action="Click">
+ <action name="ToggleMaximize">
+ <direction>horizontal</direction>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Close">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="Close"/>
+ </mousebind>
+ </context>
+ <context name="Desktop">
+ <mousebind button="Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="C-A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="C-A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ </context>
+ <context name="Root">
+ <!-- Menus -->
+ <mousebind button="Middle" action="Press">
+ <action name="ShowMenu">
+ <menu>client-list-combined-menu</menu>
+ </action>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="ShowMenu">
+ <menu>root-menu</menu>
+ </action>
+ </mousebind>
+ </context>
+ <context name="MoveResize">
+ <mousebind button="Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ </context>
+ </mouse>
+ <menu>
+ <!-- You can specify more than one menu file in here and they are all loaded,
+ just don't make menu ids clash or, well, it'll be kind of pointless -->
+ <!-- default menu file (or custom one in $HOME/.config/openbox/) -->
+ <!-- system menu files on Debian systems -->
+ <file>/var/lib/openbox/debian-menu.xml</file>
+ <file>menu.xml</file>
+ <hideDelay>200</hideDelay>
+ <!-- if a press-release lasts longer than this setting (in milliseconds), the
+ menu is hidden again -->
+ <middle>no</middle>
+ <!-- center submenus vertically about the parent entry -->
+ <submenuShowDelay>100</submenuShowDelay>
+ <!-- time to delay before showing a submenu after hovering over the parent
+ entry.
+ if this is a negative value, then the delay is infinite and the
+ submenu will not be shown until it is clicked on -->
+ <submenuHideDelay>400</submenuHideDelay>
+ <!-- time to delay before hiding a submenu when selecting another
+ entry in parent menu
+ if this is a negative value, then the delay is infinite and the
+ submenu will not be hidden until a different submenu is opened -->
+ <showIcons>yes</showIcons>
+ <!-- controls if icons appear in the client-list-(combined-)menu -->
+ <manageDesktops>yes</manageDesktops>
+ <!-- show the manage desktops section in the client-list-(combined-)menu -->
+ </menu>
+ <applications>
+ <application class="*">
+ <decor>no</decor>
+ </application>
+ <!--
+ # this is an example with comments through out. use these to make your
+ # own rules, but without the comments of course.
+ # you may use one or more of the name/class/role/title/type rules to specify
+ # windows to match
+
+ <application name="the window's _OB_APP_NAME property (see obxprop)"
+ class="the window's _OB_APP_CLASS property (see obxprop)"
+ groupname="the window's _OB_APP_GROUP_NAME property (see obxprop)"
+ groupclass="the window's _OB_APP_GROUP_CLASS property (see obxprop)"
+ role="the window's _OB_APP_ROLE property (see obxprop)"
+ title="the window's _OB_APP_TITLE property (see obxprop)"
+ type="the window's _OB_APP_TYPE property (see obxprob)..
+ (if unspecified, then it is 'dialog' for child windows)">
+ # you may set only one of name/class/role/title/type, or you may use more
+ # than one together to restrict your matches.
+
+ # the name, class, role, and title use simple wildcard matching such as those
+ # used by a shell. you can use * to match any characters and ? to match
+ # any single character.
+
+ # the type is one of: normal, dialog, splash, utility, menu, toolbar, dock,
+ # or desktop
+
+ # when multiple rules match a window, they will all be applied, in the
+ # order that they appear in this list
+
+
+ # each rule element can be left out or set to 'default' to specify to not
+ # change that attribute of the window
+
+ <decor>yes</decor>
+ # enable or disable window decorations
+
+ <shade>no</shade>
+ # make the window shaded when it appears, or not
+
+ <position force="no">
+ # the position is only used if both an x and y coordinate are provided
+ # (and not set to 'default')
+ # when force is "yes", then the window will be placed here even if it
+ # says you want it placed elsewhere. this is to override buggy
+ # applications who refuse to behave
+ <x>center</x>
+ # a number like 50, or 'center' to center on screen. use a negative number
+ # to start from the right (or bottom for <y>), ie -50 is 50 pixels from
+ # the right edge (or bottom). use 'default' to specify using value
+ # provided by the application, or chosen by openbox, instead.
+ <y>200</y>
+ <monitor>1</monitor>
+ # specifies the monitor in a xinerama setup.
+ # 1 is the first head, or 'mouse' for wherever the mouse is
+ </position>
+
+ <size>
+ # the size to make the window.
+ <width>20</width>
+ # a number like 20, or 'default' to use the size given by the application.
+ # you can use fractions such as 1/2 or percentages such as 75% in which
+ # case the value is relative to the size of the monitor that the window
+ # appears on.
+ <height>30%</height>
+ </size>
+
+ <focus>yes</focus>
+ # if the window should try be given focus when it appears. if this is set
+ # to yes it doesn't guarantee the window will be given focus. some
+ # restrictions may apply, but Openbox will try to
+
+ <desktop>1</desktop>
+ # 1 is the first desktop, 'all' for all desktops
+
+ <layer>normal</layer>
+ # 'above', 'normal', or 'below'
+
+ <iconic>no</iconic>
+ # make the window iconified when it appears, or not
+
+ <skip_pager>no</skip_pager>
+ # asks to not be shown in pagers
+
+ <skip_taskbar>no</skip_taskbar>
+ # asks to not be shown in taskbars. window cycling actions will also
+ # skip past such windows
+
+ <fullscreen>yes</fullscreen>
+ # make the window in fullscreen mode when it appears
+
+ <maximized>true</maximized>
+ # 'Horizontal', 'Vertical' or boolean (yes/no)
+ </application>
+
+ # end of the example
+-->
+ </applications>
+</openbox_config>
diff --git a/openbox/laptop/autostart b/openbox/laptop/autostart
new file mode 100755
index 0000000..dd7e974
--- /dev/null
+++ b/openbox/laptop/autostart
@@ -0,0 +1,27 @@
+#
+# These things are run when an Openbox X Session is started.
+# You may place a similar script in $HOME/.config/openbox/autostart
+# to run user-specific things.
+#
+
+# If you want to use GNOME config tools...
+#
+#if test -x /usr/lib/x86_64-linux-gnu/gnome-settings-daemon >/dev/null; then
+# /usr/lib/x86_64-linux-gnu/gnome-settings-daemon &
+#elif which gnome-settings-daemon >/dev/null 2>&1; then
+# gnome-settings-daemon &
+#fi
+
+# If you want to use XFCE config tools...
+#
+#xfce-mcs-manager &
+nitrogen --restore
+tint2 &
+/home/swatson/.config/lemonbar/startLemon.sh &
+nm-applet &
+#compton -b &
+dunst &
+expressvpn connect &
+# Enable mousepad while typing
+xinput set-prop 12 318 0
+xinput set-prop 12 287 0
diff --git a/openbox/laptop/environment b/openbox/laptop/environment
new file mode 100755
index 0000000..3311bd6
--- /dev/null
+++ b/openbox/laptop/environment
@@ -0,0 +1,10 @@
+#
+# Set system-wide environment variables here for Openbox
+# User-specific variables should be placed in $HOME/.config/openbox/environment
+#
+
+# To set your language for displaying messages and time/date formats, use the following:
+#LANG=en_CA.UTF8
+
+# To set your keyboard layout, you need to modify your X config:
+# http://www.google.com/search?q=how+to+set+keyboard+layout+xorg
diff --git a/openbox/laptop/menu.xml b/openbox/laptop/menu.xml
new file mode 100644
index 0000000..b3cf8bf
--- /dev/null
+++ b/openbox/laptop/menu.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/ file:///usr/share/openbox/menu.xsd">
+ <menu id="root-menu" label="Openbox 3">
+ <item label="Terminal emulator">
+ <action name="Execute">
+ <execute>urxvt</execute>
+ </action>
+ </item>
+ <item label="Web browser">
+ <action name="Execute">
+ <execute>x-www-browser</execute>
+ </action>
+ </item>
+ <!-- This requires the presence of the 'openbox-menu' package to work -->
+ <separator/>
+ <menu execute="/usr/bin/obamenu" id="applications-menu" label="Applications"/>
+ <separator/>
+ <item label="ObConf">
+ <action name="Execute">
+ <execute>obconf</execute>
+ </action>
+ </item>
+ <item label="Reconfigure">
+ <action name="Reconfigure"/>
+ </item>
+ <item label="Restart">
+ <action name="Restart"/>
+ </item>
+ <separator/>
+ <item label="Exit">
+ <action name="Exit"/>
+ </item>
+ </menu>
+</openbox_menu>
diff --git a/openbox/laptop/rc.xml b/openbox/laptop/rc.xml
new file mode 100644
index 0000000..d8ee5a0
--- /dev/null
+++ b/openbox/laptop/rc.xml
@@ -0,0 +1,832 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Do not edit this file, it will be overwritten on install.
+ Copy the file to $HOME/.config/openbox/ instead. -->
+<openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <resistance>
+ <strength>10</strength>
+ <screen_edge_strength>20</screen_edge_strength>
+ </resistance>
+ <focus>
+ <focusNew>yes</focusNew>
+ <!-- always try to focus new windows when they appear. other rules do
+ apply -->
+ <followMouse>yes</followMouse>
+ <!-- move focus to a window when you move the mouse into it -->
+ <focusLast>yes</focusLast>
+ <!-- focus the last used window when changing desktops, instead of the one
+ under the mouse pointer. when followMouse is enabled -->
+ <underMouse>no</underMouse>
+ <!-- move focus under the mouse, even when the mouse is not moving -->
+ <focusDelay>200</focusDelay>
+ <!-- when followMouse is enabled, the mouse must be inside the window for
+ this many milliseconds (1000 = 1 sec) before moving focus to it -->
+ <raiseOnFocus>no</raiseOnFocus>
+ <!-- when followMouse is enabled, and a window is given focus by moving the
+ mouse into it, also raise the window -->
+ </focus>
+ <placement>
+ <policy>Smart</policy>
+ <!-- 'Smart' or 'UnderMouse' -->
+ <center>yes</center>
+ <!-- whether to place windows in the center of the free area found or
+ the top left corner -->
+ <monitor>Primary</monitor>
+ <!-- with Smart placement on a multi-monitor system, try to place new windows
+ on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where
+ the active window is, 'Primary' - only on the primary monitor -->
+ <primaryMonitor>1</primaryMonitor>
+ <!-- The monitor where Openbox should place popup dialogs such as the
+ focus cycling popup, or the desktop switch popup. It can be an index
+ from 1, specifying a particular monitor. Or it can be one of the
+ following: 'Mouse' - where the mouse is, or
+ 'Active' - where the active window is -->
+ </placement>
+ <theme>
+ <name>Clearlooks</name>
+ <titleLayout>NLIMC</titleLayout>
+ <!--
+ available characters are NDSLIMC, each can occur at most once.
+ N: window icon
+ L: window label (AKA title).
+ I: iconify
+ M: maximize
+ C: close
+ S: shade (roll up/down)
+ D: omnipresent (on all desktops).
+ -->
+ <keepBorder>yes</keepBorder>
+ <animateIconify>yes</animateIconify>
+ <font place="ActiveWindow">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Bold</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="InactiveWindow">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Bold</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="MenuHeader">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Normal</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="MenuItem">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Normal</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="ActiveOnScreenDisplay">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Bold</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ <font place="InactiveOnScreenDisplay">
+ <name>sans</name>
+ <size>12</size>
+ <!-- font size in points -->
+ <weight>Bold</weight>
+ <!-- 'bold' or 'normal' -->
+ <slant>Normal</slant>
+ <!-- 'italic' or 'normal' -->
+ </font>
+ </theme>
+ <desktops>
+ <!-- this stuff is only used at startup, pagers allow you to change them
+ during a session
+
+ these are default values to use when other ones are not already set
+ by other applications, or saved in your session
+
+ use obconf if you want to change these without having to log out
+ and back in -->
+ <number>4</number>
+ <firstdesk>1</firstdesk>
+ <names>
+ <!-- set names up here if you want to, like this:
+ <name>desktop 1</name>
+ <name>desktop 2</name>
+ -->
+ </names>
+ <popupTime>875</popupTime>
+ <!-- The number of milliseconds to show the popup for when switching
+ desktops. Set this to 0 to disable the popup. -->
+ </desktops>
+ <resize>
+ <drawContents>yes</drawContents>
+ <popupShow>Nonpixel</popupShow>
+ <!-- 'Always', 'Never', or 'Nonpixel' (xterms and such) -->
+ <popupPosition>Center</popupPosition>
+ <!-- 'Center', 'Top', or 'Fixed' -->
+ <popupFixedPosition>
+ <!-- these are used if popupPosition is set to 'Fixed' -->
+ <x>10</x>
+ <!-- positive number for distance from left edge, negative number for
+ distance from right edge, or 'Center' -->
+ <y>10</y>
+ <!-- positive number for distance from top edge, negative number for
+ distance from bottom edge, or 'Center' -->
+ </popupFixedPosition>
+ </resize>
+ <!-- You can reserve a portion of your screen where windows will not cover when
+ they are maximized, or when they are initially placed.
+ Many programs reserve space automatically, but you can use this in other
+ cases. -->
+ <margins>
+ <top>0</top>
+ <bottom>0</bottom>
+ <left>0</left>
+ <right>0</right>
+ </margins>
+ <dock>
+ <position>BottomRight</position>
+ <!-- (Top|Bottom)(Left|Right|)|Top|Bottom|Left|Right|Floating -->
+ <floatingX>0</floatingX>
+ <floatingY>0</floatingY>
+ <noStrut>no</noStrut>
+ <stacking>Above</stacking>
+ <!-- 'Above', 'Normal', or 'Below' -->
+ <direction>Horizontal</direction>
+ <!-- 'Vertical' or 'Horizontal' -->
+ <autoHide>no</autoHide>
+ <hideDelay>300</hideDelay>
+ <!-- in milliseconds (1000 = 1 second) -->
+ <showDelay>300</showDelay>
+ <!-- in milliseconds (1000 = 1 second) -->
+ <moveButton>Middle</moveButton>
+ <!-- 'Left', 'Middle', 'Right' -->
+ </dock>
+ <keyboard>
+ <chainQuitKey>C-g</chainQuitKey>
+ <!-- Keybindings for desktop switching -->
+ <keybind key="C-A-Left">
+ <action name="GoToDesktop">
+ <to>left</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="C-A-Right">
+ <action name="GoToDesktop">
+ <to>right</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="C-A-Up">
+ <action name="GoToDesktop">
+ <to>up</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="C-A-Down">
+ <action name="GoToDesktop">
+ <to>down</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="S-A-Left">
+ <action name="SendToDesktop">
+ <to>left</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="S-A-Right">
+ <action name="SendToDesktop">
+ <to>right</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="S-A-Up">
+ <action name="SendToDesktop">
+ <to>up</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="S-A-Down">
+ <action name="SendToDesktop">
+ <to>down</to>
+ <wrap>no</wrap>
+ </action>
+ </keybind>
+ <keybind key="W-F1">
+ <action name="GoToDesktop">
+ <to>1</to>
+ </action>
+ </keybind>
+ <keybind key="W-F2">
+ <action name="GoToDesktop">
+ <to>2</to>
+ </action>
+ </keybind>
+ <keybind key="W-F3">
+ <action name="GoToDesktop">
+ <to>3</to>
+ </action>
+ </keybind>
+ <keybind key="W-F4">
+ <action name="GoToDesktop">
+ <to>4</to>
+ </action>
+ </keybind>
+ <keybind key="W-e">
+ <action name="ToggleShowDesktop"/>
+ </keybind>
+ <!-- Keybindings for windows -->
+ <keybind key="W-S-q">
+ <action name="Close"/>
+ </keybind>
+ <keybind key="A-Escape">
+ <action name="Lower"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ </keybind>
+ <keybind key="A-space">
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </keybind>
+ <!-- Take a screenshot of the current window with scrot when Alt+Print are pressed -->
+ <keybind key="A-Print">
+ <action name="Execute">
+ <command>scrot -s</command>
+ </action>
+ </keybind>
+ <!-- Keybindings for window switching -->
+ <keybind key="A-Tab">
+ <action name="NextWindow">
+ <finalactions>
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </finalactions>
+ </action>
+ </keybind>
+ <keybind key="A-S-Tab">
+ <action name="PreviousWindow">
+ <finalactions>
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </finalactions>
+ </action>
+ </keybind>
+ <keybind key="C-A-Tab">
+ <action name="NextWindow">
+ <panels>yes</panels>
+ <desktop>yes</desktop>
+ <finalactions>
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </finalactions>
+ </action>
+ </keybind>
+ <!-- Keybindings for window switching with the arrow keys -->
+ <keybind key="W-S-Right">
+ <action name="DirectionalCycleWindows">
+ <direction>right</direction>
+ </action>
+ </keybind>
+ <keybind key="W-S-Left">
+ <action name="DirectionalCycleWindows">
+ <direction>left</direction>
+ </action>
+ </keybind>
+ <keybind key="W-S-Up">
+ <action name="DirectionalCycleWindows">
+ <direction>up</direction>
+ </action>
+ </keybind>
+ <keybind key="W-S-Down">
+ <action name="DirectionalCycleWindows">
+ <direction>down</direction>
+ </action>
+ </keybind>
+ <!-- Keybindings for running applications -->
+ <keybind key="W-d">
+ <action name="Execute">
+ <command>rofi -show run</command>
+ </action>
+ </keybind>
+ <keybind key="W-S-d">
+ <action name="Execute">
+ <command>rofi -show window</command>
+ </action>
+ </keybind>
+ <keybind key="W-Return">
+ <action name="Execute">
+ <command>urxvt</command>
+ </action>
+ </keybind>
+ <keybind key="XF86AudioRaiseVolume">
+ <action name="Execute">
+ <command>amixer -q set Master 2dB+ unmute</command>
+ </action>
+ </keybind>
+ <keybind key="XF86AudioLowerVolume">
+ <action name="Execute">
+ <command>amixer -q set Master 2dB- unmute</command>
+ </action>
+ </keybind>
+ <keybind key="XF86AudioMute">
+ <action name="Execute">
+ <command>amixer -q set Speaker toggle; amixer -q set Master toggle</command>
+ </action>
+ </keybind>
+ <keybind key="XF86MonBrightnessUp">
+ <action name="Execute">
+ <command>sudo light -A 10</command>
+ </action>
+ </keybind>
+ <keybind key="XF86MonBrightnessDown">
+ <action name="Execute">
+ <command>sudo light -U 10</command>
+ </action>
+ </keybind>
+ <!-- Launch scrot when Print is pressed -->
+ <keybind key="Print">
+ <action name="Execute">
+ <command>scrot</command>
+ </action>
+ </keybind>
+ </keyboard>
+ <mouse>
+ <dragThreshold>1</dragThreshold>
+ <!-- number of pixels the mouse must move before a drag begins -->
+ <doubleClickTime>500</doubleClickTime>
+ <!-- in milliseconds (1000 = 1 second) -->
+ <screenEdgeWarpTime>400</screenEdgeWarpTime>
+ <!-- Time before changing desktops when the pointer touches the edge of the
+ screen while moving a window, in milliseconds (1000 = 1 second).
+ Set this to 0 to disable warping -->
+ <screenEdgeWarpMouse>false</screenEdgeWarpMouse>
+ <!-- Set this to TRUE to move the mouse pointer across the desktop when
+ switching due to hitting the edge of the screen -->
+ <context name="Frame">
+ <mousebind button="A-Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="A-Left" action="Click">
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="W-Left" action="Drag">
+ <action name="Move"/>
+ </mousebind>
+ <mousebind button="A-Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="W-Right" action="Drag">
+ <action name="Resize"/>
+ </mousebind>
+ <mousebind button="A-Middle" action="Press">
+ <action name="Lower"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ </mousebind>
+ <mousebind button="A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="C-A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="C-A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-S-Up" action="Click">
+ <action name="SendToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-S-Down" action="Click">
+ <action name="SendToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Titlebar">
+ <mousebind button="Left" action="Drag">
+ <action name="Move"/>
+ </mousebind>
+ <mousebind button="Left" action="DoubleClick">
+ <action name="ToggleMaximize"/>
+ </mousebind>
+ <mousebind button="Up" action="Click">
+ <action name="if">
+ <shaded>no</shaded>
+ <then>
+ <action name="Shade"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ <action name="Lower"/>
+ </then>
+ </action>
+ </mousebind>
+ <mousebind button="Down" action="Click">
+ <action name="if">
+ <shaded>yes</shaded>
+ <then>
+ <action name="Unshade"/>
+ <action name="Raise"/>
+ </then>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Titlebar Top Right Bottom Left TLCorner TRCorner BRCorner BLCorner">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Middle" action="Press">
+ <action name="Lower"/>
+ <action name="FocusToBottom"/>
+ <action name="Unfocus"/>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Top">
+ <mousebind button="Left" action="Drag">
+ <action name="Resize">
+ <edge>top</edge>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Left">
+ <mousebind button="Left" action="Drag">
+ <action name="Resize">
+ <edge>left</edge>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Right">
+ <mousebind button="Left" action="Drag">
+ <action name="Resize">
+ <edge>right</edge>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Bottom">
+ <mousebind button="Left" action="Drag">
+ <action name="Resize">
+ <edge>bottom</edge>
+ </action>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </mousebind>
+ </context>
+ <context name="TRCorner BRCorner TLCorner BLCorner">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Left" action="Drag">
+ <action name="Resize"/>
+ </mousebind>
+ </context>
+ <context name="Client">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Middle" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ </context>
+ <context name="Icon">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="ShowMenu">
+ <menu>client-menu</menu>
+ </action>
+ </mousebind>
+ </context>
+ <context name="AllDesktops">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="ToggleOmnipresent"/>
+ </mousebind>
+ </context>
+ <context name="Shade">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="ToggleShade"/>
+ </mousebind>
+ </context>
+ <context name="Iconify">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="Iconify"/>
+ </mousebind>
+ </context>
+ <context name="Maximize">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Middle" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="ToggleMaximize"/>
+ </mousebind>
+ <mousebind button="Middle" action="Click">
+ <action name="ToggleMaximize">
+ <direction>vertical</direction>
+ </action>
+ </mousebind>
+ <mousebind button="Right" action="Click">
+ <action name="ToggleMaximize">
+ <direction>horizontal</direction>
+ </action>
+ </mousebind>
+ </context>
+ <context name="Close">
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ <action name="Unshade"/>
+ </mousebind>
+ <mousebind button="Left" action="Click">
+ <action name="Close"/>
+ </mousebind>
+ </context>
+ <context name="Desktop">
+ <mousebind button="Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="C-A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="C-A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="Left" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="Focus"/>
+ <action name="Raise"/>
+ </mousebind>
+ </context>
+ <context name="Root">
+ <!-- Menus -->
+ <mousebind button="Middle" action="Press">
+ <action name="ShowMenu">
+ <menu>client-list-combined-menu</menu>
+ </action>
+ </mousebind>
+ <mousebind button="Right" action="Press">
+ <action name="ShowMenu">
+ <menu>root-menu</menu>
+ </action>
+ </mousebind>
+ </context>
+ <context name="MoveResize">
+ <mousebind button="Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Up" action="Click">
+ <action name="GoToDesktop">
+ <to>previous</to>
+ </action>
+ </mousebind>
+ <mousebind button="A-Down" action="Click">
+ <action name="GoToDesktop">
+ <to>next</to>
+ </action>
+ </mousebind>
+ </context>
+ </mouse>
+ <menu>
+ <!-- You can specify more than one menu file in here and they are all loaded,
+ just don't make menu ids clash or, well, it'll be kind of pointless -->
+ <!-- default menu file (or custom one in $HOME/.config/openbox/) -->
+ <!-- system menu files on Debian systems -->
+ <file>/var/lib/openbox/debian-menu.xml</file>
+ <file>menu.xml</file>
+ <hideDelay>200</hideDelay>
+ <!-- if a press-release lasts longer than this setting (in milliseconds), the
+ menu is hidden again -->
+ <middle>no</middle>
+ <!-- center submenus vertically about the parent entry -->
+ <submenuShowDelay>100</submenuShowDelay>
+ <!-- time to delay before showing a submenu after hovering over the parent
+ entry.
+ if this is a negative value, then the delay is infinite and the
+ submenu will not be shown until it is clicked on -->
+ <submenuHideDelay>400</submenuHideDelay>
+ <!-- time to delay before hiding a submenu when selecting another
+ entry in parent menu
+ if this is a negative value, then the delay is infinite and the
+ submenu will not be hidden until a different submenu is opened -->
+ <showIcons>yes</showIcons>
+ <!-- controls if icons appear in the client-list-(combined-)menu -->
+ <manageDesktops>yes</manageDesktops>
+ <!-- show the manage desktops section in the client-list-(combined-)menu -->
+ </menu>
+ <applications>
+ <application class="*">
+ <decor>no</decor>
+ </application>
+ <!--
+ # this is an example with comments through out. use these to make your
+ # own rules, but without the comments of course.
+ # you may use one or more of the name/class/role/title/type rules to specify
+ # windows to match
+
+ <application name="the window's _OB_APP_NAME property (see obxprop)"
+ class="the window's _OB_APP_CLASS property (see obxprop)"
+ groupname="the window's _OB_APP_GROUP_NAME property (see obxprop)"
+ groupclass="the window's _OB_APP_GROUP_CLASS property (see obxprop)"
+ role="the window's _OB_APP_ROLE property (see obxprop)"
+ title="the window's _OB_APP_TITLE property (see obxprop)"
+ type="the window's _OB_APP_TYPE property (see obxprob)..
+ (if unspecified, then it is 'dialog' for child windows)">
+ # you may set only one of name/class/role/title/type, or you may use more
+ # than one together to restrict your matches.
+
+ # the name, class, role, and title use simple wildcard matching such as those
+ # used by a shell. you can use * to match any characters and ? to match
+ # any single character.
+
+ # the type is one of: normal, dialog, splash, utility, menu, toolbar, dock,
+ # or desktop
+
+ # when multiple rules match a window, they will all be applied, in the
+ # order that they appear in this list
+
+
+ # each rule element can be left out or set to 'default' to specify to not
+ # change that attribute of the window
+
+ <decor>yes</decor>
+ # enable or disable window decorations
+
+ <shade>no</shade>
+ # make the window shaded when it appears, or not
+
+ <position force="no">
+ # the position is only used if both an x and y coordinate are provided
+ # (and not set to 'default')
+ # when force is "yes", then the window will be placed here even if it
+ # says you want it placed elsewhere. this is to override buggy
+ # applications who refuse to behave
+ <x>center</x>
+ # a number like 50, or 'center' to center on screen. use a negative number
+ # to start from the right (or bottom for <y>), ie -50 is 50 pixels from
+ # the right edge (or bottom). use 'default' to specify using value
+ # provided by the application, or chosen by openbox, instead.
+ <y>200</y>
+ <monitor>1</monitor>
+ # specifies the monitor in a xinerama setup.
+ # 1 is the first head, or 'mouse' for wherever the mouse is
+ </position>
+
+ <size>
+ # the size to make the window.
+ <width>20</width>
+ # a number like 20, or 'default' to use the size given by the application.
+ # you can use fractions such as 1/2 or percentages such as 75% in which
+ # case the value is relative to the size of the monitor that the window
+ # appears on.
+ <height>30%</height>
+ </size>
+
+ <focus>yes</focus>
+ # if the window should try be given focus when it appears. if this is set
+ # to yes it doesn't guarantee the window will be given focus. some
+ # restrictions may apply, but Openbox will try to
+
+ <desktop>1</desktop>
+ # 1 is the first desktop, 'all' for all desktops
+
+ <layer>normal</layer>
+ # 'above', 'normal', or 'below'
+
+ <iconic>no</iconic>
+ # make the window iconified when it appears, or not
+
+ <skip_pager>no</skip_pager>
+ # asks to not be shown in pagers
+
+ <skip_taskbar>no</skip_taskbar>
+ # asks to not be shown in taskbars. window cycling actions will also
+ # skip past such windows
+
+ <fullscreen>yes</fullscreen>
+ # make the window in fullscreen mode when it appears
+
+ <maximized>true</maximized>
+ # 'Horizontal', 'Vertical' or boolean (yes/no)
+ </application>
+
+ # end of the example
+-->
+ </applications>
+</openbox_config>
diff --git a/osd/osd-display.sh b/osd/osd-display.sh
new file mode 100755
index 0000000..68628ea
--- /dev/null
+++ b/osd/osd-display.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+./osd-game.sh | osd_cat -p bottom -c green -O 1 -l 1
diff --git a/osd/osd-game.sh b/osd/osd-game.sh
new file mode 100755
index 0000000..4d133c6
--- /dev/null
+++ b/osd/osd-game.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+cpuTemp() {
+
+ CPUTEMP=$(sensors | grep CPU | awk '{print $2}' | grep -o [0-9][0-9]||[0-9][0-9][0-9])
+ CPUFREQ=$(lscpu | grep MHz | head -n1 | awk '{print $3}')
+
+ echo -n "CPU Temp: $CPUTEMP° > CPU Freq: $CPUFREQ"
+
+}
+
+loadAvg() {
+
+ la=$(uptime | grep -o :\ [0-9].* | sed s/://g | awk '{print $1}' | sed s/,//g)
+ echo -n "Load: $la"
+
+}
+
+while true; do
+ echo -ne "$(cpuTemp) $(loadAvg)\n"
+ sleep 1
+done
diff --git a/rofi/config b/rofi/config
new file mode 100644
index 0000000..2128029
--- /dev/null
+++ b/rofi/config
@@ -0,0 +1 @@
+rofi.theme: ~/.cache/wal/colors-rofi-dark.rasi
diff --git a/rofi/rofiCmd.txt b/rofi/rofiCmd.txt
new file mode 100644
index 0000000..59605ef
--- /dev/null
+++ b/rofi/rofiCmd.txt
@@ -0,0 +1 @@
+#rofi -key-run mod4+d -key-ssh mod4+shift+x -key-window mod4+shift+w -quiet -terminal urxvt
diff --git a/sentraq-fw/keymap.c b/sentraq-fw/keymap.c
new file mode 100644
index 0000000..072a49e
--- /dev/null
+++ b/sentraq-fw/keymap.c
@@ -0,0 +1,20 @@
+#include QMK_KEYBOARD_H
+enum custom_keycodes {
+ TEST,
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case TEST:
+ if (record->event.pressed) {
+ SEND_STRING("TEST STRING");
+ }
+ break;
+ }
+ return true;
+};
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+ [0] = LAYOUT_60_ansi(KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_CAPS, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(1), KC_APP, KC_RCTL),
+ [1] = LAYOUT_60_ansi(KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_TRNS, KC_HOME, KC_UP, KC_END, LGUI(KC_D), TEST, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_PSCR, KC_SLCK, KC_PAUS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, BL_BRTG, BL_TOGG, BL_INC, BL_DEC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RESET)
+};
diff --git a/sentraq-fw/notes.txt b/sentraq-fw/notes.txt
new file mode 100644
index 0000000..cf49bf1
--- /dev/null
+++ b/sentraq-fw/notes.txt
@@ -0,0 +1,6 @@
+https://config.qmk.fm
+
+use dfu-programmer:
+sudo dfu-programmer atmega32u4 erase
+sudo dfu-programmer atmega32u4 flash $path_to_hex
+sudo dfu-programmer reset
diff --git a/terms/st/st-0.8.2/FAQ b/terms/st/st-0.8.2/FAQ
new file mode 100644
index 0000000..921c493
--- /dev/null
+++ b/terms/st/st-0.8.2/FAQ
@@ -0,0 +1,167 @@
+## Why does st not handle utmp entries?
+
+Use the excellent tool of [utmp](http://git.suckless.org/utmp/) for this task.
+
+## Some _random program_ complains that st is unknown/not recognised/unsupported/whatever!
+
+It means that st doesn’t have any terminfo entry on your system. Chances are
+you did not `make install`. If you just want to test it without installing it,
+you can manually run `tic -sx st.info`.
+
+## Nothing works, and nothing is said about an unknown terminal!
+
+* Some programs just assume they’re running in xterm i.e. they don’t rely on
+ terminfo. What you see is the current state of the “xterm compliance”.
+* Some programs don’t complain about the lacking st description and default to
+ another terminal. In that case see the question about terminfo.
+
+## I get some weird glitches/visual bug on _random program_!
+
+Try launching it with a different TERM: $ TERM=xterm myapp. toe(1) will give
+you a list of available terminals, but you’ll most likely switch between xterm,
+st or st-256color. The default value for TERM can be changed in config.h
+(TNAME).
+
+## How do I scroll back up?
+
+Using a terminal multiplexer.
+
+* `st -e tmux` using C-b [
+* `st -e screen` using C-a ESC
+
+## Why doesn't the Del key work in some programs?
+
+Taken from the terminfo manpage:
+
+ If the terminal has a keypad that transmits codes when the keys
+ are pressed, this information can be given. Note that it is not
+ possible to handle terminals where the keypad only works in
+ local (this applies, for example, to the unshifted HP 2621 keys).
+ If the keypad can be set to transmit or not transmit, give these
+ codes as smkx and rmkx. Otherwise the keypad is assumed to
+ always transmit.
+
+In the st case smkx=E[?1hE= and rmkx=E[?1lE>, so it is mandatory that
+applications which want to test against keypad keys send these
+sequences.
+
+But buggy applications (like bash and irssi, for example) don't do this. A fast
+solution for them is to use the following command:
+
+ $ printf '\033[?1h\033=' >/dev/tty
+
+or
+ $ tput smkx
+
+In the case of bash, readline is used. Readline has a different note in its
+manpage about this issue:
+
+ enable-keypad (Off)
+ When set to On, readline will try to enable the
+ application keypad when it is called. Some systems
+ need this to enable arrow keys.
+
+Adding this option to your .inputrc will fix the keypad problem for all
+applications using readline.
+
+If you are using zsh, then read the zsh FAQ
+<http://zsh.sourceforge.net/FAQ/zshfaq03.html#l25>:
+
+ It should be noted that the O / [ confusion can occur with other keys
+ such as Home and End. Some systems let you query the key sequences
+ sent by these keys from the system's terminal database, terminfo.
+ Unfortunately, the key sequences given there typically apply to the
+ mode that is not the one zsh uses by default (it's the "application"
+ mode rather than the "raw" mode). Explaining the use of terminfo is
+ outside of the scope of this FAQ, but if you wish to use the key
+ sequences given there you can tell the line editor to turn on
+ "application" mode when it starts and turn it off when it stops:
+
+ function zle-line-init () { echoti smkx }
+ function zle-line-finish () { echoti rmkx }
+ zle -N zle-line-init
+ zle -N zle-line-finish
+
+Putting these lines into your .zshrc will fix the problems.
+
+## How can I use meta in 8bit mode?
+
+St supports meta in 8bit mode, but the default terminfo entry doesn't
+use this capability. If you want it, you have to use the 'st-meta' value
+in TERM.
+
+## I cannot compile st in OpenBSD
+
+OpenBSD lacks librt, despite it being mandatory in POSIX
+<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/c99.html#tag_20_11_13>.
+If you want to compile st for OpenBSD you have to remove -lrt from config.mk, and
+st will compile without any loss of functionality, because all the functions are
+included in libc on this platform.
+
+## The Backspace Case
+
+St is emulating the Linux way of handling backspace being delete and delete being
+backspace.
+
+This is an issue that was discussed in suckless mailing list
+<http://lists.suckless.org/dev/1404/20697.html>. Here is why some old grumpy
+terminal users wants its backspace to be how he feels it:
+
+ Well, I am going to comment why I want to change the behaviour
+ of this key. When ASCII was defined in 1968, communication
+ with computers was done using punched cards, or hardcopy
+ terminals (basically a typewriter machine connected with the
+ computer using a serial port). ASCII defines DELETE as 7F,
+ because, in punched-card terms, it means all the holes of the
+ card punched; it is thus a kind of 'physical delete'. In the
+ same way, the BACKSPACE key was a non-destructive backspace,
+ as on a typewriter. So, if you wanted to delete a character,
+ you had to BACKSPACE and then DELETE. Another use of BACKSPACE
+ was to type accented characters, for example 'a BACKSPACE `'.
+ The VT100 had no BACKSPACE key; it was generated using the
+ CONTROL key as another control character (CONTROL key sets to
+ 0 b7 b6 b5, so it converts H (code 0x48) into BACKSPACE (code
+ 0x08)), but it had a DELETE key in a similar position where
+ the BACKSPACE key is located today on common PC keyboards.
+ All the terminal emulators emulated the difference between
+ these keys correctly: the backspace key generated a BACKSPACE
+ (^H) and delete key generated a DELETE (^?).
+
+ But a problem arose when Linus Torvalds wrote Linux. Unlike
+ earlier terminals, the Linux virtual terminal (the terminal
+ emulator integrated in the kernel) returned a DELETE when
+ backspace was pressed, due to the VT100 having a DELETE key in
+ the same position. This created a lot of problems (see [1]
+ and [2]). Since Linux has become the king, a lot of terminal
+ emulators today generate a DELETE when the backspace key is
+ pressed in order to avoid problems with Linux. The result is
+ that the only way of generating a BACKSPACE on these systems
+ is by using CONTROL + H. (I also think that emacs had an
+ important point here because the CONTROL + H prefix is used
+ in emacs in some commands (help commands).)
+
+ From point of view of the kernel, you can change the key
+ for deleting a previous character with stty erase. When you
+ connect a real terminal into a machine you describe the type
+ of terminal, so getty configures the correct value of stty
+ erase for this terminal. In the case of terminal emulators,
+ however, you don't have any getty that can set the correct
+ value of stty erase, so you always get the default value.
+ For this reason, it is necessary to add 'stty erase ^H' to your
+ profile if you have changed the value of the backspace key.
+ Of course, another solution is for st itself to modify the
+ value of stty erase. I usually have the inverse problem:
+ when I connect to non-Unix machines, I have to press CONTROL +
+ h to get a BACKSPACE. The inverse problem occurs when a user
+ connects to my Unix machines from a different system with a
+ correct backspace key.
+
+ [1] http://www.ibb.net/~anne/keyboard.html
+ [2] http://www.tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html
+
+## But I really want the old grumpy behaviour of my terminal
+
+Apply [1].
+
+[1] http://st.suckless.org/patches/delkey
+
diff --git a/terms/st/st-0.8.2/LEGACY b/terms/st/st-0.8.2/LEGACY
new file mode 100644
index 0000000..bf28b1e
--- /dev/null
+++ b/terms/st/st-0.8.2/LEGACY
@@ -0,0 +1,17 @@
+A STATEMENT ON LEGACY SUPPORT
+
+In the terminal world there is much cruft that comes from old and unsup‐
+ported terminals that inherit incompatible modes and escape sequences
+which noone is able to know, except when he/she comes from that time and
+developed a graphical vt100 emulator at that time.
+
+One goal of st is to only support what is really needed. When you en‐
+counter a sequence which you really need, implement it. But while you
+are at it, do not add the other cruft you might encounter while sneek‐
+ing at other terminal emulators. History has bloated them and there is
+no real evidence that most of the sequences are used today.
+
+
+Christoph Lohmann <20h@r-36.net>
+2012-09-13T07:00:36.081271045+02:00
+
diff --git a/terms/st/st-0.8.2/LICENSE b/terms/st/st-0.8.2/LICENSE
new file mode 100644
index 0000000..c356c39
--- /dev/null
+++ b/terms/st/st-0.8.2/LICENSE
@@ -0,0 +1,34 @@
+MIT/X Consortium License
+
+© 2014-2018 Hiltjo Posthuma <hiltjo at codemadness dot org>
+© 2018 Devin J. Pohly <djpohly at gmail dot com>
+© 2014-2017 Quentin Rameau <quinq at fifth dot space>
+© 2009-2012 Aurélien APTEL <aurelien dot aptel at gmail dot com>
+© 2008-2017 Anselm R Garbe <garbeam at gmail dot com>
+© 2012-2017 Roberto E. Vargas Caballero <k0ga at shike2 dot com>
+© 2012-2016 Christoph Lohmann <20h at r-36 dot net>
+© 2013 Eon S. Jeon <esjeon at hyunmu dot am>
+© 2013 Alexander Sedov <alex0player at gmail dot com>
+© 2013 Mark Edgar <medgar123 at gmail dot com>
+© 2013-2014 Eric Pruitt <eric.pruitt at gmail dot com>
+© 2013 Michael Forney <mforney at mforney dot org>
+© 2013-2014 Markus Teich <markus dot teich at stusta dot mhn dot de>
+© 2014-2015 Laslo Hunhold <dev at frign dot de>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
diff --git a/terms/st/st-0.8.2/Makefile b/terms/st/st-0.8.2/Makefile
new file mode 100644
index 0000000..470ac86
--- /dev/null
+++ b/terms/st/st-0.8.2/Makefile
@@ -0,0 +1,57 @@
+# st - simple terminal
+# See LICENSE file for copyright and license details.
+.POSIX:
+
+include config.mk
+
+SRC = st.c x.c
+OBJ = $(SRC:.c=.o)
+
+all: options st
+
+options:
+ @echo st build options:
+ @echo "CFLAGS = $(STCFLAGS)"
+ @echo "LDFLAGS = $(STLDFLAGS)"
+ @echo "CC = $(CC)"
+
+config.h:
+ cp config.def.h config.h
+
+.c.o:
+ $(CC) $(STCFLAGS) -c $<
+
+st.o: config.h st.h win.h
+x.o: arg.h config.h st.h win.h
+
+$(OBJ): config.h config.mk
+
+st: $(OBJ)
+ $(CC) -o $@ $(OBJ) $(STLDFLAGS)
+
+clean:
+ rm -f st $(OBJ) st-$(VERSION).tar.gz
+
+dist: clean
+ mkdir -p st-$(VERSION)
+ cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\
+ config.def.h st.info st.1 arg.h st.h win.h $(SRC)\
+ st-$(VERSION)
+ tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
+ rm -rf st-$(VERSION)
+
+install: st
+ mkdir -p $(DESTDIR)$(PREFIX)/bin
+ cp -f st $(DESTDIR)$(PREFIX)/bin
+ chmod 755 $(DESTDIR)$(PREFIX)/bin/st
+ mkdir -p $(DESTDIR)$(MANPREFIX)/man1
+ sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
+ chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
+ tic -sx st.info
+ @echo Please see the README file regarding the terminfo entry of st.
+
+uninstall:
+ rm -f $(DESTDIR)$(PREFIX)/bin/st
+ rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
+
+.PHONY: all options clean dist install uninstall
diff --git a/terms/st/st-0.8.2/README b/terms/st/st-0.8.2/README
new file mode 100644
index 0000000..6a846ed
--- /dev/null
+++ b/terms/st/st-0.8.2/README
@@ -0,0 +1,34 @@
+st - simple terminal
+--------------------
+st is a simple terminal emulator for X which sucks less.
+
+
+Requirements
+------------
+In order to build st you need the Xlib header files.
+
+
+Installation
+------------
+Edit config.mk to match your local setup (st is installed into
+the /usr/local namespace by default).
+
+Afterwards enter the following command to build and install st (if
+necessary as root):
+
+ make clean install
+
+
+Running st
+----------
+If you did not install st with make clean install, you must compile
+the st terminfo entry with the following command:
+
+ tic -sx st.info
+
+See the man page for additional details.
+
+Credits
+-------
+Based on Aurélien APTEL <aurelien dot aptel at gmail dot com> bt source code.
+
diff --git a/terms/st/st-0.8.2/TODO b/terms/st/st-0.8.2/TODO
new file mode 100644
index 0000000..5f74cd5
--- /dev/null
+++ b/terms/st/st-0.8.2/TODO
@@ -0,0 +1,28 @@
+vt emulation
+------------
+
+* double-height support
+
+code & interface
+----------------
+
+* add a simple way to do multiplexing
+
+drawing
+-------
+* add diacritics support to xdraws()
+ * switch to a suckless font drawing library
+* make the font cache simpler
+* add better support for brightening of the upper colors
+
+bugs
+----
+
+* fix shift up/down (shift selection in emacs)
+* remove DEC test sequence when appropriate
+
+misc
+----
+
+ $ grep -nE 'XXX|TODO' st.c
+
diff --git a/terms/st/st-0.8.2/arg.h b/terms/st/st-0.8.2/arg.h
new file mode 100644
index 0000000..a22e019
--- /dev/null
+++ b/terms/st/st-0.8.2/arg.h
@@ -0,0 +1,50 @@
+/*
+ * Copy me if you can.
+ * by 20h
+ */
+
+#ifndef ARG_H__
+#define ARG_H__
+
+extern char *argv0;
+
+/* use main(int argc, char *argv[]) */
+#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
+ argv[0] && argv[0][0] == '-'\
+ && argv[0][1];\
+ argc--, argv++) {\
+ char argc_;\
+ char **argv_;\
+ int brk_;\
+ if (argv[0][1] == '-' && argv[0][2] == '\0') {\
+ argv++;\
+ argc--;\
+ break;\
+ }\
+ int i_;\
+ for (i_ = 1, brk_ = 0, argv_ = argv;\
+ argv[0][i_] && !brk_;\
+ i_++) {\
+ if (argv_ != argv)\
+ break;\
+ argc_ = argv[0][i_];\
+ switch (argc_)
+
+#define ARGEND }\
+ }
+
+#define ARGC() argc_
+
+#define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
+ ((x), abort(), (char *)0) :\
+ (brk_ = 1, (argv[0][i_+1] != '\0')?\
+ (&argv[0][i_+1]) :\
+ (argc--, argv++, argv[0])))
+
+#define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
+ (char *)0 :\
+ (brk_ = 1, (argv[0][i_+1] != '\0')?\
+ (&argv[0][i_+1]) :\
+ (argc--, argv++, argv[0])))
+
+#endif
diff --git a/terms/st/st-0.8.2/config.def.h b/terms/st/st-0.8.2/config.def.h
new file mode 100644
index 0000000..0e01717
--- /dev/null
+++ b/terms/st/st-0.8.2/config.def.h
@@ -0,0 +1,462 @@
+/* See LICENSE file for copyright and license details. */
+
+/*
+ * appearance
+ *
+ * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
+ */
+static char *font = "Liberation Mono:pixelsize=12:antialias=true:autohint=true";
+static int borderpx = 2;
+
+/*
+ * What program is execed by st depends of these precedence rules:
+ * 1: program passed with -e
+ * 2: utmp option
+ * 3: SHELL environment variable
+ * 4: value of shell in /etc/passwd
+ * 5: value of shell in config.h
+ */
+static char *shell = "/bin/sh";
+char *utmp = NULL;
+char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
+
+/* identification sequence returned in DA and DECID */
+char *vtiden = "\033[?6c";
+
+/* Kerning / character bounding-box multipliers */
+static float cwscale = 1.0;
+static float chscale = 1.0;
+
+/*
+ * word delimiter string
+ *
+ * More advanced example: " `'\"()[]{}"
+ */
+char *worddelimiters = " ";
+
+/* selection timeouts (in milliseconds) */
+static unsigned int doubleclicktimeout = 300;
+static unsigned int tripleclicktimeout = 600;
+
+/* alt screens */
+int allowaltscreen = 1;
+
+/* frames per second st should at maximum draw to the screen */
+static unsigned int xfps = 120;
+static unsigned int actionfps = 30;
+
+/*
+ * blinking timeout (set to 0 to disable blinking) for the terminal blinking
+ * attribute.
+ */
+static unsigned int blinktimeout = 800;
+
+/*
+ * thickness of underline and bar cursors
+ */
+static unsigned int cursorthickness = 2;
+
+/*
+ * bell volume. It must be a value between -100 and 100. Use 0 for disabling
+ * it
+ */
+static int bellvolume = 0;
+
+/* default TERM value */
+char *termname = "st-256color";
+
+/*
+ * spaces per tab
+ *
+ * When you are changing this value, don't forget to adapt the »it« value in
+ * the st.info and appropriately install the st.info in the environment where
+ * you use this st version.
+ *
+ * it#$tabspaces,
+ *
+ * Secondly make sure your kernel is not expanding tabs. When running `stty
+ * -a` »tab0« should appear. You can tell the terminal to not expand tabs by
+ * running following command:
+ *
+ * stty tabs
+ */
+unsigned int tabspaces = 8;
+
+/* Terminal colors (16 first used in escape sequence) */
+static const char *colorname[] = {
+ /* 8 normal colors */
+ "black",
+ "red3",
+ "green3",
+ "yellow3",
+ "blue2",
+ "magenta3",
+ "cyan3",
+ "gray90",
+
+ /* 8 bright colors */
+ "gray50",
+ "red",
+ "green",
+ "yellow",
+ "#5c5cff",
+ "magenta",
+ "cyan",
+ "white",
+
+ [255] = 0,
+
+ /* more colors can be added after 255 to use with DefaultXX */
+ "#cccccc",
+ "#555555",
+};
+
+
+/*
+ * Default colors (colorname index)
+ * foreground, background, cursor, reverse cursor
+ */
+unsigned int defaultfg = 7;
+unsigned int defaultbg = 0;
+static unsigned int defaultcs = 256;
+static unsigned int defaultrcs = 257;
+
+/*
+ * Default shape of cursor
+ * 2: Block ("█")
+ * 4: Underline ("_")
+ * 6: Bar ("|")
+ * 7: Snowman ("☃")
+ */
+static unsigned int cursorshape = 2;
+
+/*
+ * Default columns and rows numbers
+ */
+
+static unsigned int cols = 80;
+static unsigned int rows = 24;
+
+/*
+ * Default colour and shape of the mouse cursor
+ */
+static unsigned int mouseshape = XC_xterm;
+static unsigned int mousefg = 7;
+static unsigned int mousebg = 0;
+
+/*
+ * Color used to display font attributes when fontconfig selected a font which
+ * doesn't match the ones requested.
+ */
+static unsigned int defaultattr = 11;
+
+/*
+ * Internal mouse shortcuts.
+ * Beware that overloading Button1 will disable the selection.
+ */
+static MouseShortcut mshortcuts[] = {
+ /* button mask string */
+ { Button4, XK_ANY_MOD, "\031" },
+ { Button5, XK_ANY_MOD, "\005" },
+};
+
+/* Internal keyboard shortcuts. */
+#define MODKEY Mod1Mask
+#define TERMMOD (ControlMask|ShiftMask)
+
+static Shortcut shortcuts[] = {
+ /* mask keysym function argument */
+ { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
+ { ControlMask, XK_Print, toggleprinter, {.i = 0} },
+ { ShiftMask, XK_Print, printscreen, {.i = 0} },
+ { XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
+ { TERMMOD, XK_Prior, zoom, {.f = +1} },
+ { TERMMOD, XK_Next, zoom, {.f = -1} },
+ { TERMMOD, XK_Home, zoomreset, {.f = 0} },
+ { TERMMOD, XK_C, clipcopy, {.i = 0} },
+ { TERMMOD, XK_V, clippaste, {.i = 0} },
+ { TERMMOD, XK_Y, selpaste, {.i = 0} },
+ { ShiftMask, XK_Insert, selpaste, {.i = 0} },
+ { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
+};
+
+/*
+ * Special keys (change & recompile st.info accordingly)
+ *
+ * Mask value:
+ * * Use XK_ANY_MOD to match the key no matter modifiers state
+ * * Use XK_NO_MOD to match the key alone (no modifiers)
+ * appkey value:
+ * * 0: no value
+ * * > 0: keypad application mode enabled
+ * * = 2: term.numlock = 1
+ * * < 0: keypad application mode disabled
+ * appcursor value:
+ * * 0: no value
+ * * > 0: cursor application mode enabled
+ * * < 0: cursor application mode disabled
+ * crlf value
+ * * 0: no value
+ * * > 0: crlf mode is enabled
+ * * < 0: crlf mode is disabled
+ *
+ * Be careful with the order of the definitions because st searches in
+ * this table sequentially, so any XK_ANY_MOD must be in the last
+ * position for a key.
+ */
+
+/*
+ * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF)
+ * to be mapped below, add them to this array.
+ */
+static KeySym mappedkeys[] = { -1 };
+
+/*
+ * State bits to ignore when matching key or button events. By default,
+ * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
+ */
+static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
+
+/*
+ * Override mouse-select while mask is active (when MODE_MOUSE is set).
+ * Note that if you want to use ShiftMask with selmasks, set this to an other
+ * modifier, set to 0 to not use it.
+ */
+static uint forceselmod = ShiftMask;
+
+/*
+ * This is the huge key array which defines all compatibility to the Linux
+ * world. Please decide about changes wisely.
+ */
+static Key key[] = {
+ /* keysym mask string appkey appcursor */
+ { XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
+ { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
+ { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
+ { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
+ { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
+ { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
+ { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
+ { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
+ { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
+ { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
+ { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
+ { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
+ { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
+ { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
+ { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
+ { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
+ { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
+ { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
+ { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
+ { XK_KP_End, ControlMask, "\033[J", -1, 0},
+ { XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
+ { XK_KP_End, ShiftMask, "\033[K", -1, 0},
+ { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
+ { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
+ { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
+ { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
+ { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
+ { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
+ { XK_KP_Insert, ControlMask, "\033[L", -1, 0},
+ { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
+ { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
+ { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
+ { XK_KP_Delete, ControlMask, "\033[M", -1, 0},
+ { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
+ { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
+ { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
+ { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
+ { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
+ { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
+ { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
+ { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
+ { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
+ { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
+ { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
+ { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
+ { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
+ { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
+ { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
+ { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
+ { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
+ { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
+ { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
+ { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
+ { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
+ { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
+ { XK_Up, ShiftMask, "\033[1;2A", 0, 0},
+ { XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
+ { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
+ { XK_Up, ControlMask, "\033[1;5A", 0, 0},
+ { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
+ { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
+ { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
+ { XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
+ { XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
+ { XK_Down, ShiftMask, "\033[1;2B", 0, 0},
+ { XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
+ { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
+ { XK_Down, ControlMask, "\033[1;5B", 0, 0},
+ { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
+ { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
+ { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
+ { XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
+ { XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
+ { XK_Left, ShiftMask, "\033[1;2D", 0, 0},
+ { XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
+ { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
+ { XK_Left, ControlMask, "\033[1;5D", 0, 0},
+ { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
+ { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
+ { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
+ { XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
+ { XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
+ { XK_Right, ShiftMask, "\033[1;2C", 0, 0},
+ { XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
+ { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
+ { XK_Right, ControlMask, "\033[1;5C", 0, 0},
+ { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
+ { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
+ { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
+ { XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
+ { XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
+ { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
+ { XK_Return, Mod1Mask, "\033\r", 0, 0},
+ { XK_Return, XK_ANY_MOD, "\r", 0, 0},
+ { XK_Insert, ShiftMask, "\033[4l", -1, 0},
+ { XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
+ { XK_Insert, ControlMask, "\033[L", -1, 0},
+ { XK_Insert, ControlMask, "\033[2;5~", +1, 0},
+ { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
+ { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
+ { XK_Delete, ControlMask, "\033[M", -1, 0},
+ { XK_Delete, ControlMask, "\033[3;5~", +1, 0},
+ { XK_Delete, ShiftMask, "\033[2K", -1, 0},
+ { XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
+ { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
+ { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
+ { XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
+ { XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
+ { XK_Home, ShiftMask, "\033[2J", 0, -1},
+ { XK_Home, ShiftMask, "\033[1;2H", 0, +1},
+ { XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
+ { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
+ { XK_End, ControlMask, "\033[J", -1, 0},
+ { XK_End, ControlMask, "\033[1;5F", +1, 0},
+ { XK_End, ShiftMask, "\033[K", -1, 0},
+ { XK_End, ShiftMask, "\033[1;2F", +1, 0},
+ { XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
+ { XK_Prior, ControlMask, "\033[5;5~", 0, 0},
+ { XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
+ { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
+ { XK_Next, ControlMask, "\033[6;5~", 0, 0},
+ { XK_Next, ShiftMask, "\033[6;2~", 0, 0},
+ { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
+ { XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
+ { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
+ { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
+ { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
+ { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
+ { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
+ { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
+ { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
+ { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
+ { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
+ { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
+ { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
+ { XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
+ { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
+ { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
+ { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
+ { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
+ { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
+ { XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
+ { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
+ { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
+ { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
+ { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
+ { XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
+ { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
+ { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
+ { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
+ { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
+ { XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
+ { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
+ { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
+ { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
+ { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
+ { XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
+ { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
+ { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
+ { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
+ { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
+ { XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
+ { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
+ { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
+ { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
+ { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
+ { XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
+ { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
+ { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
+ { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
+ { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
+ { XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
+ { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
+ { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
+ { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
+ { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
+ { XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
+ { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
+ { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
+ { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
+ { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
+ { XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
+ { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
+ { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
+ { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
+ { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
+ { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
+ { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
+ { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
+ { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
+ { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
+ { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
+ { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
+ { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
+ { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
+ { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
+ { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
+ { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
+ { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
+ { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
+ { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
+ { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
+ { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
+ { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
+ { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
+ { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
+ { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
+ { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
+ { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
+};
+
+/*
+ * Selection types' masks.
+ * Use the same masks as usual.
+ * Button1Mask is always unset, to make masks match between ButtonPress.
+ * ButtonRelease and MotionNotify.
+ * If no match is found, regular selection is used.
+ */
+static uint selmasks[] = {
+ [SEL_RECTANGULAR] = Mod1Mask,
+};
+
+/*
+ * Printable characters in ASCII, used to estimate the advance width
+ * of single wide characters.
+ */
+static char ascii_printable[] =
+ " !\"#$%&'()*+,-./0123456789:;<=>?"
+ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
+ "`abcdefghijklmnopqrstuvwxyz{|}~";
diff --git a/terms/st/st-0.8.2/config.h b/terms/st/st-0.8.2/config.h
new file mode 100644
index 0000000..accbedf
--- /dev/null
+++ b/terms/st/st-0.8.2/config.h
@@ -0,0 +1,463 @@
+/* See LICENSE file for copyright and license details. */
+
+/*
+ * appearance
+ *
+ * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
+ */
+// static char *font = "Terminus:pixelsize=20:antialias=true:autohint=true";
+static char *font = "gohufont-14:pixelsize=18:antialias=true";
+static int borderpx = 2;
+
+/*
+ * What program is execed by st depends of these precedence rules:
+ * 1: program passed with -e
+ * 2: utmp option
+ * 3: SHELL environment variable
+ * 4: value of shell in /etc/passwd
+ * 5: value of shell in config.h
+ */
+static char *shell = "/bin/sh";
+char *utmp = NULL;
+char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
+
+/* identification sequence returned in DA and DECID */
+char *vtiden = "\033[?6c";
+
+/* Kerning / character bounding-box multipliers */
+static float cwscale = 1.0;
+static float chscale = 1.0;
+
+/*
+ * word delimiter string
+ *
+ * More advanced example: " `'\"()[]{}"
+ */
+char *worddelimiters = " ";
+
+/* selection timeouts (in milliseconds) */
+static unsigned int doubleclicktimeout = 300;
+static unsigned int tripleclicktimeout = 600;
+
+/* alt screens */
+int allowaltscreen = 1;
+
+/* frames per second st should at maximum draw to the screen */
+static unsigned int xfps = 144;
+static unsigned int actionfps = 144;
+
+/*
+ * blinking timeout (set to 0 to disable blinking) for the terminal blinking
+ * attribute.
+ */
+static unsigned int blinktimeout = 800;
+
+/*
+ * thickness of underline and bar cursors
+ */
+static unsigned int cursorthickness = 2;
+
+/*
+ * bell volume. It must be a value between -100 and 100. Use 0 for disabling
+ * it
+ */
+static int bellvolume = 0;
+
+/* default TERM value */
+char *termname = "st-256color";
+
+/*
+ * spaces per tab
+ *
+ * When you are changing this value, don't forget to adapt the »it« value in
+ * the st.info and appropriately install the st.info in the environment where
+ * you use this st version.
+ *
+ * it#$tabspaces,
+ *
+ * Secondly make sure your kernel is not expanding tabs. When running `stty
+ * -a` »tab0« should appear. You can tell the terminal to not expand tabs by
+ * running following command:
+ *
+ * stty tabs
+ */
+unsigned int tabspaces = 8;
+
+/* Terminal colors (16 first used in escape sequence) */
+static const char *colorname[] = {
+ /* 8 normal colors */
+ "black",
+ "red3",
+ "green3",
+ "yellow3",
+ "blue2",
+ "magenta3",
+ "cyan3",
+ "gray90",
+
+ /* 8 bright colors */
+ "gray50",
+ "red",
+ "green",
+ "yellow",
+ "#5c5cff",
+ "magenta",
+ "cyan",
+ "white",
+
+ [255] = 0,
+
+ /* more colors can be added after 255 to use with DefaultXX */
+ "#cccccc",
+ "#555555",
+};
+
+
+/*
+ * Default colors (colorname index)
+ * foreground, background, cursor, reverse cursor
+ */
+unsigned int defaultfg = 7;
+unsigned int defaultbg = 0;
+static unsigned int defaultcs = 256;
+static unsigned int defaultrcs = 257;
+
+/*
+ * Default shape of cursor
+ * 2: Block ("█")
+ * 4: Underline ("_")
+ * 6: Bar ("|")
+ * 7: Snowman ("☃")
+ */
+static unsigned int cursorshape = 2;
+
+/*
+ * Default columns and rows numbers
+ */
+
+static unsigned int cols = 80;
+static unsigned int rows = 24;
+
+/*
+ * Default colour and shape of the mouse cursor
+ */
+static unsigned int mouseshape = XC_xterm;
+static unsigned int mousefg = 7;
+static unsigned int mousebg = 0;
+
+/*
+ * Color used to display font attributes when fontconfig selected a font which
+ * doesn't match the ones requested.
+ */
+static unsigned int defaultattr = 11;
+
+/*
+ * Internal mouse shortcuts.
+ * Beware that overloading Button1 will disable the selection.
+ */
+static MouseShortcut mshortcuts[] = {
+ /* button mask string */
+ { Button4, XK_ANY_MOD, "\031" },
+ { Button5, XK_ANY_MOD, "\005" },
+};
+
+/* Internal keyboard shortcuts. */
+#define MODKEY Mod1Mask
+#define TERMMOD (ControlMask|ShiftMask)
+
+static Shortcut shortcuts[] = {
+ /* mask keysym function argument */
+ { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
+ { ControlMask, XK_Print, toggleprinter, {.i = 0} },
+ { ShiftMask, XK_Print, printscreen, {.i = 0} },
+ { XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
+ { TERMMOD, XK_Prior, zoom, {.f = +1} },
+ { TERMMOD, XK_Next, zoom, {.f = -1} },
+ { TERMMOD, XK_Home, zoomreset, {.f = 0} },
+ { TERMMOD, XK_C, clipcopy, {.i = 0} },
+ { TERMMOD, XK_V, clippaste, {.i = 0} },
+ { TERMMOD, XK_Y, selpaste, {.i = 0} },
+ { ShiftMask, XK_Insert, selpaste, {.i = 0} },
+ { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
+};
+
+/*
+ * Special keys (change & recompile st.info accordingly)
+ *
+ * Mask value:
+ * * Use XK_ANY_MOD to match the key no matter modifiers state
+ * * Use XK_NO_MOD to match the key alone (no modifiers)
+ * appkey value:
+ * * 0: no value
+ * * > 0: keypad application mode enabled
+ * * = 2: term.numlock = 1
+ * * < 0: keypad application mode disabled
+ * appcursor value:
+ * * 0: no value
+ * * > 0: cursor application mode enabled
+ * * < 0: cursor application mode disabled
+ * crlf value
+ * * 0: no value
+ * * > 0: crlf mode is enabled
+ * * < 0: crlf mode is disabled
+ *
+ * Be careful with the order of the definitions because st searches in
+ * this table sequentially, so any XK_ANY_MOD must be in the last
+ * position for a key.
+ */
+
+/*
+ * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF)
+ * to be mapped below, add them to this array.
+ */
+static KeySym mappedkeys[] = { -1 };
+
+/*
+ * State bits to ignore when matching key or button events. By default,
+ * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
+ */
+static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
+
+/*
+ * Override mouse-select while mask is active (when MODE_MOUSE is set).
+ * Note that if you want to use ShiftMask with selmasks, set this to an other
+ * modifier, set to 0 to not use it.
+ */
+static uint forceselmod = ShiftMask;
+
+/*
+ * This is the huge key array which defines all compatibility to the Linux
+ * world. Please decide about changes wisely.
+ */
+static Key key[] = {
+ /* keysym mask string appkey appcursor */
+ { XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
+ { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
+ { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
+ { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
+ { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
+ { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
+ { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
+ { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
+ { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
+ { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
+ { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
+ { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
+ { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
+ { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
+ { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
+ { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
+ { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
+ { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
+ { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
+ { XK_KP_End, ControlMask, "\033[J", -1, 0},
+ { XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
+ { XK_KP_End, ShiftMask, "\033[K", -1, 0},
+ { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
+ { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
+ { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
+ { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
+ { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
+ { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
+ { XK_KP_Insert, ControlMask, "\033[L", -1, 0},
+ { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
+ { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
+ { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
+ { XK_KP_Delete, ControlMask, "\033[M", -1, 0},
+ { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
+ { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
+ { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
+ { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
+ { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
+ { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
+ { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
+ { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
+ { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
+ { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
+ { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
+ { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
+ { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
+ { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
+ { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
+ { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
+ { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
+ { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
+ { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
+ { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
+ { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
+ { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
+ { XK_Up, ShiftMask, "\033[1;2A", 0, 0},
+ { XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
+ { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
+ { XK_Up, ControlMask, "\033[1;5A", 0, 0},
+ { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
+ { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
+ { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
+ { XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
+ { XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
+ { XK_Down, ShiftMask, "\033[1;2B", 0, 0},
+ { XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
+ { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
+ { XK_Down, ControlMask, "\033[1;5B", 0, 0},
+ { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
+ { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
+ { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
+ { XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
+ { XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
+ { XK_Left, ShiftMask, "\033[1;2D", 0, 0},
+ { XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
+ { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
+ { XK_Left, ControlMask, "\033[1;5D", 0, 0},
+ { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
+ { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
+ { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
+ { XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
+ { XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
+ { XK_Right, ShiftMask, "\033[1;2C", 0, 0},
+ { XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
+ { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
+ { XK_Right, ControlMask, "\033[1;5C", 0, 0},
+ { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
+ { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
+ { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
+ { XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
+ { XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
+ { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
+ { XK_Return, Mod1Mask, "\033\r", 0, 0},
+ { XK_Return, XK_ANY_MOD, "\r", 0, 0},
+ { XK_Insert, ShiftMask, "\033[4l", -1, 0},
+ { XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
+ { XK_Insert, ControlMask, "\033[L", -1, 0},
+ { XK_Insert, ControlMask, "\033[2;5~", +1, 0},
+ { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
+ { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
+ { XK_Delete, ControlMask, "\033[M", -1, 0},
+ { XK_Delete, ControlMask, "\033[3;5~", +1, 0},
+ { XK_Delete, ShiftMask, "\033[2K", -1, 0},
+ { XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
+ { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
+ { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
+ { XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
+ { XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
+ { XK_Home, ShiftMask, "\033[2J", 0, -1},
+ { XK_Home, ShiftMask, "\033[1;2H", 0, +1},
+ { XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
+ { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
+ { XK_End, ControlMask, "\033[J", -1, 0},
+ { XK_End, ControlMask, "\033[1;5F", +1, 0},
+ { XK_End, ShiftMask, "\033[K", -1, 0},
+ { XK_End, ShiftMask, "\033[1;2F", +1, 0},
+ { XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
+ { XK_Prior, ControlMask, "\033[5;5~", 0, 0},
+ { XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
+ { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
+ { XK_Next, ControlMask, "\033[6;5~", 0, 0},
+ { XK_Next, ShiftMask, "\033[6;2~", 0, 0},
+ { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
+ { XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
+ { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
+ { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
+ { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
+ { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
+ { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
+ { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
+ { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
+ { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
+ { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
+ { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
+ { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
+ { XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
+ { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
+ { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
+ { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
+ { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
+ { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
+ { XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
+ { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
+ { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
+ { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
+ { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
+ { XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
+ { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
+ { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
+ { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
+ { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
+ { XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
+ { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
+ { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
+ { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
+ { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
+ { XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
+ { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
+ { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
+ { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
+ { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
+ { XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
+ { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
+ { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
+ { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
+ { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
+ { XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
+ { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
+ { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
+ { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
+ { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
+ { XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
+ { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
+ { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
+ { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
+ { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
+ { XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
+ { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
+ { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
+ { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
+ { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
+ { XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
+ { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
+ { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
+ { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
+ { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
+ { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
+ { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
+ { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
+ { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
+ { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
+ { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
+ { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
+ { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
+ { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
+ { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
+ { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
+ { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
+ { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
+ { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
+ { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
+ { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
+ { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
+ { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
+ { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
+ { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
+ { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
+ { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
+ { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
+};
+
+/*
+ * Selection types' masks.
+ * Use the same masks as usual.
+ * Button1Mask is always unset, to make masks match between ButtonPress.
+ * ButtonRelease and MotionNotify.
+ * If no match is found, regular selection is used.
+ */
+static uint selmasks[] = {
+ [SEL_RECTANGULAR] = Mod1Mask,
+};
+
+/*
+ * Printable characters in ASCII, used to estimate the advance width
+ * of single wide characters.
+ */
+static char ascii_printable[] =
+ " !\"#$%&'()*+,-./0123456789:;<=>?"
+ "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
+ "`abcdefghijklmnopqrstuvwxyz{|}~";
diff --git a/terms/st/st-0.8.2/config.mk b/terms/st/st-0.8.2/config.mk
new file mode 100644
index 0000000..0cbb002
--- /dev/null
+++ b/terms/st/st-0.8.2/config.mk
@@ -0,0 +1,35 @@
+# st version
+VERSION = 0.8.2
+
+# Customize below to fit your system
+
+# paths
+PREFIX = /usr/local
+MANPREFIX = $(PREFIX)/share/man
+
+X11INC = /usr/X11R6/include
+X11LIB = /usr/X11R6/lib
+
+PKG_CONFIG = pkg-config
+
+# includes and libs
+INCS = -I$(X11INC) \
+ `$(PKG_CONFIG) --cflags fontconfig` \
+ `$(PKG_CONFIG) --cflags freetype2`
+LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft \
+ `$(PKG_CONFIG) --libs fontconfig` \
+ `$(PKG_CONFIG) --libs freetype2`
+
+# flags
+STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
+STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
+STLDFLAGS = $(LIBS) $(LDFLAGS)
+
+# OpenBSD:
+#CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
+#LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
+# `pkg-config --libs fontconfig` \
+# `pkg-config --libs freetype2`
+
+# compiler and linker
+# CC = c99
diff --git a/terms/st/st-0.8.2/install.sh b/terms/st/st-0.8.2/install.sh
new file mode 100755
index 0000000..7a3ec16
--- /dev/null
+++ b/terms/st/st-0.8.2/install.sh
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+TARGET="/home/spesk/.local/bin/"
+FILE="st"
+
+if [[ -f $FILE ]]; then
+ echo "Found $FILE, linking to $TARGET"
+ ln $FILE $TARGET
+else
+ echo "$FILE not found"
+fi
diff --git a/terms/st/st-0.8.2/st b/terms/st/st-0.8.2/st
new file mode 100755
index 0000000..89e80a8
Binary files /dev/null and b/terms/st/st-0.8.2/st differ
diff --git a/terms/st/st-0.8.2/st.1 b/terms/st/st-0.8.2/st.1
new file mode 100644
index 0000000..e8d6059
--- /dev/null
+++ b/terms/st/st-0.8.2/st.1
@@ -0,0 +1,176 @@
+.TH ST 1 st\-VERSION
+.SH NAME
+st \- simple terminal
+.SH SYNOPSIS
+.B st
+.RB [ \-aiv ]
+.RB [ \-c
+.IR class ]
+.RB [ \-f
+.IR font ]
+.RB [ \-g
+.IR geometry ]
+.RB [ \-n
+.IR name ]
+.RB [ \-o
+.IR iofile ]
+.RB [ \-T
+.IR title ]
+.RB [ \-t
+.IR title ]
+.RB [ \-l
+.IR line ]
+.RB [ \-w
+.IR windowid ]
+.RB [[ \-e ]
+.IR command
+.RI [ arguments ...]]
+.PP
+.B st
+.RB [ \-aiv ]
+.RB [ \-c
+.IR class ]
+.RB [ \-f
+.IR font ]
+.RB [ \-g
+.IR geometry ]
+.RB [ \-n
+.IR name ]
+.RB [ \-o
+.IR iofile ]
+.RB [ \-T
+.IR title ]
+.RB [ \-t
+.IR title ]
+.RB [ \-w
+.IR windowid ]
+.RB \-l
+.IR line
+.RI [ stty_args ...]
+.SH DESCRIPTION
+.B st
+is a simple terminal emulator.
+.SH OPTIONS
+.TP
+.B \-a
+disable alternate screens in terminal
+.TP
+.BI \-c " class"
+defines the window class (default $TERM).
+.TP
+.BI \-f " font"
+defines the
+.I font
+to use when st is run.
+.TP
+.BI \-g " geometry"
+defines the X11 geometry string.
+The form is [=][<cols>{xX}<rows>][{+-}<xoffset>{+-}<yoffset>]. See
+.BR XParseGeometry (3)
+for further details.
+.TP
+.B \-i
+will fixate the position given with the -g option.
+.TP
+.BI \-n " name"
+defines the window instance name (default $TERM).
+.TP
+.BI \-o " iofile"
+writes all the I/O to
+.I iofile.
+This feature is useful when recording st sessions. A value of "-" means
+standard output.
+.TP
+.BI \-T " title"
+defines the window title (default 'st').
+.TP
+.BI \-t " title"
+defines the window title (default 'st').
+.TP
+.BI \-w " windowid"
+embeds st within the window identified by
+.I windowid
+.TP
+.BI \-l " line"
+use a tty
+.I line
+instead of a pseudo terminal.
+.I line
+should be a (pseudo-)serial device (e.g. /dev/ttyS0 on Linux for serial port
+0).
+When this flag is given
+remaining arguments are used as flags for
+.BR stty(1).
+By default st initializes the serial line to 8 bits, no parity, 1 stop bit
+and a 38400 baud rate. The speed is set by appending it as last argument
+(e.g. 'st -l /dev/ttyS0 115200'). Arguments before the last one are
+.BR stty(1)
+flags. If you want to set odd parity on 115200 baud use for example 'st -l
+/dev/ttyS0 parenb parodd 115200'. Set the number of bits by using for
+example 'st -l /dev/ttyS0 cs7 115200'. See
+.BR stty(1)
+for more arguments and cases.
+.TP
+.B \-v
+prints version information to stderr, then exits.
+.TP
+.BI \-e " command " [ " arguments " "... ]"
+st executes
+.I command
+instead of the shell. If this is used it
+.B must be the last option
+on the command line, as in xterm / rxvt.
+This option is only intended for compatibility,
+and all the remaining arguments are used as a command
+even without it.
+.SH SHORTCUTS
+.TP
+.B Break
+Send a break in the serial line.
+Break key is obtained in PC keyboards
+pressing at the same time control and pause.
+.TP
+.B Ctrl-Print Screen
+Toggle if st should print to the
+.I iofile.
+.TP
+.B Shift-Print Screen
+Print the full screen to the
+.I iofile.
+.TP
+.B Print Screen
+Print the selection to the
+.I iofile.
+.TP
+.B Ctrl-Shift-Page Up
+Increase font size.
+.TP
+.B Ctrl-Shift-Page Down
+Decrease font size.
+.TP
+.B Ctrl-Shift-Home
+Reset to default font size.
+.TP
+.B Ctrl-Shift-y
+Paste from primary selection (middle mouse button).
+.TP
+.B Ctrl-Shift-c
+Copy the selected text to the clipboard selection.
+.TP
+.B Ctrl-Shift-v
+Paste from the clipboard selection.
+.SH CUSTOMIZATION
+.B st
+can be customized by creating a custom config.h and (re)compiling the source
+code. This keeps it fast, secure and simple.
+.SH AUTHORS
+See the LICENSE file for the authors.
+.SH LICENSE
+See the LICENSE file for the terms of redistribution.
+.SH SEE ALSO
+.BR tabbed (1),
+.BR utmp (1),
+.BR stty (1)
+.SH BUGS
+See the TODO file in the distribution.
+
diff --git a/terms/st/st-0.8.2/st.c b/terms/st/st-0.8.2/st.c
new file mode 100644
index 0000000..b8e6077
--- /dev/null
+++ b/terms/st/st-0.8.2/st.c
@@ -0,0 +1,2604 @@
+/* See LICENSE for license details. */
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <pwd.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/ioctl.h>
+#include <sys/select.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <termios.h>
+#include <unistd.h>
+#include <wchar.h>
+
+#include "st.h"
+#include "win.h"
+
+#if defined(__linux)
+ #include <pty.h>
+#elif defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
+ #include <util.h>
+#elif defined(__FreeBSD__) || defined(__DragonFly__)
+ #include <libutil.h>
+#endif
+
+/* Arbitrary sizes */
+#define UTF_INVALID 0xFFFD
+#define UTF_SIZ 4
+#define ESC_BUF_SIZ (128*UTF_SIZ)
+#define ESC_ARG_SIZ 16
+#define STR_BUF_SIZ ESC_BUF_SIZ
+#define STR_ARG_SIZ ESC_ARG_SIZ
+
+/* macros */
+#define IS_SET(flag) ((term.mode & (flag)) != 0)
+#define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == '\177')
+#define ISCONTROLC1(c) (BETWEEN(c, 0x80, 0x9f))
+#define ISCONTROL(c) (ISCONTROLC0(c) || ISCONTROLC1(c))
+#define ISDELIM(u) (utf8strchr(worddelimiters, u) != NULL)
+
+enum term_mode {
+ MODE_WRAP = 1 << 0,
+ MODE_INSERT = 1 << 1,
+ MODE_ALTSCREEN = 1 << 2,
+ MODE_CRLF = 1 << 3,
+ MODE_ECHO = 1 << 4,
+ MODE_PRINT = 1 << 5,
+ MODE_UTF8 = 1 << 6,
+ MODE_SIXEL = 1 << 7,
+};
+
+enum cursor_movement {
+ CURSOR_SAVE,
+ CURSOR_LOAD
+};
+
+enum cursor_state {
+ CURSOR_DEFAULT = 0,
+ CURSOR_WRAPNEXT = 1,
+ CURSOR_ORIGIN = 2
+};
+
+enum charset {
+ CS_GRAPHIC0,
+ CS_GRAPHIC1,
+ CS_UK,
+ CS_USA,
+ CS_MULTI,
+ CS_GER,
+ CS_FIN
+};
+
+enum escape_state {
+ ESC_START = 1,
+ ESC_CSI = 2,
+ ESC_STR = 4, /* OSC, PM, APC */
+ ESC_ALTCHARSET = 8,
+ ESC_STR_END = 16, /* a final string was encountered */
+ ESC_TEST = 32, /* Enter in test mode */
+ ESC_UTF8 = 64,
+ ESC_DCS =128,
+};
+
+typedef struct {
+ Glyph attr; /* current char attributes */
+ int x;
+ int y;
+ char state;
+} TCursor;
+
+typedef struct {
+ int mode;
+ int type;
+ int snap;
+ /*
+ * Selection variables:
+ * nb – normalized coordinates of the beginning of the selection
+ * ne – normalized coordinates of the end of the selection
+ * ob – original coordinates of the beginning of the selection
+ * oe – original coordinates of the end of the selection
+ */
+ struct {
+ int x, y;
+ } nb, ne, ob, oe;
+
+ int alt;
+} Selection;
+
+/* Internal representation of the screen */
+typedef struct {
+ int row; /* nb row */
+ int col; /* nb col */
+ Line *line; /* screen */
+ Line *alt; /* alternate screen */
+ int *dirty; /* dirtyness of lines */
+ TCursor c; /* cursor */
+ int ocx; /* old cursor col */
+ int ocy; /* old cursor row */
+ int top; /* top scroll limit */
+ int bot; /* bottom scroll limit */
+ int mode; /* terminal mode flags */
+ int esc; /* escape state flags */
+ char trantbl[4]; /* charset table translation */
+ int charset; /* current charset */
+ int icharset; /* selected charset for sequence */
+ int *tabs;
+} Term;
+
+/* CSI Escape sequence structs */
+/* ESC '[' [[ [<priv>] <arg> [;]] <mode> [<mode>]] */
+typedef struct {
+ char buf[ESC_BUF_SIZ]; /* raw string */
+ int len; /* raw string length */
+ char priv;
+ int arg[ESC_ARG_SIZ];
+ int narg; /* nb of args */
+ char mode[2];
+} CSIEscape;
+
+/* STR Escape sequence structs */
+/* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */
+typedef struct {
+ char type; /* ESC type ... */
+ char buf[STR_BUF_SIZ]; /* raw string */
+ int len; /* raw string length */
+ char *args[STR_ARG_SIZ];
+ int narg; /* nb of args */
+} STREscape;
+
+static void execsh(char *, char **);
+static void stty(char **);
+static void sigchld(int);
+static void ttywriteraw(const char *, size_t);
+
+static void csidump(void);
+static void csihandle(void);
+static void csiparse(void);
+static void csireset(void);
+static int eschandle(uchar);
+static void strdump(void);
+static void strhandle(void);
+static void strparse(void);
+static void strreset(void);
+
+static void tprinter(char *, size_t);
+static void tdumpsel(void);
+static void tdumpline(int);
+static void tdump(void);
+static void tclearregion(int, int, int, int);
+static void tcursor(int);
+static void tdeletechar(int);
+static void tdeleteline(int);
+static void tinsertblank(int);
+static void tinsertblankline(int);
+static int tlinelen(int);
+static void tmoveto(int, int);
+static void tmoveato(int, int);
+static void tnewline(int);
+static void tputtab(int);
+static void tputc(Rune);
+static void treset(void);
+static void tscrollup(int, int);
+static void tscrolldown(int, int);
+static void tsetattr(int *, int);
+static void tsetchar(Rune, Glyph *, int, int);
+static void tsetdirt(int, int);
+static void tsetscroll(int, int);
+static void tswapscreen(void);
+static void tsetmode(int, int, int *, int);
+static int twrite(const char *, int, int);
+static void tfulldirt(void);
+static void tcontrolcode(uchar );
+static void tdectest(char );
+static void tdefutf8(char);
+static int32_t tdefcolor(int *, int *, int);
+static void tdeftran(char);
+static void tstrsequence(uchar);
+
+static void drawregion(int, int, int, int);
+
+static void selnormalize(void);
+static void selscroll(int, int);
+static void selsnap(int *, int *, int);
+
+static size_t utf8decode(const char *, Rune *, size_t);
+static Rune utf8decodebyte(char, size_t *);
+static char utf8encodebyte(Rune, size_t);
+static char *utf8strchr(char *, Rune);
+static size_t utf8validate(Rune *, size_t);
+
+static char *base64dec(const char *);
+static char base64dec_getc(const char **);
+
+static ssize_t xwrite(int, const char *, size_t);
+
+/* Globals */
+static Term term;
+static Selection sel;
+static CSIEscape csiescseq;
+static STREscape strescseq;
+static int iofd = 1;
+static int cmdfd;
+static pid_t pid;
+
+static uchar utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
+static uchar utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
+static Rune utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
+static Rune utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
+
+ssize_t
+xwrite(int fd, const char *s, size_t len)
+{
+ size_t aux = len;
+ ssize_t r;
+
+ while (len > 0) {
+ r = write(fd, s, len);
+ if (r < 0)
+ return r;
+ len -= r;
+ s += r;
+ }
+
+ return aux;
+}
+
+void *
+xmalloc(size_t len)
+{
+ void *p;
+
+ if (!(p = malloc(len)))
+ die("malloc: %s\n", strerror(errno));
+
+ return p;
+}
+
+void *
+xrealloc(void *p, size_t len)
+{
+ if ((p = realloc(p, len)) == NULL)
+ die("realloc: %s\n", strerror(errno));
+
+ return p;
+}
+
+char *
+xstrdup(char *s)
+{
+ if ((s = strdup(s)) == NULL)
+ die("strdup: %s\n", strerror(errno));
+
+ return s;
+}
+
+size_t
+utf8decode(const char *c, Rune *u, size_t clen)
+{
+ size_t i, j, len, type;
+ Rune udecoded;
+
+ *u = UTF_INVALID;
+ if (!clen)
+ return 0;
+ udecoded = utf8decodebyte(c[0], &len);
+ if (!BETWEEN(len, 1, UTF_SIZ))
+ return 1;
+ for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
+ udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
+ if (type != 0)
+ return j;
+ }
+ if (j < len)
+ return 0;
+ *u = udecoded;
+ utf8validate(u, len);
+
+ return len;
+}
+
+Rune
+utf8decodebyte(char c, size_t *i)
+{
+ for (*i = 0; *i < LEN(utfmask); ++(*i))
+ if (((uchar)c & utfmask[*i]) == utfbyte[*i])
+ return (uchar)c & ~utfmask[*i];
+
+ return 0;
+}
+
+size_t
+utf8encode(Rune u, char *c)
+{
+ size_t len, i;
+
+ len = utf8validate(&u, 0);
+ if (len > UTF_SIZ)
+ return 0;
+
+ for (i = len - 1; i != 0; --i) {
+ c[i] = utf8encodebyte(u, 0);
+ u >>= 6;
+ }
+ c[0] = utf8encodebyte(u, len);
+
+ return len;
+}
+
+char
+utf8encodebyte(Rune u, size_t i)
+{
+ return utfbyte[i] | (u & ~utfmask[i]);
+}
+
+char *
+utf8strchr(char *s, Rune u)
+{
+ Rune r;
+ size_t i, j, len;
+
+ len = strlen(s);
+ for (i = 0, j = 0; i < len; i += j) {
+ if (!(j = utf8decode(&s[i], &r, len - i)))
+ break;
+ if (r == u)
+ return &(s[i]);
+ }
+
+ return NULL;
+}
+
+size_t
+utf8validate(Rune *u, size_t i)
+{
+ if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
+ *u = UTF_INVALID;
+ for (i = 1; *u > utfmax[i]; ++i)
+ ;
+
+ return i;
+}
+
+static const char base64_digits[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 62, 0, 0, 0,
+ 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 0, 0, 0, -1, 0, 0, 0, 0, 1,
+ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, 0, 0, 0, 0, 0, 0, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+char
+base64dec_getc(const char **src)
+{
+ while (**src && !isprint(**src)) (*src)++;
+ return *((*src)++);
+}
+
+char *
+base64dec(const char *src)
+{
+ size_t in_len = strlen(src);
+ char *result, *dst;
+
+ if (in_len % 4)
+ in_len += 4 - (in_len % 4);
+ result = dst = xmalloc(in_len / 4 * 3 + 1);
+ while (*src) {
+ int a = base64_digits[(unsigned char) base64dec_getc(&src)];
+ int b = base64_digits[(unsigned char) base64dec_getc(&src)];
+ int c = base64_digits[(unsigned char) base64dec_getc(&src)];
+ int d = base64_digits[(unsigned char) base64dec_getc(&src)];
+
+ *dst++ = (a << 2) | ((b & 0x30) >> 4);
+ if (c == -1)
+ break;
+ *dst++ = ((b & 0x0f) << 4) | ((c & 0x3c) >> 2);
+ if (d == -1)
+ break;
+ *dst++ = ((c & 0x03) << 6) | d;
+ }
+ *dst = '\0';
+ return result;
+}
+
+void
+selinit(void)
+{
+ sel.mode = SEL_IDLE;
+ sel.snap = 0;
+ sel.ob.x = -1;
+}
+
+int
+tlinelen(int y)
+{
+ int i = term.col;
+
+ if (term.line[y][i - 1].mode & ATTR_WRAP)
+ return i;
+
+ while (i > 0 && term.line[y][i - 1].u == ' ')
+ --i;
+
+ return i;
+}
+
+void
+selstart(int col, int row, int snap)
+{
+ selclear();
+ sel.mode = SEL_EMPTY;
+ sel.type = SEL_REGULAR;
+ sel.alt = IS_SET(MODE_ALTSCREEN);
+ sel.snap = snap;
+ sel.oe.x = sel.ob.x = col;
+ sel.oe.y = sel.ob.y = row;
+ selnormalize();
+
+ if (sel.snap != 0)
+ sel.mode = SEL_READY;
+ tsetdirt(sel.nb.y, sel.ne.y);
+}
+
+void
+selextend(int col, int row, int type, int done)
+{
+ int oldey, oldex, oldsby, oldsey, oldtype;
+
+ if (sel.mode == SEL_IDLE)
+ return;
+ if (done && sel.mode == SEL_EMPTY) {
+ selclear();
+ return;
+ }
+
+ oldey = sel.oe.y;
+ oldex = sel.oe.x;
+ oldsby = sel.nb.y;
+ oldsey = sel.ne.y;
+ oldtype = sel.type;
+
+ sel.oe.x = col;
+ sel.oe.y = row;
+ selnormalize();
+ sel.type = type;
+
+ if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type)
+ tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey));
+
+ sel.mode = done ? SEL_IDLE : SEL_READY;
+}
+
+void
+selnormalize(void)
+{
+ int i;
+
+ if (sel.type == SEL_REGULAR && sel.ob.y != sel.oe.y) {
+ sel.nb.x = sel.ob.y < sel.oe.y ? sel.ob.x : sel.oe.x;
+ sel.ne.x = sel.ob.y < sel.oe.y ? sel.oe.x : sel.ob.x;
+ } else {
+ sel.nb.x = MIN(sel.ob.x, sel.oe.x);
+ sel.ne.x = MAX(sel.ob.x, sel.oe.x);
+ }
+ sel.nb.y = MIN(sel.ob.y, sel.oe.y);
+ sel.ne.y = MAX(sel.ob.y, sel.oe.y);
+
+ selsnap(&sel.nb.x, &sel.nb.y, -1);
+ selsnap(&sel.ne.x, &sel.ne.y, +1);
+
+ /* expand selection over line breaks */
+ if (sel.type == SEL_RECTANGULAR)
+ return;
+ i = tlinelen(sel.nb.y);
+ if (i < sel.nb.x)
+ sel.nb.x = i;
+ if (tlinelen(sel.ne.y) <= sel.ne.x)
+ sel.ne.x = term.col - 1;
+}
+
+int
+selected(int x, int y)
+{
+ if (sel.mode == SEL_EMPTY || sel.ob.x == -1 ||
+ sel.alt != IS_SET(MODE_ALTSCREEN))
+ return 0;
+
+ if (sel.type == SEL_RECTANGULAR)
+ return BETWEEN(y, sel.nb.y, sel.ne.y)
+ && BETWEEN(x, sel.nb.x, sel.ne.x);
+
+ return BETWEEN(y, sel.nb.y, sel.ne.y)
+ && (y != sel.nb.y || x >= sel.nb.x)
+ && (y != sel.ne.y || x <= sel.ne.x);
+}
+
+void
+selsnap(int *x, int *y, int direction)
+{
+ int newx, newy, xt, yt;
+ int delim, prevdelim;
+ Glyph *gp, *prevgp;
+
+ switch (sel.snap) {
+ case SNAP_WORD:
+ /*
+ * Snap around if the word wraps around at the end or
+ * beginning of a line.
+ */
+ prevgp = &term.line[*y][*x];
+ prevdelim = ISDELIM(prevgp->u);
+ for (;;) {
+ newx = *x + direction;
+ newy = *y;
+ if (!BETWEEN(newx, 0, term.col - 1)) {
+ newy += direction;
+ newx = (newx + term.col) % term.col;
+ if (!BETWEEN(newy, 0, term.row - 1))
+ break;
+
+ if (direction > 0)
+ yt = *y, xt = *x;
+ else
+ yt = newy, xt = newx;
+ if (!(term.line[yt][xt].mode & ATTR_WRAP))
+ break;
+ }
+
+ if (newx >= tlinelen(newy))
+ break;
+
+ gp = &term.line[newy][newx];
+ delim = ISDELIM(gp->u);
+ if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
+ || (delim && gp->u != prevgp->u)))
+ break;
+
+ *x = newx;
+ *y = newy;
+ prevgp = gp;
+ prevdelim = delim;
+ }
+ break;
+ case SNAP_LINE:
+ /*
+ * Snap around if the the previous line or the current one
+ * has set ATTR_WRAP at its end. Then the whole next or
+ * previous line will be selected.
+ */
+ *x = (direction < 0) ? 0 : term.col - 1;
+ if (direction < 0) {
+ for (; *y > 0; *y += direction) {
+ if (!(term.line[*y-1][term.col-1].mode
+ & ATTR_WRAP)) {
+ break;
+ }
+ }
+ } else if (direction > 0) {
+ for (; *y < term.row-1; *y += direction) {
+ if (!(term.line[*y][term.col-1].mode
+ & ATTR_WRAP)) {
+ break;
+ }
+ }
+ }
+ break;
+ }
+}
+
+char *
+getsel(void)
+{
+ char *str, *ptr;
+ int y, bufsize, lastx, linelen;
+ Glyph *gp, *last;
+
+ if (sel.ob.x == -1)
+ return NULL;
+
+ bufsize = (term.col+1) * (sel.ne.y-sel.nb.y+1) * UTF_SIZ;
+ ptr = str = xmalloc(bufsize);
+
+ /* append every set & selected glyph to the selection */
+ for (y = sel.nb.y; y <= sel.ne.y; y++) {
+ if ((linelen = tlinelen(y)) == 0) {
+ *ptr++ = '\n';
+ continue;
+ }
+
+ if (sel.type == SEL_RECTANGULAR) {
+ gp = &term.line[y][sel.nb.x];
+ lastx = sel.ne.x;
+ } else {
+ gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
+ lastx = (sel.ne.y == y) ? sel.ne.x : term.col-1;
+ }
+ last = &term.line[y][MIN(lastx, linelen-1)];
+ while (last >= gp && last->u == ' ')
+ --last;
+
+ for ( ; gp <= last; ++gp) {
+ if (gp->mode & ATTR_WDUMMY)
+ continue;
+
+ ptr += utf8encode(gp->u, ptr);
+ }
+
+ /*
+ * Copy and pasting of line endings is inconsistent
+ * in the inconsistent terminal and GUI world.
+ * The best solution seems like to produce '\n' when
+ * something is copied from st and convert '\n' to
+ * '\r', when something to be pasted is received by
+ * st.
+ * FIXME: Fix the computer world.
+ */
+ if ((y < sel.ne.y || lastx >= linelen) && !(last->mode & ATTR_WRAP))
+ *ptr++ = '\n';
+ }
+ *ptr = 0;
+ return str;
+}
+
+void
+selclear(void)
+{
+ if (sel.ob.x == -1)
+ return;
+ sel.mode = SEL_IDLE;
+ sel.ob.x = -1;
+ tsetdirt(sel.nb.y, sel.ne.y);
+}
+
+void
+die(const char *errstr, ...)
+{
+ va_list ap;
+
+ va_start(ap, errstr);
+ vfprintf(stderr, errstr, ap);
+ va_end(ap);
+ exit(1);
+}
+
+void
+execsh(char *cmd, char **args)
+{
+ char *sh, *prog;
+ const struct passwd *pw;
+
+ errno = 0;
+ if ((pw = getpwuid(getuid())) == NULL) {
+ if (errno)
+ die("getpwuid: %s\n", strerror(errno));
+ else
+ die("who are you?\n");
+ }
+
+ if ((sh = getenv("SHELL")) == NULL)
+ sh = (pw->pw_shell[0]) ? pw->pw_shell : cmd;
+
+ if (args)
+ prog = args[0];
+ else if (utmp)
+ prog = utmp;
+ else
+ prog = sh;
+ DEFAULT(args, ((char *[]) {prog, NULL}));
+
+ unsetenv("COLUMNS");
+ unsetenv("LINES");
+ unsetenv("TERMCAP");
+ setenv("LOGNAME", pw->pw_name, 1);
+ setenv("USER", pw->pw_name, 1);
+ setenv("SHELL", sh, 1);
+ setenv("HOME", pw->pw_dir, 1);
+ setenv("TERM", termname, 1);
+
+ signal(SIGCHLD, SIG_DFL);
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGINT, SIG_DFL);
+ signal(SIGQUIT, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGALRM, SIG_DFL);
+
+ execvp(prog, args);
+ _exit(1);
+}
+
+void
+sigchld(int a)
+{
+ int stat;
+ pid_t p;
+
+ if ((p = waitpid(pid, &stat, WNOHANG)) < 0)
+ die("waiting for pid %hd failed: %s\n", pid, strerror(errno));
+
+ if (pid != p)
+ return;
+
+ if (WIFEXITED(stat) && WEXITSTATUS(stat))
+ die("child exited with status %d\n", WEXITSTATUS(stat));
+ else if (WIFSIGNALED(stat))
+ die("child terminated due to signal %d\n", WTERMSIG(stat));
+ exit(0);
+}
+
+void
+stty(char **args)
+{
+ char cmd[_POSIX_ARG_MAX], **p, *q, *s;
+ size_t n, siz;
+
+ if ((n = strlen(stty_args)) > sizeof(cmd)-1)
+ die("incorrect stty parameters\n");
+ memcpy(cmd, stty_args, n);
+ q = cmd + n;
+ siz = sizeof(cmd) - n;
+ for (p = args; p && (s = *p); ++p) {
+ if ((n = strlen(s)) > siz-1)
+ die("stty parameter length too long\n");
+ *q++ = ' ';
+ memcpy(q, s, n);
+ q += n;
+ siz -= n + 1;
+ }
+ *q = '\0';
+ if (system(cmd) != 0)
+ perror("Couldn't call stty");
+}
+
+int
+ttynew(char *line, char *cmd, char *out, char **args)
+{
+ int m, s;
+
+ if (out) {
+ term.mode |= MODE_PRINT;
+ iofd = (!strcmp(out, "-")) ?
+ 1 : open(out, O_WRONLY | O_CREAT, 0666);
+ if (iofd < 0) {
+ fprintf(stderr, "Error opening %s:%s\n",
+ out, strerror(errno));
+ }
+ }
+
+ if (line) {
+ if ((cmdfd = open(line, O_RDWR)) < 0)
+ die("open line '%s' failed: %s\n",
+ line, strerror(errno));
+ dup2(cmdfd, 0);
+ stty(args);
+ return cmdfd;
+ }
+
+ /* seems to work fine on linux, openbsd and freebsd */
+ if (openpty(&m, &s, NULL, NULL, NULL) < 0)
+ die("openpty failed: %s\n", strerror(errno));
+
+ switch (pid = fork()) {
+ case -1:
+ die("fork failed: %s\n", strerror(errno));
+ break;
+ case 0:
+ close(iofd);
+ setsid(); /* create a new process group */
+ dup2(s, 0);
+ dup2(s, 1);
+ dup2(s, 2);
+ if (ioctl(s, TIOCSCTTY, NULL) < 0)
+ die("ioctl TIOCSCTTY failed: %s\n", strerror(errno));
+ close(s);
+ close(m);
+#ifdef __OpenBSD__
+ if (pledge("stdio getpw proc exec", NULL) == -1)
+ die("pledge\n");
+#endif
+ execsh(cmd, args);
+ break;
+ default:
+#ifdef __OpenBSD__
+ if (pledge("stdio rpath tty proc", NULL) == -1)
+ die("pledge\n");
+#endif
+ close(s);
+ cmdfd = m;
+ signal(SIGCHLD, sigchld);
+ break;
+ }
+ return cmdfd;
+}
+
+size_t
+ttyread(void)
+{
+ static char buf[BUFSIZ];
+ static int buflen = 0;
+ int written;
+ int ret;
+
+ /* append read bytes to unprocessed bytes */
+ if ((ret = read(cmdfd, buf+buflen, LEN(buf)-buflen)) < 0)
+ die("couldn't read from shell: %s\n", strerror(errno));
+ buflen += ret;
+
+ written = twrite(buf, buflen, 0);
+ buflen -= written;
+ /* keep any uncomplete utf8 char for the next call */
+ if (buflen > 0)
+ memmove(buf, buf + written, buflen);
+
+ return ret;
+}
+
+void
+ttywrite(const char *s, size_t n, int may_echo)
+{
+ const char *next;
+
+ if (may_echo && IS_SET(MODE_ECHO))
+ twrite(s, n, 1);
+
+ if (!IS_SET(MODE_CRLF)) {
+ ttywriteraw(s, n);
+ return;
+ }
+
+ /* This is similar to how the kernel handles ONLCR for ttys */
+ while (n > 0) {
+ if (*s == '\r') {
+ next = s + 1;
+ ttywriteraw("\r\n", 2);
+ } else {
+ next = memchr(s, '\r', n);
+ DEFAULT(next, s + n);
+ ttywriteraw(s, next - s);
+ }
+ n -= next - s;
+ s = next;
+ }
+}
+
+void
+ttywriteraw(const char *s, size_t n)
+{
+ fd_set wfd, rfd;
+ ssize_t r;
+ size_t lim = 256;
+
+ /*
+ * Remember that we are using a pty, which might be a modem line.
+ * Writing too much will clog the line. That's why we are doing this
+ * dance.
+ * FIXME: Migrate the world to Plan 9.
+ */
+ while (n > 0) {
+ FD_ZERO(&wfd);
+ FD_ZERO(&rfd);
+ FD_SET(cmdfd, &wfd);
+ FD_SET(cmdfd, &rfd);
+
+ /* Check if we can write. */
+ if (pselect(cmdfd+1, &rfd, &wfd, NULL, NULL, NULL) < 0) {
+ if (errno == EINTR)
+ continue;
+ die("select failed: %s\n", strerror(errno));
+ }
+ if (FD_ISSET(cmdfd, &wfd)) {
+ /*
+ * Only write the bytes written by ttywrite() or the
+ * default of 256. This seems to be a reasonable value
+ * for a serial line. Bigger values might clog the I/O.
+ */
+ if ((r = write(cmdfd, s, (n < lim)? n : lim)) < 0)
+ goto write_error;
+ if (r < n) {
+ /*
+ * We weren't able to write out everything.
+ * This means the buffer is getting full
+ * again. Empty it.
+ */
+ if (n < lim)
+ lim = ttyread();
+ n -= r;
+ s += r;
+ } else {
+ /* All bytes have been written. */
+ break;
+ }
+ }
+ if (FD_ISSET(cmdfd, &rfd))
+ lim = ttyread();
+ }
+ return;
+
+write_error:
+ die("write error on tty: %s\n", strerror(errno));
+}
+
+void
+ttyresize(int tw, int th)
+{
+ struct winsize w;
+
+ w.ws_row = term.row;
+ w.ws_col = term.col;
+ w.ws_xpixel = tw;
+ w.ws_ypixel = th;
+ if (ioctl(cmdfd, TIOCSWINSZ, &w) < 0)
+ fprintf(stderr, "Couldn't set window size: %s\n", strerror(errno));
+}
+
+void
+ttyhangup()
+{
+ /* Send SIGHUP to shell */
+ kill(pid, SIGHUP);
+}
+
+int
+tattrset(int attr)
+{
+ int i, j;
+
+ for (i = 0; i < term.row-1; i++) {
+ for (j = 0; j < term.col-1; j++) {
+ if (term.line[i][j].mode & attr)
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+void
+tsetdirt(int top, int bot)
+{
+ int i;
+
+ LIMIT(top, 0, term.row-1);
+ LIMIT(bot, 0, term.row-1);
+
+ for (i = top; i <= bot; i++)
+ term.dirty[i] = 1;
+}
+
+void
+tsetdirtattr(int attr)
+{
+ int i, j;
+
+ for (i = 0; i < term.row-1; i++) {
+ for (j = 0; j < term.col-1; j++) {
+ if (term.line[i][j].mode & attr) {
+ tsetdirt(i, i);
+ break;
+ }
+ }
+ }
+}
+
+void
+tfulldirt(void)
+{
+ tsetdirt(0, term.row-1);
+}
+
+void
+tcursor(int mode)
+{
+ static TCursor c[2];
+ int alt = IS_SET(MODE_ALTSCREEN);
+
+ if (mode == CURSOR_SAVE) {
+ c[alt] = term.c;
+ } else if (mode == CURSOR_LOAD) {
+ term.c = c[alt];
+ tmoveto(c[alt].x, c[alt].y);
+ }
+}
+
+void
+treset(void)
+{
+ uint i;
+
+ term.c = (TCursor){{
+ .mode = ATTR_NULL,
+ .fg = defaultfg,
+ .bg = defaultbg
+ }, .x = 0, .y = 0, .state = CURSOR_DEFAULT};
+
+ memset(term.tabs, 0, term.col * sizeof(*term.tabs));
+ for (i = tabspaces; i < term.col; i += tabspaces)
+ term.tabs[i] = 1;
+ term.top = 0;
+ term.bot = term.row - 1;
+ term.mode = MODE_WRAP|MODE_UTF8;
+ memset(term.trantbl, CS_USA, sizeof(term.trantbl));
+ term.charset = 0;
+
+ for (i = 0; i < 2; i++) {
+ tmoveto(0, 0);
+ tcursor(CURSOR_SAVE);
+ tclearregion(0, 0, term.col-1, term.row-1);
+ tswapscreen();
+ }
+}
+
+void
+tnew(int col, int row)
+{
+ term = (Term){ .c = { .attr = { .fg = defaultfg, .bg = defaultbg } } };
+ tresize(col, row);
+ treset();
+}
+
+void
+tswapscreen(void)
+{
+ Line *tmp = term.line;
+
+ term.line = term.alt;
+ term.alt = tmp;
+ term.mode ^= MODE_ALTSCREEN;
+ tfulldirt();
+}
+
+void
+tscrolldown(int orig, int n)
+{
+ int i;
+ Line temp;
+
+ LIMIT(n, 0, term.bot-orig+1);
+
+ tsetdirt(orig, term.bot-n);
+ tclearregion(0, term.bot-n+1, term.col-1, term.bot);
+
+ for (i = term.bot; i >= orig+n; i--) {
+ temp = term.line[i];
+ term.line[i] = term.line[i-n];
+ term.line[i-n] = temp;
+ }
+
+ selscroll(orig, n);
+}
+
+void
+tscrollup(int orig, int n)
+{
+ int i;
+ Line temp;
+
+ LIMIT(n, 0, term.bot-orig+1);
+
+ tclearregion(0, orig, term.col-1, orig+n-1);
+ tsetdirt(orig+n, term.bot);
+
+ for (i = orig; i <= term.bot-n; i++) {
+ temp = term.line[i];
+ term.line[i] = term.line[i+n];
+ term.line[i+n] = temp;
+ }
+
+ selscroll(orig, -n);
+}
+
+void
+selscroll(int orig, int n)
+{
+ if (sel.ob.x == -1)
+ return;
+
+ if (BETWEEN(sel.ob.y, orig, term.bot) || BETWEEN(sel.oe.y, orig, term.bot)) {
+ if ((sel.ob.y += n) > term.bot || (sel.oe.y += n) < term.top) {
+ selclear();
+ return;
+ }
+ if (sel.type == SEL_RECTANGULAR) {
+ if (sel.ob.y < term.top)
+ sel.ob.y = term.top;
+ if (sel.oe.y > term.bot)
+ sel.oe.y = term.bot;
+ } else {
+ if (sel.ob.y < term.top) {
+ sel.ob.y = term.top;
+ sel.ob.x = 0;
+ }
+ if (sel.oe.y > term.bot) {
+ sel.oe.y = term.bot;
+ sel.oe.x = term.col;
+ }
+ }
+ selnormalize();
+ }
+}
+
+void
+tnewline(int first_col)
+{
+ int y = term.c.y;
+
+ if (y == term.bot) {
+ tscrollup(term.top, 1);
+ } else {
+ y++;
+ }
+ tmoveto(first_col ? 0 : term.c.x, y);
+}
+
+void
+csiparse(void)
+{
+ char *p = csiescseq.buf, *np;
+ long int v;
+
+ csiescseq.narg = 0;
+ if (*p == '?') {
+ csiescseq.priv = 1;
+ p++;
+ }
+
+ csiescseq.buf[csiescseq.len] = '\0';
+ while (p < csiescseq.buf+csiescseq.len) {
+ np = NULL;
+ v = strtol(p, &np, 10);
+ if (np == p)
+ v = 0;
+ if (v == LONG_MAX || v == LONG_MIN)
+ v = -1;
+ csiescseq.arg[csiescseq.narg++] = v;
+ p = np;
+ if (*p != ';' || csiescseq.narg == ESC_ARG_SIZ)
+ break;
+ p++;
+ }
+ csiescseq.mode[0] = *p++;
+ csiescseq.mode[1] = (p < csiescseq.buf+csiescseq.len) ? *p : '\0';
+}
+
+/* for absolute user moves, when decom is set */
+void
+tmoveato(int x, int y)
+{
+ tmoveto(x, y + ((term.c.state & CURSOR_ORIGIN) ? term.top: 0));
+}
+
+void
+tmoveto(int x, int y)
+{
+ int miny, maxy;
+
+ if (term.c.state & CURSOR_ORIGIN) {
+ miny = term.top;
+ maxy = term.bot;
+ } else {
+ miny = 0;
+ maxy = term.row - 1;
+ }
+ term.c.state &= ~CURSOR_WRAPNEXT;
+ term.c.x = LIMIT(x, 0, term.col-1);
+ term.c.y = LIMIT(y, miny, maxy);
+}
+
+void
+tsetchar(Rune u, Glyph *attr, int x, int y)
+{
+ static char *vt100_0[62] = { /* 0x41 - 0x7e */
+ "↑", "↓", "→", "←", "█", "▚", "☃", /* A - G */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* H - O */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* P - W */
+ 0, 0, 0, 0, 0, 0, 0, " ", /* X - _ */
+ "◆", "▒", "␉", "␌", "␍", "␊", "°", "±", /* ` - g */
+ "", "␋", "┘", "┐", "┌", "└", "┼", "⎺", /* h - o */
+ "⎻", "─", "⎼", "⎽", "├", "┤", "┴", "┬", /* p - w */
+ "│", "≤", "≥", "π", "≠", "£", "·", /* x - ~ */
+ };
+
+ /*
+ * The table is proudly stolen from rxvt.
+ */
+ if (term.trantbl[term.charset] == CS_GRAPHIC0 &&
+ BETWEEN(u, 0x41, 0x7e) && vt100_0[u - 0x41])
+ utf8decode(vt100_0[u - 0x41], &u, UTF_SIZ);
+
+ if (term.line[y][x].mode & ATTR_WIDE) {
+ if (x+1 < term.col) {
+ term.line[y][x+1].u = ' ';
+ term.line[y][x+1].mode &= ~ATTR_WDUMMY;
+ }
+ } else if (term.line[y][x].mode & ATTR_WDUMMY) {
+ term.line[y][x-1].u = ' ';
+ term.line[y][x-1].mode &= ~ATTR_WIDE;
+ }
+
+ term.dirty[y] = 1;
+ term.line[y][x] = *attr;
+ term.line[y][x].u = u;
+}
+
+void
+tclearregion(int x1, int y1, int x2, int y2)
+{
+ int x, y, temp;
+ Glyph *gp;
+
+ if (x1 > x2)
+ temp = x1, x1 = x2, x2 = temp;
+ if (y1 > y2)
+ temp = y1, y1 = y2, y2 = temp;
+
+ LIMIT(x1, 0, term.col-1);
+ LIMIT(x2, 0, term.col-1);
+ LIMIT(y1, 0, term.row-1);
+ LIMIT(y2, 0, term.row-1);
+
+ for (y = y1; y <= y2; y++) {
+ term.dirty[y] = 1;
+ for (x = x1; x <= x2; x++) {
+ gp = &term.line[y][x];
+ if (selected(x, y))
+ selclear();
+ gp->fg = term.c.attr.fg;
+ gp->bg = term.c.attr.bg;
+ gp->mode = 0;
+ gp->u = ' ';
+ }
+ }
+}
+
+void
+tdeletechar(int n)
+{
+ int dst, src, size;
+ Glyph *line;
+
+ LIMIT(n, 0, term.col - term.c.x);
+
+ dst = term.c.x;
+ src = term.c.x + n;
+ size = term.col - src;
+ line = term.line[term.c.y];
+
+ memmove(&line[dst], &line[src], size * sizeof(Glyph));
+ tclearregion(term.col-n, term.c.y, term.col-1, term.c.y);
+}
+
+void
+tinsertblank(int n)
+{
+ int dst, src, size;
+ Glyph *line;
+
+ LIMIT(n, 0, term.col - term.c.x);
+
+ dst = term.c.x + n;
+ src = term.c.x;
+ size = term.col - dst;
+ line = term.line[term.c.y];
+
+ memmove(&line[dst], &line[src], size * sizeof(Glyph));
+ tclearregion(src, term.c.y, dst - 1, term.c.y);
+}
+
+void
+tinsertblankline(int n)
+{
+ if (BETWEEN(term.c.y, term.top, term.bot))
+ tscrolldown(term.c.y, n);
+}
+
+void
+tdeleteline(int n)
+{
+ if (BETWEEN(term.c.y, term.top, term.bot))
+ tscrollup(term.c.y, n);
+}
+
+int32_t
+tdefcolor(int *attr, int *npar, int l)
+{
+ int32_t idx = -1;
+ uint r, g, b;
+
+ switch (attr[*npar + 1]) {
+ case 2: /* direct color in RGB space */
+ if (*npar + 4 >= l) {
+ fprintf(stderr,
+ "erresc(38): Incorrect number of parameters (%d)\n",
+ *npar);
+ break;
+ }
+ r = attr[*npar + 2];
+ g = attr[*npar + 3];
+ b = attr[*npar + 4];
+ *npar += 4;
+ if (!BETWEEN(r, 0, 255) || !BETWEEN(g, 0, 255) || !BETWEEN(b, 0, 255))
+ fprintf(stderr, "erresc: bad rgb color (%u,%u,%u)\n",
+ r, g, b);
+ else
+ idx = TRUECOLOR(r, g, b);
+ break;
+ case 5: /* indexed color */
+ if (*npar + 2 >= l) {
+ fprintf(stderr,
+ "erresc(38): Incorrect number of parameters (%d)\n",
+ *npar);
+ break;
+ }
+ *npar += 2;
+ if (!BETWEEN(attr[*npar], 0, 255))
+ fprintf(stderr, "erresc: bad fgcolor %d\n", attr[*npar]);
+ else
+ idx = attr[*npar];
+ break;
+ case 0: /* implemented defined (only foreground) */
+ case 1: /* transparent */
+ case 3: /* direct color in CMY space */
+ case 4: /* direct color in CMYK space */
+ default:
+ fprintf(stderr,
+ "erresc(38): gfx attr %d unknown\n", attr[*npar]);
+ break;
+ }
+
+ return idx;
+}
+
+void
+tsetattr(int *attr, int l)
+{
+ int i;
+ int32_t idx;
+
+ for (i = 0; i < l; i++) {
+ switch (attr[i]) {
+ case 0:
+ term.c.attr.mode &= ~(
+ ATTR_BOLD |
+ ATTR_FAINT |
+ ATTR_ITALIC |
+ ATTR_UNDERLINE |
+ ATTR_BLINK |
+ ATTR_REVERSE |
+ ATTR_INVISIBLE |
+ ATTR_STRUCK );
+ term.c.attr.fg = defaultfg;
+ term.c.attr.bg = defaultbg;
+ break;
+ case 1:
+ term.c.attr.mode |= ATTR_BOLD;
+ break;
+ case 2:
+ term.c.attr.mode |= ATTR_FAINT;
+ break;
+ case 3:
+ term.c.attr.mode |= ATTR_ITALIC;
+ break;
+ case 4:
+ term.c.attr.mode |= ATTR_UNDERLINE;
+ break;
+ case 5: /* slow blink */
+ /* FALLTHROUGH */
+ case 6: /* rapid blink */
+ term.c.attr.mode |= ATTR_BLINK;
+ break;
+ case 7:
+ term.c.attr.mode |= ATTR_REVERSE;
+ break;
+ case 8:
+ term.c.attr.mode |= ATTR_INVISIBLE;
+ break;
+ case 9:
+ term.c.attr.mode |= ATTR_STRUCK;
+ break;
+ case 22:
+ term.c.attr.mode &= ~(ATTR_BOLD | ATTR_FAINT);
+ break;
+ case 23:
+ term.c.attr.mode &= ~ATTR_ITALIC;
+ break;
+ case 24:
+ term.c.attr.mode &= ~ATTR_UNDERLINE;
+ break;
+ case 25:
+ term.c.attr.mode &= ~ATTR_BLINK;
+ break;
+ case 27:
+ term.c.attr.mode &= ~ATTR_REVERSE;
+ break;
+ case 28:
+ term.c.attr.mode &= ~ATTR_INVISIBLE;
+ break;
+ case 29:
+ term.c.attr.mode &= ~ATTR_STRUCK;
+ break;
+ case 38:
+ if ((idx = tdefcolor(attr, &i, l)) >= 0)
+ term.c.attr.fg = idx;
+ break;
+ case 39:
+ term.c.attr.fg = defaultfg;
+ break;
+ case 48:
+ if ((idx = tdefcolor(attr, &i, l)) >= 0)
+ term.c.attr.bg = idx;
+ break;
+ case 49:
+ term.c.attr.bg = defaultbg;
+ break;
+ default:
+ if (BETWEEN(attr[i], 30, 37)) {
+ term.c.attr.fg = attr[i] - 30;
+ } else if (BETWEEN(attr[i], 40, 47)) {
+ term.c.attr.bg = attr[i] - 40;
+ } else if (BETWEEN(attr[i], 90, 97)) {
+ term.c.attr.fg = attr[i] - 90 + 8;
+ } else if (BETWEEN(attr[i], 100, 107)) {
+ term.c.attr.bg = attr[i] - 100 + 8;
+ } else {
+ fprintf(stderr,
+ "erresc(default): gfx attr %d unknown\n",
+ attr[i]);
+ csidump();
+ }
+ break;
+ }
+ }
+}
+
+void
+tsetscroll(int t, int b)
+{
+ int temp;
+
+ LIMIT(t, 0, term.row-1);
+ LIMIT(b, 0, term.row-1);
+ if (t > b) {
+ temp = t;
+ t = b;
+ b = temp;
+ }
+ term.top = t;
+ term.bot = b;
+}
+
+void
+tsetmode(int priv, int set, int *args, int narg)
+{
+ int alt, *lim;
+
+ for (lim = args + narg; args < lim; ++args) {
+ if (priv) {
+ switch (*args) {
+ case 1: /* DECCKM -- Cursor key */
+ xsetmode(set, MODE_APPCURSOR);
+ break;
+ case 5: /* DECSCNM -- Reverse video */
+ xsetmode(set, MODE_REVERSE);
+ break;
+ case 6: /* DECOM -- Origin */
+ MODBIT(term.c.state, set, CURSOR_ORIGIN);
+ tmoveato(0, 0);
+ break;
+ case 7: /* DECAWM -- Auto wrap */
+ MODBIT(term.mode, set, MODE_WRAP);
+ break;
+ case 0: /* Error (IGNORED) */
+ case 2: /* DECANM -- ANSI/VT52 (IGNORED) */
+ case 3: /* DECCOLM -- Column (IGNORED) */
+ case 4: /* DECSCLM -- Scroll (IGNORED) */
+ case 8: /* DECARM -- Auto repeat (IGNORED) */
+ case 18: /* DECPFF -- Printer feed (IGNORED) */
+ case 19: /* DECPEX -- Printer extent (IGNORED) */
+ case 42: /* DECNRCM -- National characters (IGNORED) */
+ case 12: /* att610 -- Start blinking cursor (IGNORED) */
+ break;
+ case 25: /* DECTCEM -- Text Cursor Enable Mode */
+ xsetmode(!set, MODE_HIDE);
+ break;
+ case 9: /* X10 mouse compatibility mode */
+ xsetpointermotion(0);
+ xsetmode(0, MODE_MOUSE);
+ xsetmode(set, MODE_MOUSEX10);
+ break;
+ case 1000: /* 1000: report button press */
+ xsetpointermotion(0);
+ xsetmode(0, MODE_MOUSE);
+ xsetmode(set, MODE_MOUSEBTN);
+ break;
+ case 1002: /* 1002: report motion on button press */
+ xsetpointermotion(0);
+ xsetmode(0, MODE_MOUSE);
+ xsetmode(set, MODE_MOUSEMOTION);
+ break;
+ case 1003: /* 1003: enable all mouse motions */
+ xsetpointermotion(set);
+ xsetmode(0, MODE_MOUSE);
+ xsetmode(set, MODE_MOUSEMANY);
+ break;
+ case 1004: /* 1004: send focus events to tty */
+ xsetmode(set, MODE_FOCUS);
+ break;
+ case 1006: /* 1006: extended reporting mode */
+ xsetmode(set, MODE_MOUSESGR);
+ break;
+ case 1034:
+ xsetmode(set, MODE_8BIT);
+ break;
+ case 1049: /* swap screen & set/restore cursor as xterm */
+ if (!allowaltscreen)
+ break;
+ tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
+ /* FALLTHROUGH */
+ case 47: /* swap screen */
+ case 1047:
+ if (!allowaltscreen)
+ break;
+ alt = IS_SET(MODE_ALTSCREEN);
+ if (alt) {
+ tclearregion(0, 0, term.col-1,
+ term.row-1);
+ }
+ if (set ^ alt) /* set is always 1 or 0 */
+ tswapscreen();
+ if (*args != 1049)
+ break;
+ /* FALLTHROUGH */
+ case 1048:
+ tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
+ break;
+ case 2004: /* 2004: bracketed paste mode */
+ xsetmode(set, MODE_BRCKTPASTE);
+ break;
+ /* Not implemented mouse modes. See comments there. */
+ case 1001: /* mouse highlight mode; can hang the
+ terminal by design when implemented. */
+ case 1005: /* UTF-8 mouse mode; will confuse
+ applications not supporting UTF-8
+ and luit. */
+ case 1015: /* urxvt mangled mouse mode; incompatible
+ and can be mistaken for other control
+ codes. */
+ default:
+ fprintf(stderr,
+ "erresc: unknown private set/reset mode %d\n",
+ *args);
+ break;
+ }
+ } else {
+ switch (*args) {
+ case 0: /* Error (IGNORED) */
+ break;
+ case 2:
+ xsetmode(set, MODE_KBDLOCK);
+ break;
+ case 4: /* IRM -- Insertion-replacement */
+ MODBIT(term.mode, set, MODE_INSERT);
+ break;
+ case 12: /* SRM -- Send/Receive */
+ MODBIT(term.mode, !set, MODE_ECHO);
+ break;
+ case 20: /* LNM -- Linefeed/new line */
+ MODBIT(term.mode, set, MODE_CRLF);
+ break;
+ default:
+ fprintf(stderr,
+ "erresc: unknown set/reset mode %d\n",
+ *args);
+ break;
+ }
+ }
+ }
+}
+
+void
+csihandle(void)
+{
+ char buf[40];
+ int len;
+
+ switch (csiescseq.mode[0]) {
+ default:
+ unknown:
+ fprintf(stderr, "erresc: unknown csi ");
+ csidump();
+ /* die(""); */
+ break;
+ case '@': /* ICH -- Insert <n> blank char */
+ DEFAULT(csiescseq.arg[0], 1);
+ tinsertblank(csiescseq.arg[0]);
+ break;
+ case 'A': /* CUU -- Cursor <n> Up */
+ DEFAULT(csiescseq.arg[0], 1);
+ tmoveto(term.c.x, term.c.y-csiescseq.arg[0]);
+ break;
+ case 'B': /* CUD -- Cursor <n> Down */
+ case 'e': /* VPR --Cursor <n> Down */
+ DEFAULT(csiescseq.arg[0], 1);
+ tmoveto(term.c.x, term.c.y+csiescseq.arg[0]);
+ break;
+ case 'i': /* MC -- Media Copy */
+ switch (csiescseq.arg[0]) {
+ case 0:
+ tdump();
+ break;
+ case 1:
+ tdumpline(term.c.y);
+ break;
+ case 2:
+ tdumpsel();
+ break;
+ case 4:
+ term.mode &= ~MODE_PRINT;
+ break;
+ case 5:
+ term.mode |= MODE_PRINT;
+ break;
+ }
+ break;
+ case 'c': /* DA -- Device Attributes */
+ if (csiescseq.arg[0] == 0)
+ ttywrite(vtiden, strlen(vtiden), 0);
+ break;
+ case 'C': /* CUF -- Cursor <n> Forward */
+ case 'a': /* HPR -- Cursor <n> Forward */
+ DEFAULT(csiescseq.arg[0], 1);
+ tmoveto(term.c.x+csiescseq.arg[0], term.c.y);
+ break;
+ case 'D': /* CUB -- Cursor <n> Backward */
+ DEFAULT(csiescseq.arg[0], 1);
+ tmoveto(term.c.x-csiescseq.arg[0], term.c.y);
+ break;
+ case 'E': /* CNL -- Cursor <n> Down and first col */
+ DEFAULT(csiescseq.arg[0], 1);
+ tmoveto(0, term.c.y+csiescseq.arg[0]);
+ break;
+ case 'F': /* CPL -- Cursor <n> Up and first col */
+ DEFAULT(csiescseq.arg[0], 1);
+ tmoveto(0, term.c.y-csiescseq.arg[0]);
+ break;
+ case 'g': /* TBC -- Tabulation clear */
+ switch (csiescseq.arg[0]) {
+ case 0: /* clear current tab stop */
+ term.tabs[term.c.x] = 0;
+ break;
+ case 3: /* clear all the tabs */
+ memset(term.tabs, 0, term.col * sizeof(*term.tabs));
+ break;
+ default:
+ goto unknown;
+ }
+ break;
+ case 'G': /* CHA -- Move to <col> */
+ case '`': /* HPA */
+ DEFAULT(csiescseq.arg[0], 1);
+ tmoveto(csiescseq.arg[0]-1, term.c.y);
+ break;
+ case 'H': /* CUP -- Move to <row> <col> */
+ case 'f': /* HVP */
+ DEFAULT(csiescseq.arg[0], 1);
+ DEFAULT(csiescseq.arg[1], 1);
+ tmoveato(csiescseq.arg[1]-1, csiescseq.arg[0]-1);
+ break;
+ case 'I': /* CHT -- Cursor Forward Tabulation <n> tab stops */
+ DEFAULT(csiescseq.arg[0], 1);
+ tputtab(csiescseq.arg[0]);
+ break;
+ case 'J': /* ED -- Clear screen */
+ switch (csiescseq.arg[0]) {
+ case 0: /* below */
+ tclearregion(term.c.x, term.c.y, term.col-1, term.c.y);
+ if (term.c.y < term.row-1) {
+ tclearregion(0, term.c.y+1, term.col-1,
+ term.row-1);
+ }
+ break;
+ case 1: /* above */
+ if (term.c.y > 1)
+ tclearregion(0, 0, term.col-1, term.c.y-1);
+ tclearregion(0, term.c.y, term.c.x, term.c.y);
+ break;
+ case 2: /* all */
+ tclearregion(0, 0, term.col-1, term.row-1);
+ break;
+ default:
+ goto unknown;
+ }
+ break;
+ case 'K': /* EL -- Clear line */
+ switch (csiescseq.arg[0]) {
+ case 0: /* right */
+ tclearregion(term.c.x, term.c.y, term.col-1,
+ term.c.y);
+ break;
+ case 1: /* left */
+ tclearregion(0, term.c.y, term.c.x, term.c.y);
+ break;
+ case 2: /* all */
+ tclearregion(0, term.c.y, term.col-1, term.c.y);
+ break;
+ }
+ break;
+ case 'S': /* SU -- Scroll <n> line up */
+ DEFAULT(csiescseq.arg[0], 1);
+ tscrollup(term.top, csiescseq.arg[0]);
+ break;
+ case 'T': /* SD -- Scroll <n> line down */
+ DEFAULT(csiescseq.arg[0], 1);
+ tscrolldown(term.top, csiescseq.arg[0]);
+ break;
+ case 'L': /* IL -- Insert <n> blank lines */
+ DEFAULT(csiescseq.arg[0], 1);
+ tinsertblankline(csiescseq.arg[0]);
+ break;
+ case 'l': /* RM -- Reset Mode */
+ tsetmode(csiescseq.priv, 0, csiescseq.arg, csiescseq.narg);
+ break;
+ case 'M': /* DL -- Delete <n> lines */
+ DEFAULT(csiescseq.arg[0], 1);
+ tdeleteline(csiescseq.arg[0]);
+ break;
+ case 'X': /* ECH -- Erase <n> char */
+ DEFAULT(csiescseq.arg[0], 1);
+ tclearregion(term.c.x, term.c.y,
+ term.c.x + csiescseq.arg[0] - 1, term.c.y);
+ break;
+ case 'P': /* DCH -- Delete <n> char */
+ DEFAULT(csiescseq.arg[0], 1);
+ tdeletechar(csiescseq.arg[0]);
+ break;
+ case 'Z': /* CBT -- Cursor Backward Tabulation <n> tab stops */
+ DEFAULT(csiescseq.arg[0], 1);
+ tputtab(-csiescseq.arg[0]);
+ break;
+ case 'd': /* VPA -- Move to <row> */
+ DEFAULT(csiescseq.arg[0], 1);
+ tmoveato(term.c.x, csiescseq.arg[0]-1);
+ break;
+ case 'h': /* SM -- Set terminal mode */
+ tsetmode(csiescseq.priv, 1, csiescseq.arg, csiescseq.narg);
+ break;
+ case 'm': /* SGR -- Terminal attribute (color) */
+ tsetattr(csiescseq.arg, csiescseq.narg);
+ break;
+ case 'n': /* DSR – Device Status Report (cursor position) */
+ if (csiescseq.arg[0] == 6) {
+ len = snprintf(buf, sizeof(buf),"\033[%i;%iR",
+ term.c.y+1, term.c.x+1);
+ ttywrite(buf, len, 0);
+ }
+ break;
+ case 'r': /* DECSTBM -- Set Scrolling Region */
+ if (csiescseq.priv) {
+ goto unknown;
+ } else {
+ DEFAULT(csiescseq.arg[0], 1);
+ DEFAULT(csiescseq.arg[1], term.row);
+ tsetscroll(csiescseq.arg[0]-1, csiescseq.arg[1]-1);
+ tmoveato(0, 0);
+ }
+ break;
+ case 's': /* DECSC -- Save cursor position (ANSI.SYS) */
+ tcursor(CURSOR_SAVE);
+ break;
+ case 'u': /* DECRC -- Restore cursor position (ANSI.SYS) */
+ tcursor(CURSOR_LOAD);
+ break;
+ case ' ':
+ switch (csiescseq.mode[1]) {
+ case 'q': /* DECSCUSR -- Set Cursor Style */
+ if (xsetcursor(csiescseq.arg[0]))
+ goto unknown;
+ break;
+ default:
+ goto unknown;
+ }
+ break;
+ }
+}
+
+void
+csidump(void)
+{
+ int i;
+ uint c;
+
+ fprintf(stderr, "ESC[");
+ for (i = 0; i < csiescseq.len; i++) {
+ c = csiescseq.buf[i] & 0xff;
+ if (isprint(c)) {
+ putc(c, stderr);
+ } else if (c == '\n') {
+ fprintf(stderr, "(\\n)");
+ } else if (c == '\r') {
+ fprintf(stderr, "(\\r)");
+ } else if (c == 0x1b) {
+ fprintf(stderr, "(\\e)");
+ } else {
+ fprintf(stderr, "(%02x)", c);
+ }
+ }
+ putc('\n', stderr);
+}
+
+void
+csireset(void)
+{
+ memset(&csiescseq, 0, sizeof(csiescseq));
+}
+
+void
+strhandle(void)
+{
+ char *p = NULL;
+ int j, narg, par;
+
+ term.esc &= ~(ESC_STR_END|ESC_STR);
+ strparse();
+ par = (narg = strescseq.narg) ? atoi(strescseq.args[0]) : 0;
+
+ switch (strescseq.type) {
+ case ']': /* OSC -- Operating System Command */
+ switch (par) {
+ case 0:
+ case 1:
+ case 2:
+ if (narg > 1)
+ xsettitle(strescseq.args[1]);
+ return;
+ case 52:
+ if (narg > 2) {
+ char *dec;
+
+ dec = base64dec(strescseq.args[2]);
+ if (dec) {
+ xsetsel(dec);
+ xclipcopy();
+ } else {
+ fprintf(stderr, "erresc: invalid base64\n");
+ }
+ }
+ return;
+ case 4: /* color set */
+ if (narg < 3)
+ break;
+ p = strescseq.args[2];
+ /* FALLTHROUGH */
+ case 104: /* color reset, here p = NULL */
+ j = (narg > 1) ? atoi(strescseq.args[1]) : -1;
+ if (xsetcolorname(j, p)) {
+ fprintf(stderr, "erresc: invalid color %s\n", p);
+ } else {
+ /*
+ * TODO if defaultbg color is changed, borders
+ * are dirty
+ */
+ redraw();
+ }
+ return;
+ }
+ break;
+ case 'k': /* old title set compatibility */
+ xsettitle(strescseq.args[0]);
+ return;
+ case 'P': /* DCS -- Device Control String */
+ term.mode |= ESC_DCS;
+ case '_': /* APC -- Application Program Command */
+ case '^': /* PM -- Privacy Message */
+ return;
+ }
+
+ fprintf(stderr, "erresc: unknown str ");
+ strdump();
+}
+
+void
+strparse(void)
+{
+ int c;
+ char *p = strescseq.buf;
+
+ strescseq.narg = 0;
+ strescseq.buf[strescseq.len] = '\0';
+
+ if (*p == '\0')
+ return;
+
+ while (strescseq.narg < STR_ARG_SIZ) {
+ strescseq.args[strescseq.narg++] = p;
+ while ((c = *p) != ';' && c != '\0')
+ ++p;
+ if (c == '\0')
+ return;
+ *p++ = '\0';
+ }
+}
+
+void
+strdump(void)
+{
+ int i;
+ uint c;
+
+ fprintf(stderr, "ESC%c", strescseq.type);
+ for (i = 0; i < strescseq.len; i++) {
+ c = strescseq.buf[i] & 0xff;
+ if (c == '\0') {
+ putc('\n', stderr);
+ return;
+ } else if (isprint(c)) {
+ putc(c, stderr);
+ } else if (c == '\n') {
+ fprintf(stderr, "(\\n)");
+ } else if (c == '\r') {
+ fprintf(stderr, "(\\r)");
+ } else if (c == 0x1b) {
+ fprintf(stderr, "(\\e)");
+ } else {
+ fprintf(stderr, "(%02x)", c);
+ }
+ }
+ fprintf(stderr, "ESC\\\n");
+}
+
+void
+strreset(void)
+{
+ memset(&strescseq, 0, sizeof(strescseq));
+}
+
+void
+sendbreak(const Arg *arg)
+{
+ if (tcsendbreak(cmdfd, 0))
+ perror("Error sending break");
+}
+
+void
+tprinter(char *s, size_t len)
+{
+ if (iofd != -1 && xwrite(iofd, s, len) < 0) {
+ perror("Error writing to output file");
+ close(iofd);
+ iofd = -1;
+ }
+}
+
+void
+toggleprinter(const Arg *arg)
+{
+ term.mode ^= MODE_PRINT;
+}
+
+void
+printscreen(const Arg *arg)
+{
+ tdump();
+}
+
+void
+printsel(const Arg *arg)
+{
+ tdumpsel();
+}
+
+void
+tdumpsel(void)
+{
+ char *ptr;
+
+ if ((ptr = getsel())) {
+ tprinter(ptr, strlen(ptr));
+ free(ptr);
+ }
+}
+
+void
+tdumpline(int n)
+{
+ char buf[UTF_SIZ];
+ Glyph *bp, *end;
+
+ bp = &term.line[n][0];
+ end = &bp[MIN(tlinelen(n), term.col) - 1];
+ if (bp != end || bp->u != ' ') {
+ for ( ;bp <= end; ++bp)
+ tprinter(buf, utf8encode(bp->u, buf));
+ }
+ tprinter("\n", 1);
+}
+
+void
+tdump(void)
+{
+ int i;
+
+ for (i = 0; i < term.row; ++i)
+ tdumpline(i);
+}
+
+void
+tputtab(int n)
+{
+ uint x = term.c.x;
+
+ if (n > 0) {
+ while (x < term.col && n--)
+ for (++x; x < term.col && !term.tabs[x]; ++x)
+ /* nothing */ ;
+ } else if (n < 0) {
+ while (x > 0 && n++)
+ for (--x; x > 0 && !term.tabs[x]; --x)
+ /* nothing */ ;
+ }
+ term.c.x = LIMIT(x, 0, term.col-1);
+}
+
+void
+tdefutf8(char ascii)
+{
+ if (ascii == 'G')
+ term.mode |= MODE_UTF8;
+ else if (ascii == '@')
+ term.mode &= ~MODE_UTF8;
+}
+
+void
+tdeftran(char ascii)
+{
+ static char cs[] = "0B";
+ static int vcs[] = {CS_GRAPHIC0, CS_USA};
+ char *p;
+
+ if ((p = strchr(cs, ascii)) == NULL) {
+ fprintf(stderr, "esc unhandled charset: ESC ( %c\n", ascii);
+ } else {
+ term.trantbl[term.icharset] = vcs[p - cs];
+ }
+}
+
+void
+tdectest(char c)
+{
+ int x, y;
+
+ if (c == '8') { /* DEC screen alignment test. */
+ for (x = 0; x < term.col; ++x) {
+ for (y = 0; y < term.row; ++y)
+ tsetchar('E', &term.c.attr, x, y);
+ }
+ }
+}
+
+void
+tstrsequence(uchar c)
+{
+ strreset();
+
+ switch (c) {
+ case 0x90: /* DCS -- Device Control String */
+ c = 'P';
+ term.esc |= ESC_DCS;
+ break;
+ case 0x9f: /* APC -- Application Program Command */
+ c = '_';
+ break;
+ case 0x9e: /* PM -- Privacy Message */
+ c = '^';
+ break;
+ case 0x9d: /* OSC -- Operating System Command */
+ c = ']';
+ break;
+ }
+ strescseq.type = c;
+ term.esc |= ESC_STR;
+}
+
+void
+tcontrolcode(uchar ascii)
+{
+ switch (ascii) {
+ case '\t': /* HT */
+ tputtab(1);
+ return;
+ case '\b': /* BS */
+ tmoveto(term.c.x-1, term.c.y);
+ return;
+ case '\r': /* CR */
+ tmoveto(0, term.c.y);
+ return;
+ case '\f': /* LF */
+ case '\v': /* VT */
+ case '\n': /* LF */
+ /* go to first col if the mode is set */
+ tnewline(IS_SET(MODE_CRLF));
+ return;
+ case '\a': /* BEL */
+ if (term.esc & ESC_STR_END) {
+ /* backwards compatibility to xterm */
+ strhandle();
+ } else {
+ xbell();
+ }
+ break;
+ case '\033': /* ESC */
+ csireset();
+ term.esc &= ~(ESC_CSI|ESC_ALTCHARSET|ESC_TEST);
+ term.esc |= ESC_START;
+ return;
+ case '\016': /* SO (LS1 -- Locking shift 1) */
+ case '\017': /* SI (LS0 -- Locking shift 0) */
+ term.charset = 1 - (ascii - '\016');
+ return;
+ case '\032': /* SUB */
+ tsetchar('?', &term.c.attr, term.c.x, term.c.y);
+ case '\030': /* CAN */
+ csireset();
+ break;
+ case '\005': /* ENQ (IGNORED) */
+ case '\000': /* NUL (IGNORED) */
+ case '\021': /* XON (IGNORED) */
+ case '\023': /* XOFF (IGNORED) */
+ case 0177: /* DEL (IGNORED) */
+ return;
+ case 0x80: /* TODO: PAD */
+ case 0x81: /* TODO: HOP */
+ case 0x82: /* TODO: BPH */
+ case 0x83: /* TODO: NBH */
+ case 0x84: /* TODO: IND */
+ break;
+ case 0x85: /* NEL -- Next line */
+ tnewline(1); /* always go to first col */
+ break;
+ case 0x86: /* TODO: SSA */
+ case 0x87: /* TODO: ESA */
+ break;
+ case 0x88: /* HTS -- Horizontal tab stop */
+ term.tabs[term.c.x] = 1;
+ break;
+ case 0x89: /* TODO: HTJ */
+ case 0x8a: /* TODO: VTS */
+ case 0x8b: /* TODO: PLD */
+ case 0x8c: /* TODO: PLU */
+ case 0x8d: /* TODO: RI */
+ case 0x8e: /* TODO: SS2 */
+ case 0x8f: /* TODO: SS3 */
+ case 0x91: /* TODO: PU1 */
+ case 0x92: /* TODO: PU2 */
+ case 0x93: /* TODO: STS */
+ case 0x94: /* TODO: CCH */
+ case 0x95: /* TODO: MW */
+ case 0x96: /* TODO: SPA */
+ case 0x97: /* TODO: EPA */
+ case 0x98: /* TODO: SOS */
+ case 0x99: /* TODO: SGCI */
+ break;
+ case 0x9a: /* DECID -- Identify Terminal */
+ ttywrite(vtiden, strlen(vtiden), 0);
+ break;
+ case 0x9b: /* TODO: CSI */
+ case 0x9c: /* TODO: ST */
+ break;
+ case 0x90: /* DCS -- Device Control String */
+ case 0x9d: /* OSC -- Operating System Command */
+ case 0x9e: /* PM -- Privacy Message */
+ case 0x9f: /* APC -- Application Program Command */
+ tstrsequence(ascii);
+ return;
+ }
+ /* only CAN, SUB, \a and C1 chars interrupt a sequence */
+ term.esc &= ~(ESC_STR_END|ESC_STR);
+}
+
+/*
+ * returns 1 when the sequence is finished and it hasn't to read
+ * more characters for this sequence, otherwise 0
+ */
+int
+eschandle(uchar ascii)
+{
+ switch (ascii) {
+ case '[':
+ term.esc |= ESC_CSI;
+ return 0;
+ case '#':
+ term.esc |= ESC_TEST;
+ return 0;
+ case '%':
+ term.esc |= ESC_UTF8;
+ return 0;
+ case 'P': /* DCS -- Device Control String */
+ case '_': /* APC -- Application Program Command */
+ case '^': /* PM -- Privacy Message */
+ case ']': /* OSC -- Operating System Command */
+ case 'k': /* old title set compatibility */
+ tstrsequence(ascii);
+ return 0;
+ case 'n': /* LS2 -- Locking shift 2 */
+ case 'o': /* LS3 -- Locking shift 3 */
+ term.charset = 2 + (ascii - 'n');
+ break;
+ case '(': /* GZD4 -- set primary charset G0 */
+ case ')': /* G1D4 -- set secondary charset G1 */
+ case '*': /* G2D4 -- set tertiary charset G2 */
+ case '+': /* G3D4 -- set quaternary charset G3 */
+ term.icharset = ascii - '(';
+ term.esc |= ESC_ALTCHARSET;
+ return 0;
+ case 'D': /* IND -- Linefeed */
+ if (term.c.y == term.bot) {
+ tscrollup(term.top, 1);
+ } else {
+ tmoveto(term.c.x, term.c.y+1);
+ }
+ break;
+ case 'E': /* NEL -- Next line */
+ tnewline(1); /* always go to first col */
+ break;
+ case 'H': /* HTS -- Horizontal tab stop */
+ term.tabs[term.c.x] = 1;
+ break;
+ case 'M': /* RI -- Reverse index */
+ if (term.c.y == term.top) {
+ tscrolldown(term.top, 1);
+ } else {
+ tmoveto(term.c.x, term.c.y-1);
+ }
+ break;
+ case 'Z': /* DECID -- Identify Terminal */
+ ttywrite(vtiden, strlen(vtiden), 0);
+ break;
+ case 'c': /* RIS -- Reset to initial state */
+ treset();
+ resettitle();
+ xloadcols();
+ break;
+ case '=': /* DECPAM -- Application keypad */
+ xsetmode(1, MODE_APPKEYPAD);
+ break;
+ case '>': /* DECPNM -- Normal keypad */
+ xsetmode(0, MODE_APPKEYPAD);
+ break;
+ case '7': /* DECSC -- Save Cursor */
+ tcursor(CURSOR_SAVE);
+ break;
+ case '8': /* DECRC -- Restore Cursor */
+ tcursor(CURSOR_LOAD);
+ break;
+ case '\\': /* ST -- String Terminator */
+ if (term.esc & ESC_STR_END)
+ strhandle();
+ break;
+ default:
+ fprintf(stderr, "erresc: unknown sequence ESC 0x%02X '%c'\n",
+ (uchar) ascii, isprint(ascii)? ascii:'.');
+ break;
+ }
+ return 1;
+}
+
+void
+tputc(Rune u)
+{
+ char c[UTF_SIZ];
+ int control;
+ int width, len;
+ Glyph *gp;
+
+ control = ISCONTROL(u);
+ if (!IS_SET(MODE_UTF8) && !IS_SET(MODE_SIXEL)) {
+ c[0] = u;
+ width = len = 1;
+ } else {
+ len = utf8encode(u, c);
+ if (!control && (width = wcwidth(u)) == -1) {
+ memcpy(c, "\357\277\275", 4); /* UTF_INVALID */
+ width = 1;
+ }
+ }
+
+ if (IS_SET(MODE_PRINT))
+ tprinter(c, len);
+
+ /*
+ * STR sequence must be checked before anything else
+ * because it uses all following characters until it
+ * receives a ESC, a SUB, a ST or any other C1 control
+ * character.
+ */
+ if (term.esc & ESC_STR) {
+ if (u == '\a' || u == 030 || u == 032 || u == 033 ||
+ ISCONTROLC1(u)) {
+ term.esc &= ~(ESC_START|ESC_STR|ESC_DCS);
+ if (IS_SET(MODE_SIXEL)) {
+ /* TODO: render sixel */;
+ term.mode &= ~MODE_SIXEL;
+ return;
+ }
+ term.esc |= ESC_STR_END;
+ goto check_control_code;
+ }
+
+
+ if (IS_SET(MODE_SIXEL)) {
+ /* TODO: implement sixel mode */
+ return;
+ }
+ if (term.esc&ESC_DCS && strescseq.len == 0 && u == 'q')
+ term.mode |= MODE_SIXEL;
+
+ if (strescseq.len+len >= sizeof(strescseq.buf)-1) {
+ /*
+ * Here is a bug in terminals. If the user never sends
+ * some code to stop the str or esc command, then st
+ * will stop responding. But this is better than
+ * silently failing with unknown characters. At least
+ * then users will report back.
+ *
+ * In the case users ever get fixed, here is the code:
+ */
+ /*
+ * term.esc = 0;
+ * strhandle();
+ */
+ return;
+ }
+
+ memmove(&strescseq.buf[strescseq.len], c, len);
+ strescseq.len += len;
+ return;
+ }
+
+check_control_code:
+ /*
+ * Actions of control codes must be performed as soon they arrive
+ * because they can be embedded inside a control sequence, and
+ * they must not cause conflicts with sequences.
+ */
+ if (control) {
+ tcontrolcode(u);
+ /*
+ * control codes are not shown ever
+ */
+ return;
+ } else if (term.esc & ESC_START) {
+ if (term.esc & ESC_CSI) {
+ csiescseq.buf[csiescseq.len++] = u;
+ if (BETWEEN(u, 0x40, 0x7E)
+ || csiescseq.len >= \
+ sizeof(csiescseq.buf)-1) {
+ term.esc = 0;
+ csiparse();
+ csihandle();
+ }
+ return;
+ } else if (term.esc & ESC_UTF8) {
+ tdefutf8(u);
+ } else if (term.esc & ESC_ALTCHARSET) {
+ tdeftran(u);
+ } else if (term.esc & ESC_TEST) {
+ tdectest(u);
+ } else {
+ if (!eschandle(u))
+ return;
+ /* sequence already finished */
+ }
+ term.esc = 0;
+ /*
+ * All characters which form part of a sequence are not
+ * printed
+ */
+ return;
+ }
+ if (sel.ob.x != -1 && BETWEEN(term.c.y, sel.ob.y, sel.oe.y))
+ selclear();
+
+ gp = &term.line[term.c.y][term.c.x];
+ if (IS_SET(MODE_WRAP) && (term.c.state & CURSOR_WRAPNEXT)) {
+ gp->mode |= ATTR_WRAP;
+ tnewline(1);
+ gp = &term.line[term.c.y][term.c.x];
+ }
+
+ if (IS_SET(MODE_INSERT) && term.c.x+width < term.col)
+ memmove(gp+width, gp, (term.col - term.c.x - width) * sizeof(Glyph));
+
+ if (term.c.x+width > term.col) {
+ tnewline(1);
+ gp = &term.line[term.c.y][term.c.x];
+ }
+
+ tsetchar(u, &term.c.attr, term.c.x, term.c.y);
+
+ if (width == 2) {
+ gp->mode |= ATTR_WIDE;
+ if (term.c.x+1 < term.col) {
+ gp[1].u = '\0';
+ gp[1].mode = ATTR_WDUMMY;
+ }
+ }
+ if (term.c.x+width < term.col) {
+ tmoveto(term.c.x+width, term.c.y);
+ } else {
+ term.c.state |= CURSOR_WRAPNEXT;
+ }
+}
+
+int
+twrite(const char *buf, int buflen, int show_ctrl)
+{
+ int charsize;
+ Rune u;
+ int n;
+
+ for (n = 0; n < buflen; n += charsize) {
+ if (IS_SET(MODE_UTF8) && !IS_SET(MODE_SIXEL)) {
+ /* process a complete utf8 char */
+ charsize = utf8decode(buf + n, &u, buflen - n);
+ if (charsize == 0)
+ break;
+ } else {
+ u = buf[n] & 0xFF;
+ charsize = 1;
+ }
+ if (show_ctrl && ISCONTROL(u)) {
+ if (u & 0x80) {
+ u &= 0x7f;
+ tputc('^');
+ tputc('[');
+ } else if (u != '\n' && u != '\r' && u != '\t') {
+ u ^= 0x40;
+ tputc('^');
+ }
+ }
+ tputc(u);
+ }
+ return n;
+}
+
+void
+tresize(int col, int row)
+{
+ int i;
+ int minrow = MIN(row, term.row);
+ int mincol = MIN(col, term.col);
+ int *bp;
+ TCursor c;
+
+ if (col < 1 || row < 1) {
+ fprintf(stderr,
+ "tresize: error resizing to %dx%d\n", col, row);
+ return;
+ }
+
+ /*
+ * slide screen to keep cursor where we expect it -
+ * tscrollup would work here, but we can optimize to
+ * memmove because we're freeing the earlier lines
+ */
+ for (i = 0; i <= term.c.y - row; i++) {
+ free(term.line[i]);
+ free(term.alt[i]);
+ }
+ /* ensure that both src and dst are not NULL */
+ if (i > 0) {
+ memmove(term.line, term.line + i, row * sizeof(Line));
+ memmove(term.alt, term.alt + i, row * sizeof(Line));
+ }
+ for (i += row; i < term.row; i++) {
+ free(term.line[i]);
+ free(term.alt[i]);
+ }
+
+ /* resize to new height */
+ term.line = xrealloc(term.line, row * sizeof(Line));
+ term.alt = xrealloc(term.alt, row * sizeof(Line));
+ term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty));
+ term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs));
+
+ /* resize each row to new width, zero-pad if needed */
+ for (i = 0; i < minrow; i++) {
+ term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
+ term.alt[i] = xrealloc(term.alt[i], col * sizeof(Glyph));
+ }
+
+ /* allocate any new rows */
+ for (/* i = minrow */; i < row; i++) {
+ term.line[i] = xmalloc(col * sizeof(Glyph));
+ term.alt[i] = xmalloc(col * sizeof(Glyph));
+ }
+ if (col > term.col) {
+ bp = term.tabs + term.col;
+
+ memset(bp, 0, sizeof(*term.tabs) * (col - term.col));
+ while (--bp > term.tabs && !*bp)
+ /* nothing */ ;
+ for (bp += tabspaces; bp < term.tabs + col; bp += tabspaces)
+ *bp = 1;
+ }
+ /* update terminal size */
+ term.col = col;
+ term.row = row;
+ /* reset scrolling region */
+ tsetscroll(0, row-1);
+ /* make use of the LIMIT in tmoveto */
+ tmoveto(term.c.x, term.c.y);
+ /* Clearing both screens (it makes dirty all lines) */
+ c = term.c;
+ for (i = 0; i < 2; i++) {
+ if (mincol < col && 0 < minrow) {
+ tclearregion(mincol, 0, col - 1, minrow - 1);
+ }
+ if (0 < col && minrow < row) {
+ tclearregion(0, minrow, col - 1, row - 1);
+ }
+ tswapscreen();
+ tcursor(CURSOR_LOAD);
+ }
+ term.c = c;
+}
+
+void
+resettitle(void)
+{
+ xsettitle(NULL);
+}
+
+void
+drawregion(int x1, int y1, int x2, int y2)
+{
+ int y;
+ for (y = y1; y < y2; y++) {
+ if (!term.dirty[y])
+ continue;
+
+ term.dirty[y] = 0;
+ xdrawline(term.line[y], x1, y, x2);
+ }
+}
+
+void
+draw(void)
+{
+ int cx = term.c.x;
+
+ if (!xstartdraw())
+ return;
+
+ /* adjust cursor position */
+ LIMIT(term.ocx, 0, term.col-1);
+ LIMIT(term.ocy, 0, term.row-1);
+ if (term.line[term.ocy][term.ocx].mode & ATTR_WDUMMY)
+ term.ocx--;
+ if (term.line[term.c.y][cx].mode & ATTR_WDUMMY)
+ cx--;
+
+ drawregion(0, 0, term.col, term.row);
+ xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
+ term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
+ term.ocx = cx, term.ocy = term.c.y;
+ xfinishdraw();
+}
+
+void
+redraw(void)
+{
+ tfulldirt();
+ draw();
+}
diff --git a/terms/st/st-0.8.2/st.h b/terms/st/st-0.8.2/st.h
new file mode 100644
index 0000000..38c61c4
--- /dev/null
+++ b/terms/st/st-0.8.2/st.h
@@ -0,0 +1,122 @@
+/* See LICENSE for license details. */
+
+#include <stdint.h>
+#include <sys/types.h>
+
+/* macros */
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#define MAX(a, b) ((a) < (b) ? (b) : (a))
+#define LEN(a) (sizeof(a) / sizeof(a)[0])
+#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
+#define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
+#define DEFAULT(a, b) (a) = (a) ? (a) : (b)
+#define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
+#define ATTRCMP(a, b) ((a).mode != (b).mode || (a).fg != (b).fg || \
+ (a).bg != (b).bg)
+#define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
+ (t1.tv_nsec-t2.tv_nsec)/1E6)
+#define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
+
+#define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
+#define IS_TRUECOL(x) (1 << 24 & (x))
+
+enum glyph_attribute {
+ ATTR_NULL = 0,
+ ATTR_BOLD = 1 << 0,
+ ATTR_FAINT = 1 << 1,
+ ATTR_ITALIC = 1 << 2,
+ ATTR_UNDERLINE = 1 << 3,
+ ATTR_BLINK = 1 << 4,
+ ATTR_REVERSE = 1 << 5,
+ ATTR_INVISIBLE = 1 << 6,
+ ATTR_STRUCK = 1 << 7,
+ ATTR_WRAP = 1 << 8,
+ ATTR_WIDE = 1 << 9,
+ ATTR_WDUMMY = 1 << 10,
+ ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
+};
+
+enum selection_mode {
+ SEL_IDLE = 0,
+ SEL_EMPTY = 1,
+ SEL_READY = 2
+};
+
+enum selection_type {
+ SEL_REGULAR = 1,
+ SEL_RECTANGULAR = 2
+};
+
+enum selection_snap {
+ SNAP_WORD = 1,
+ SNAP_LINE = 2
+};
+
+typedef unsigned char uchar;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef unsigned short ushort;
+
+typedef uint_least32_t Rune;
+
+#define Glyph Glyph_
+typedef struct {
+ Rune u; /* character code */
+ ushort mode; /* attribute flags */
+ uint32_t fg; /* foreground */
+ uint32_t bg; /* background */
+} Glyph;
+
+typedef Glyph *Line;
+
+typedef union {
+ int i;
+ uint ui;
+ float f;
+ const void *v;
+} Arg;
+
+void die(const char *, ...);
+void redraw(void);
+void draw(void);
+
+void printscreen(const Arg *);
+void printsel(const Arg *);
+void sendbreak(const Arg *);
+void toggleprinter(const Arg *);
+
+int tattrset(int);
+void tnew(int, int);
+void tresize(int, int);
+void tsetdirtattr(int);
+void ttyhangup(void);
+int ttynew(char *, char *, char *, char **);
+size_t ttyread(void);
+void ttyresize(int, int);
+void ttywrite(const char *, size_t, int);
+
+void resettitle(void);
+
+void selclear(void);
+void selinit(void);
+void selstart(int, int, int);
+void selextend(int, int, int, int);
+int selected(int, int);
+char *getsel(void);
+
+size_t utf8encode(Rune, char *);
+
+void *xmalloc(size_t);
+void *xrealloc(void *, size_t);
+char *xstrdup(char *);
+
+/* config.h globals */
+extern char *utmp;
+extern char *stty_args;
+extern char *vtiden;
+extern char *worddelimiters;
+extern int allowaltscreen;
+extern char *termname;
+extern unsigned int tabspaces;
+extern unsigned int defaultfg;
+extern unsigned int defaultbg;
diff --git a/terms/st/st-0.8.2/st.info b/terms/st/st-0.8.2/st.info
new file mode 100644
index 0000000..52fc617
--- /dev/null
+++ b/terms/st/st-0.8.2/st.info
@@ -0,0 +1,222 @@
+st| simpleterm,
+ acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ am,
+ bce,
+ bel=^G,
+ blink=\E[5m,
+ bold=\E[1m,
+ cbt=\E[Z,
+ cvvis=\E[?25h,
+ civis=\E[?25l,
+ clear=\E[H\E[2J,
+ cnorm=\E[?12l\E[?25h,
+ colors#8,
+ cols#80,
+ cr=^M,
+ csr=\E[%i%p1%d;%p2%dr,
+ cub=\E[%p1%dD,
+ cub1=^H,
+ cud1=^J,
+ cud=\E[%p1%dB,
+ cuf1=\E[C,
+ cuf=\E[%p1%dC,
+ cup=\E[%i%p1%d;%p2%dH,
+ cuu1=\E[A,
+ cuu=\E[%p1%dA,
+ dch=\E[%p1%dP,
+ dch1=\E[P,
+ dim=\E[2m,
+ dl=\E[%p1%dM,
+ dl1=\E[M,
+ ech=\E[%p1%dX,
+ ed=\E[J,
+ el=\E[K,
+ el1=\E[1K,
+ enacs=\E)0,
+ flash=\E[?5h$<80/>\E[?5l,
+ fsl=^G,
+ home=\E[H,
+ hpa=\E[%i%p1%dG,
+ hs,
+ ht=^I,
+ hts=\EH,
+ ich=\E[%p1%d@,
+ il1=\E[L,
+ il=\E[%p1%dL,
+ ind=^J,
+ indn=\E[%p1%dS,
+ invis=\E[8m,
+ is2=\E[4l\E>\E[?1034l,
+ it#8,
+ kel=\E[1;2F,
+ ked=\E[1;5F,
+ ka1=\E[1~,
+ ka3=\E[5~,
+ kc1=\E[4~,
+ kc3=\E[6~,
+ kbs=\177,
+ kcbt=\E[Z,
+ kb2=\EOu,
+ kcub1=\EOD,
+ kcud1=\EOB,
+ kcuf1=\EOC,
+ kcuu1=\EOA,
+ kDC=\E[3;2~,
+ kent=\EOM,
+ kEND=\E[1;2F,
+ kIC=\E[2;2~,
+ kNXT=\E[6;2~,
+ kPRV=\E[5;2~,
+ kHOM=\E[1;2H,
+ kLFT=\E[1;2D,
+ kRIT=\E[1;2C,
+ kind=\E[1;2B,
+ kri=\E[1;2A,
+ kclr=\E[3;5~,
+ kdl1=\E[3;2~,
+ kdch1=\E[3~,
+ kich1=\E[2~,
+ kend=\E[4~,
+ kf1=\EOP,
+ kf2=\EOQ,
+ kf3=\EOR,
+ kf4=\EOS,
+ kf5=\E[15~,
+ kf6=\E[17~,
+ kf7=\E[18~,
+ kf8=\E[19~,
+ kf9=\E[20~,
+ kf10=\E[21~,
+ kf11=\E[23~,
+ kf12=\E[24~,
+ kf13=\E[1;2P,
+ kf14=\E[1;2Q,
+ kf15=\E[1;2R,
+ kf16=\E[1;2S,
+ kf17=\E[15;2~,
+ kf18=\E[17;2~,
+ kf19=\E[18;2~,
+ kf20=\E[19;2~,
+ kf21=\E[20;2~,
+ kf22=\E[21;2~,
+ kf23=\E[23;2~,
+ kf24=\E[24;2~,
+ kf25=\E[1;5P,
+ kf26=\E[1;5Q,
+ kf27=\E[1;5R,
+ kf28=\E[1;5S,
+ kf29=\E[15;5~,
+ kf30=\E[17;5~,
+ kf31=\E[18;5~,
+ kf32=\E[19;5~,
+ kf33=\E[20;5~,
+ kf34=\E[21;5~,
+ kf35=\E[23;5~,
+ kf36=\E[24;5~,
+ kf37=\E[1;6P,
+ kf38=\E[1;6Q,
+ kf39=\E[1;6R,
+ kf40=\E[1;6S,
+ kf41=\E[15;6~,
+ kf42=\E[17;6~,
+ kf43=\E[18;6~,
+ kf44=\E[19;6~,
+ kf45=\E[20;6~,
+ kf46=\E[21;6~,
+ kf47=\E[23;6~,
+ kf48=\E[24;6~,
+ kf49=\E[1;3P,
+ kf50=\E[1;3Q,
+ kf51=\E[1;3R,
+ kf52=\E[1;3S,
+ kf53=\E[15;3~,
+ kf54=\E[17;3~,
+ kf55=\E[18;3~,
+ kf56=\E[19;3~,
+ kf57=\E[20;3~,
+ kf58=\E[21;3~,
+ kf59=\E[23;3~,
+ kf60=\E[24;3~,
+ kf61=\E[1;4P,
+ kf62=\E[1;4Q,
+ kf63=\E[1;4R,
+ khome=\E[1~,
+ kil1=\E[2;5~,
+ krmir=\E[2;2~,
+ knp=\E[6~,
+ kmous=\E[M,
+ kpp=\E[5~,
+ lines#24,
+ mir,
+ msgr,
+ npc,
+ op=\E[39;49m,
+ pairs#64,
+ mc0=\E[i,
+ mc4=\E[4i,
+ mc5=\E[5i,
+ rc=\E8,
+ rev=\E[7m,
+ ri=\EM,
+ ritm=\E[23m,
+ rmacs=\E(B,
+ rmcup=\E[?1049l,
+ rmir=\E[4l,
+ rmkx=\E[?1l\E>,
+ rmso=\E[27m,
+ rmul=\E[24m,
+ rs1=\Ec,
+ rs2=\E[4l\E>\E[?1034l,
+ sc=\E7,
+ setab=\E[4%p1%dm,
+ setaf=\E[3%p1%dm,
+ setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
+ setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
+ sgr0=\E[0m,
+ sgr=%?%p9%t\E(0%e\E(B%;\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m,
+ sitm=\E[3m,
+ smacs=\E(0,
+ smcup=\E[?1049h,
+ smir=\E[4h,
+ smkx=\E[?1h\E=,
+ smso=\E[7m,
+ smul=\E[4m,
+ tbc=\E[3g,
+ tsl=\E]0;,
+ xenl,
+ vpa=\E[%i%p1%dd,
+# XTerm extensions
+ rmxx=\E[29m,
+ smxx=\E[9m,
+# tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
+ Se,
+ Ss,
+ Tc,
+ Ms=\E]52;%p1%s;%p2%s\007,
+
+st-256color| simpleterm with 256 colors,
+ use=st,
+ ccc,
+ colors#256,
+ oc=\E]104\007,
+ pairs#32767,
+# Nicked from xterm-256color
+ initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
+ setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
+ setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
+
+st-meta| simpleterm with meta key,
+ use=st,
+ km,
+ rmm=\E[?1034l,
+ smm=\E[?1034h,
+ rs2=\E[4l\E>\E[?1034h,
+ is2=\E[4l\E>\E[?1034h,
+
+st-meta-256color| simpleterm with meta key and 256 colors,
+ use=st-256color,
+ km,
+ rmm=\E[?1034l,
+ smm=\E[?1034h,
+ rs2=\E[4l\E>\E[?1034h,
+ is2=\E[4l\E>\E[?1034h,
diff --git a/terms/st/st-0.8.2/st.o b/terms/st/st-0.8.2/st.o
new file mode 100644
index 0000000..2c49d7d
Binary files /dev/null and b/terms/st/st-0.8.2/st.o differ
diff --git a/terms/st/st-0.8.2/win.h b/terms/st/st-0.8.2/win.h
new file mode 100644
index 0000000..31f327d
--- /dev/null
+++ b/terms/st/st-0.8.2/win.h
@@ -0,0 +1,38 @@
+/* See LICENSE for license details. */
+
+enum win_mode {
+ MODE_VISIBLE = 1 << 0,
+ MODE_FOCUSED = 1 << 1,
+ MODE_APPKEYPAD = 1 << 2,
+ MODE_MOUSEBTN = 1 << 3,
+ MODE_MOUSEMOTION = 1 << 4,
+ MODE_REVERSE = 1 << 5,
+ MODE_KBDLOCK = 1 << 6,
+ MODE_HIDE = 1 << 7,
+ MODE_APPCURSOR = 1 << 8,
+ MODE_MOUSESGR = 1 << 9,
+ MODE_8BIT = 1 << 10,
+ MODE_BLINK = 1 << 11,
+ MODE_FBLINK = 1 << 12,
+ MODE_FOCUS = 1 << 13,
+ MODE_MOUSEX10 = 1 << 14,
+ MODE_MOUSEMANY = 1 << 15,
+ MODE_BRCKTPASTE = 1 << 16,
+ MODE_NUMLOCK = 1 << 17,
+ MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
+ |MODE_MOUSEMANY,
+};
+
+void xbell(void);
+void xclipcopy(void);
+void xdrawcursor(int, int, Glyph, int, int, Glyph);
+void xdrawline(Line, int, int, int);
+void xfinishdraw(void);
+void xloadcols(void);
+int xsetcolorname(int, const char *);
+void xsettitle(char *);
+int xsetcursor(int);
+void xsetmode(int, unsigned int);
+void xsetpointermotion(int);
+void xsetsel(char *);
+int xstartdraw(void);
diff --git a/terms/st/st-0.8.2/x.c b/terms/st/st-0.8.2/x.c
new file mode 100644
index 0000000..0422421
--- /dev/null
+++ b/terms/st/st-0.8.2/x.c
@@ -0,0 +1,1955 @@
+/* See LICENSE for license details. */
+#include <errno.h>
+#include <math.h>
+#include <limits.h>
+#include <locale.h>
+#include <signal.h>
+#include <sys/select.h>
+#include <time.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/cursorfont.h>
+#include <X11/keysym.h>
+#include <X11/Xft/Xft.h>
+#include <X11/XKBlib.h>
+
+static char *argv0;
+#include "arg.h"
+#include "st.h"
+#include "win.h"
+
+/* types used in config.h */
+typedef struct {
+ uint mod;
+ KeySym keysym;
+ void (*func)(const Arg *);
+ const Arg arg;
+} Shortcut;
+
+typedef struct {
+ uint b;
+ uint mask;
+ char *s;
+} MouseShortcut;
+
+typedef struct {
+ KeySym k;
+ uint mask;
+ char *s;
+ /* three-valued logic variables: 0 indifferent, 1 on, -1 off */
+ signed char appkey; /* application keypad */
+ signed char appcursor; /* application cursor */
+} Key;
+
+/* X modifiers */
+#define XK_ANY_MOD UINT_MAX
+#define XK_NO_MOD 0
+#define XK_SWITCH_MOD (1<<13)
+
+/* function definitions used in config.h */
+static void clipcopy(const Arg *);
+static void clippaste(const Arg *);
+static void numlock(const Arg *);
+static void selpaste(const Arg *);
+static void zoom(const Arg *);
+static void zoomabs(const Arg *);
+static void zoomreset(const Arg *);
+
+/* config.h for applying patches and the configuration. */
+#include "config.h"
+
+/* XEMBED messages */
+#define XEMBED_FOCUS_IN 4
+#define XEMBED_FOCUS_OUT 5
+
+/* macros */
+#define IS_SET(flag) ((win.mode & (flag)) != 0)
+#define TRUERED(x) (((x) & 0xff0000) >> 8)
+#define TRUEGREEN(x) (((x) & 0xff00))
+#define TRUEBLUE(x) (((x) & 0xff) << 8)
+
+typedef XftDraw *Draw;
+typedef XftColor Color;
+typedef XftGlyphFontSpec GlyphFontSpec;
+
+/* Purely graphic info */
+typedef struct {
+ int tw, th; /* tty width and height */
+ int w, h; /* window width and height */
+ int ch; /* char height */
+ int cw; /* char width */
+ int mode; /* window state/mode flags */
+ int cursor; /* cursor style */
+} TermWindow;
+
+typedef struct {
+ Display *dpy;
+ Colormap cmap;
+ Window win;
+ Drawable buf;
+ GlyphFontSpec *specbuf; /* font spec buffer used for rendering */
+ Atom xembed, wmdeletewin, netwmname, netwmpid;
+ XIM xim;
+ XIC xic;
+ Draw draw;
+ Visual *vis;
+ XSetWindowAttributes attrs;
+ int scr;
+ int isfixed; /* is fixed geometry? */
+ int l, t; /* left and top offset */
+ int gm; /* geometry mask */
+} XWindow;
+
+typedef struct {
+ Atom xtarget;
+ char *primary, *clipboard;
+ struct timespec tclick1;
+ struct timespec tclick2;
+} XSelection;
+
+/* Font structure */
+#define Font Font_
+typedef struct {
+ int height;
+ int width;
+ int ascent;
+ int descent;
+ int badslant;
+ int badweight;
+ short lbearing;
+ short rbearing;
+ XftFont *match;
+ FcFontSet *set;
+ FcPattern *pattern;
+} Font;
+
+/* Drawing Context */
+typedef struct {
+ Color *col;
+ size_t collen;
+ Font font, bfont, ifont, ibfont;
+ GC gc;
+} DC;
+
+static inline ushort sixd_to_16bit(int);
+static int xmakeglyphfontspecs(XftGlyphFontSpec *, const Glyph *, int, int, int);
+static void xdrawglyphfontspecs(const XftGlyphFontSpec *, Glyph, int, int, int);
+static void xdrawglyph(Glyph, int, int);
+static void xclear(int, int, int, int);
+static int xgeommasktogravity(int);
+static void xinit(int, int);
+static void cresize(int, int);
+static void xresize(int, int);
+static void xhints(void);
+static int xloadcolor(int, const char *, Color *);
+static int xloadfont(Font *, FcPattern *);
+static void xloadfonts(char *, double);
+static void xunloadfont(Font *);
+static void xunloadfonts(void);
+static void xsetenv(void);
+static void xseturgency(int);
+static int evcol(XEvent *);
+static int evrow(XEvent *);
+
+static void expose(XEvent *);
+static void visibility(XEvent *);
+static void unmap(XEvent *);
+static void kpress(XEvent *);
+static void cmessage(XEvent *);
+static void resize(XEvent *);
+static void focus(XEvent *);
+static void brelease(XEvent *);
+static void bpress(XEvent *);
+static void bmotion(XEvent *);
+static void propnotify(XEvent *);
+static void selnotify(XEvent *);
+static void selclear_(XEvent *);
+static void selrequest(XEvent *);
+static void setsel(char *, Time);
+static void mousesel(XEvent *, int);
+static void mousereport(XEvent *);
+static char *kmap(KeySym, uint);
+static int match(uint, uint);
+
+static void run(void);
+static void usage(void);
+
+static void (*handler[LASTEvent])(XEvent *) = {
+ [KeyPress] = kpress,
+ [ClientMessage] = cmessage,
+ [ConfigureNotify] = resize,
+ [VisibilityNotify] = visibility,
+ [UnmapNotify] = unmap,
+ [Expose] = expose,
+ [FocusIn] = focus,
+ [FocusOut] = focus,
+ [MotionNotify] = bmotion,
+ [ButtonPress] = bpress,
+ [ButtonRelease] = brelease,
+/*
+ * Uncomment if you want the selection to disappear when you select something
+ * different in another window.
+ */
+/* [SelectionClear] = selclear_, */
+ [SelectionNotify] = selnotify,
+/*
+ * PropertyNotify is only turned on when there is some INCR transfer happening
+ * for the selection retrieval.
+ */
+ [PropertyNotify] = propnotify,
+ [SelectionRequest] = selrequest,
+};
+
+/* Globals */
+static DC dc;
+static XWindow xw;
+static XSelection xsel;
+static TermWindow win;
+
+/* Font Ring Cache */
+enum {
+ FRC_NORMAL,
+ FRC_ITALIC,
+ FRC_BOLD,
+ FRC_ITALICBOLD
+};
+
+typedef struct {
+ XftFont *font;
+ int flags;
+ Rune unicodep;
+} Fontcache;
+
+/* Fontcache is an array now. A new font will be appended to the array. */
+static Fontcache frc[16];
+static int frclen = 0;
+static char *usedfont = NULL;
+static double usedfontsize = 0;
+static double defaultfontsize = 0;
+
+static char *opt_class = NULL;
+static char **opt_cmd = NULL;
+static char *opt_embed = NULL;
+static char *opt_font = NULL;
+static char *opt_io = NULL;
+static char *opt_line = NULL;
+static char *opt_name = NULL;
+static char *opt_title = NULL;
+
+static int oldbutton = 3; /* button event on startup: 3 = release */
+
+void
+clipcopy(const Arg *dummy)
+{
+ Atom clipboard;
+
+ free(xsel.clipboard);
+ xsel.clipboard = NULL;
+
+ if (xsel.primary != NULL) {
+ xsel.clipboard = xstrdup(xsel.primary);
+ clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
+ XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime);
+ }
+}
+
+void
+clippaste(const Arg *dummy)
+{
+ Atom clipboard;
+
+ clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
+ XConvertSelection(xw.dpy, clipboard, xsel.xtarget, clipboard,
+ xw.win, CurrentTime);
+}
+
+void
+selpaste(const Arg *dummy)
+{
+ XConvertSelection(xw.dpy, XA_PRIMARY, xsel.xtarget, XA_PRIMARY,
+ xw.win, CurrentTime);
+}
+
+void
+numlock(const Arg *dummy)
+{
+ win.mode ^= MODE_NUMLOCK;
+}
+
+void
+zoom(const Arg *arg)
+{
+ Arg larg;
+
+ larg.f = usedfontsize + arg->f;
+ zoomabs(&larg);
+}
+
+void
+zoomabs(const Arg *arg)
+{
+ xunloadfonts();
+ xloadfonts(usedfont, arg->f);
+ cresize(0, 0);
+ redraw();
+ xhints();
+}
+
+void
+zoomreset(const Arg *arg)
+{
+ Arg larg;
+
+ if (defaultfontsize > 0) {
+ larg.f = defaultfontsize;
+ zoomabs(&larg);
+ }
+}
+
+int
+evcol(XEvent *e)
+{
+ int x = e->xbutton.x - borderpx;
+ LIMIT(x, 0, win.tw - 1);
+ return x / win.cw;
+}
+
+int
+evrow(XEvent *e)
+{
+ int y = e->xbutton.y - borderpx;
+ LIMIT(y, 0, win.th - 1);
+ return y / win.ch;
+}
+
+void
+mousesel(XEvent *e, int done)
+{
+ int type, seltype = SEL_REGULAR;
+ uint state = e->xbutton.state & ~(Button1Mask | forceselmod);
+
+ for (type = 1; type < LEN(selmasks); ++type) {
+ if (match(selmasks[type], state)) {
+ seltype = type;
+ break;
+ }
+ }
+ selextend(evcol(e), evrow(e), seltype, done);
+ if (done)
+ setsel(getsel(), e->xbutton.time);
+}
+
+void
+mousereport(XEvent *e)
+{
+ int len, x = evcol(e), y = evrow(e),
+ button = e->xbutton.button, state = e->xbutton.state;
+ char buf[40];
+ static int ox, oy;
+
+ /* from urxvt */
+ if (e->xbutton.type == MotionNotify) {
+ if (x == ox && y == oy)
+ return;
+ if (!IS_SET(MODE_MOUSEMOTION) && !IS_SET(MODE_MOUSEMANY))
+ return;
+ /* MOUSE_MOTION: no reporting if no button is pressed */
+ if (IS_SET(MODE_MOUSEMOTION) && oldbutton == 3)
+ return;
+
+ button = oldbutton + 32;
+ ox = x;
+ oy = y;
+ } else {
+ if (!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease) {
+ button = 3;
+ } else {
+ button -= Button1;
+ if (button >= 3)
+ button += 64 - 3;
+ }
+ if (e->xbutton.type == ButtonPress) {
+ oldbutton = button;
+ ox = x;
+ oy = y;
+ } else if (e->xbutton.type == ButtonRelease) {
+ oldbutton = 3;
+ /* MODE_MOUSEX10: no button release reporting */
+ if (IS_SET(MODE_MOUSEX10))
+ return;
+ if (button == 64 || button == 65)
+ return;
+ }
+ }
+
+ if (!IS_SET(MODE_MOUSEX10)) {
+ button += ((state & ShiftMask ) ? 4 : 0)
+ + ((state & Mod4Mask ) ? 8 : 0)
+ + ((state & ControlMask) ? 16 : 0);
+ }
+
+ if (IS_SET(MODE_MOUSESGR)) {
+ len = snprintf(buf, sizeof(buf), "\033[<%d;%d;%d%c",
+ button, x+1, y+1,
+ e->xbutton.type == ButtonRelease ? 'm' : 'M');
+ } else if (x < 223 && y < 223) {
+ len = snprintf(buf, sizeof(buf), "\033[M%c%c%c",
+ 32+button, 32+x+1, 32+y+1);
+ } else {
+ return;
+ }
+
+ ttywrite(buf, len, 0);
+}
+
+void
+bpress(XEvent *e)
+{
+ struct timespec now;
+ MouseShortcut *ms;
+ int snap;
+
+ if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
+ mousereport(e);
+ return;
+ }
+
+ for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
+ if (e->xbutton.button == ms->b
+ && match(ms->mask, e->xbutton.state)) {
+ ttywrite(ms->s, strlen(ms->s), 1);
+ return;
+ }
+ }
+
+ if (e->xbutton.button == Button1) {
+ /*
+ * If the user clicks below predefined timeouts specific
+ * snapping behaviour is exposed.
+ */
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ if (TIMEDIFF(now, xsel.tclick2) <= tripleclicktimeout) {
+ snap = SNAP_LINE;
+ } else if (TIMEDIFF(now, xsel.tclick1) <= doubleclicktimeout) {
+ snap = SNAP_WORD;
+ } else {
+ snap = 0;
+ }
+ xsel.tclick2 = xsel.tclick1;
+ xsel.tclick1 = now;
+
+ selstart(evcol(e), evrow(e), snap);
+ }
+}
+
+void
+propnotify(XEvent *e)
+{
+ XPropertyEvent *xpev;
+ Atom clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
+
+ xpev = &e->xproperty;
+ if (xpev->state == PropertyNewValue &&
+ (xpev->atom == XA_PRIMARY ||
+ xpev->atom == clipboard)) {
+ selnotify(e);
+ }
+}
+
+void
+selnotify(XEvent *e)
+{
+ ulong nitems, ofs, rem;
+ int format;
+ uchar *data, *last, *repl;
+ Atom type, incratom, property = None;
+
+ incratom = XInternAtom(xw.dpy, "INCR", 0);
+
+ ofs = 0;
+ if (e->type == SelectionNotify)
+ property = e->xselection.property;
+ else if (e->type == PropertyNotify)
+ property = e->xproperty.atom;
+
+ if (property == None)
+ return;
+
+ do {
+ if (XGetWindowProperty(xw.dpy, xw.win, property, ofs,
+ BUFSIZ/4, False, AnyPropertyType,
+ &type, &format, &nitems, &rem,
+ &data)) {
+ fprintf(stderr, "Clipboard allocation failed\n");
+ return;
+ }
+
+ if (e->type == PropertyNotify && nitems == 0 && rem == 0) {
+ /*
+ * If there is some PropertyNotify with no data, then
+ * this is the signal of the selection owner that all
+ * data has been transferred. We won't need to receive
+ * PropertyNotify events anymore.
+ */
+ MODBIT(xw.attrs.event_mask, 0, PropertyChangeMask);
+ XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask,
+ &xw.attrs);
+ }
+
+ if (type == incratom) {
+ /*
+ * Activate the PropertyNotify events so we receive
+ * when the selection owner does send us the next
+ * chunk of data.
+ */
+ MODBIT(xw.attrs.event_mask, 1, PropertyChangeMask);
+ XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask,
+ &xw.attrs);
+
+ /*
+ * Deleting the property is the transfer start signal.
+ */
+ XDeleteProperty(xw.dpy, xw.win, (int)property);
+ continue;
+ }
+
+ /*
+ * As seen in getsel:
+ * Line endings are inconsistent in the terminal and GUI world
+ * copy and pasting. When receiving some selection data,
+ * replace all '\n' with '\r'.
+ * FIXME: Fix the computer world.
+ */
+ repl = data;
+ last = data + nitems * format / 8;
+ while ((repl = memchr(repl, '\n', last - repl))) {
+ *repl++ = '\r';
+ }
+
+ if (IS_SET(MODE_BRCKTPASTE) && ofs == 0)
+ ttywrite("\033[200~", 6, 0);
+ ttywrite((char *)data, nitems * format / 8, 1);
+ if (IS_SET(MODE_BRCKTPASTE) && rem == 0)
+ ttywrite("\033[201~", 6, 0);
+ XFree(data);
+ /* number of 32-bit chunks returned */
+ ofs += nitems * format / 32;
+ } while (rem > 0);
+
+ /*
+ * Deleting the property again tells the selection owner to send the
+ * next data chunk in the property.
+ */
+ XDeleteProperty(xw.dpy, xw.win, (int)property);
+}
+
+void
+xclipcopy(void)
+{
+ clipcopy(NULL);
+}
+
+void
+selclear_(XEvent *e)
+{
+ selclear();
+}
+
+void
+selrequest(XEvent *e)
+{
+ XSelectionRequestEvent *xsre;
+ XSelectionEvent xev;
+ Atom xa_targets, string, clipboard;
+ char *seltext;
+
+ xsre = (XSelectionRequestEvent *) e;
+ xev.type = SelectionNotify;
+ xev.requestor = xsre->requestor;
+ xev.selection = xsre->selection;
+ xev.target = xsre->target;
+ xev.time = xsre->time;
+ if (xsre->property == None)
+ xsre->property = xsre->target;
+
+ /* reject */
+ xev.property = None;
+
+ xa_targets = XInternAtom(xw.dpy, "TARGETS", 0);
+ if (xsre->target == xa_targets) {
+ /* respond with the supported type */
+ string = xsel.xtarget;
+ XChangeProperty(xsre->display, xsre->requestor, xsre->property,
+ XA_ATOM, 32, PropModeReplace,
+ (uchar *) &string, 1);
+ xev.property = xsre->property;
+ } else if (xsre->target == xsel.xtarget || xsre->target == XA_STRING) {
+ /*
+ * xith XA_STRING non ascii characters may be incorrect in the
+ * requestor. It is not our problem, use utf8.
+ */
+ clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
+ if (xsre->selection == XA_PRIMARY) {
+ seltext = xsel.primary;
+ } else if (xsre->selection == clipboard) {
+ seltext = xsel.clipboard;
+ } else {
+ fprintf(stderr,
+ "Unhandled clipboard selection 0x%lx\n",
+ xsre->selection);
+ return;
+ }
+ if (seltext != NULL) {
+ XChangeProperty(xsre->display, xsre->requestor,
+ xsre->property, xsre->target,
+ 8, PropModeReplace,
+ (uchar *)seltext, strlen(seltext));
+ xev.property = xsre->property;
+ }
+ }
+
+ /* all done, send a notification to the listener */
+ if (!XSendEvent(xsre->display, xsre->requestor, 1, 0, (XEvent *) &xev))
+ fprintf(stderr, "Error sending SelectionNotify event\n");
+}
+
+void
+setsel(char *str, Time t)
+{
+ if (!str)
+ return;
+
+ free(xsel.primary);
+ xsel.primary = str;
+
+ XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t);
+ if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win)
+ selclear();
+}
+
+void
+xsetsel(char *str)
+{
+ setsel(str, CurrentTime);
+}
+
+void
+brelease(XEvent *e)
+{
+ if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
+ mousereport(e);
+ return;
+ }
+
+ if (e->xbutton.button == Button2)
+ selpaste(NULL);
+ else if (e->xbutton.button == Button1)
+ mousesel(e, 1);
+}
+
+void
+bmotion(XEvent *e)
+{
+ if (IS_SET(MODE_MOUSE) && !(e->xbutton.state & forceselmod)) {
+ mousereport(e);
+ return;
+ }
+
+ mousesel(e, 0);
+}
+
+void
+cresize(int width, int height)
+{
+ int col, row;
+
+ if (width != 0)
+ win.w = width;
+ if (height != 0)
+ win.h = height;
+
+ col = (win.w - 2 * borderpx) / win.cw;
+ row = (win.h - 2 * borderpx) / win.ch;
+ col = MAX(1, col);
+ row = MAX(1, row);
+
+ tresize(col, row);
+ xresize(col, row);
+ ttyresize(win.tw, win.th);
+}
+
+void
+xresize(int col, int row)
+{
+ win.tw = col * win.cw;
+ win.th = row * win.ch;
+
+ XFreePixmap(xw.dpy, xw.buf);
+ xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
+ DefaultDepth(xw.dpy, xw.scr));
+ XftDrawChange(xw.draw, xw.buf);
+ xclear(0, 0, win.w, win.h);
+
+ /* resize to new width */
+ xw.specbuf = xrealloc(xw.specbuf, col * sizeof(GlyphFontSpec));
+}
+
+ushort
+sixd_to_16bit(int x)
+{
+ return x == 0 ? 0 : 0x3737 + 0x2828 * x;
+}
+
+int
+xloadcolor(int i, const char *name, Color *ncolor)
+{
+ XRenderColor color = { .alpha = 0xffff };
+
+ if (!name) {
+ if (BETWEEN(i, 16, 255)) { /* 256 color */
+ if (i < 6*6*6+16) { /* same colors as xterm */
+ color.red = sixd_to_16bit( ((i-16)/36)%6 );
+ color.green = sixd_to_16bit( ((i-16)/6) %6 );
+ color.blue = sixd_to_16bit( ((i-16)/1) %6 );
+ } else { /* greyscale */
+ color.red = 0x0808 + 0x0a0a * (i - (6*6*6+16));
+ color.green = color.blue = color.red;
+ }
+ return XftColorAllocValue(xw.dpy, xw.vis,
+ xw.cmap, &color, ncolor);
+ } else
+ name = colorname[i];
+ }
+
+ return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
+}
+
+void
+xloadcols(void)
+{
+ int i;
+ static int loaded;
+ Color *cp;
+
+ if (loaded) {
+ for (cp = dc.col; cp < &dc.col[dc.collen]; ++cp)
+ XftColorFree(xw.dpy, xw.vis, xw.cmap, cp);
+ } else {
+ dc.collen = MAX(LEN(colorname), 256);
+ dc.col = xmalloc(dc.collen * sizeof(Color));
+ }
+
+ for (i = 0; i < dc.collen; i++)
+ if (!xloadcolor(i, NULL, &dc.col[i])) {
+ if (colorname[i])
+ die("could not allocate color '%s'\n", colorname[i]);
+ else
+ die("could not allocate color %d\n", i);
+ }
+ loaded = 1;
+}
+
+int
+xsetcolorname(int x, const char *name)
+{
+ Color ncolor;
+
+ if (!BETWEEN(x, 0, dc.collen))
+ return 1;
+
+
+ if (!xloadcolor(x, name, &ncolor))
+ return 1;
+
+ XftColorFree(xw.dpy, xw.vis, xw.cmap, &dc.col[x]);
+ dc.col[x] = ncolor;
+
+ return 0;
+}
+
+/*
+ * Absolute coordinates.
+ */
+void
+xclear(int x1, int y1, int x2, int y2)
+{
+ XftDrawRect(xw.draw,
+ &dc.col[IS_SET(MODE_REVERSE)? defaultfg : defaultbg],
+ x1, y1, x2-x1, y2-y1);
+}
+
+void
+xhints(void)
+{
+ XClassHint class = {opt_name ? opt_name : termname,
+ opt_class ? opt_class : termname};
+ XWMHints wm = {.flags = InputHint, .input = 1};
+ XSizeHints *sizeh;
+
+ sizeh = XAllocSizeHints();
+
+ sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize;
+ sizeh->height = win.h;
+ sizeh->width = win.w;
+ sizeh->height_inc = win.ch;
+ sizeh->width_inc = win.cw;
+ sizeh->base_height = 2 * borderpx;
+ sizeh->base_width = 2 * borderpx;
+ sizeh->min_height = win.ch + 2 * borderpx;
+ sizeh->min_width = win.cw + 2 * borderpx;
+ if (xw.isfixed) {
+ sizeh->flags |= PMaxSize;
+ sizeh->min_width = sizeh->max_width = win.w;
+ sizeh->min_height = sizeh->max_height = win.h;
+ }
+ if (xw.gm & (XValue|YValue)) {
+ sizeh->flags |= USPosition | PWinGravity;
+ sizeh->x = xw.l;
+ sizeh->y = xw.t;
+ sizeh->win_gravity = xgeommasktogravity(xw.gm);
+ }
+
+ XSetWMProperties(xw.dpy, xw.win, NULL, NULL, NULL, 0, sizeh, &wm,
+ &class);
+ XFree(sizeh);
+}
+
+int
+xgeommasktogravity(int mask)
+{
+ switch (mask & (XNegative|YNegative)) {
+ case 0:
+ return NorthWestGravity;
+ case XNegative:
+ return NorthEastGravity;
+ case YNegative:
+ return SouthWestGravity;
+ }
+
+ return SouthEastGravity;
+}
+
+int
+xloadfont(Font *f, FcPattern *pattern)
+{
+ FcPattern *configured;
+ FcPattern *match;
+ FcResult result;
+ XGlyphInfo extents;
+ int wantattr, haveattr;
+
+ /*
+ * Manually configure instead of calling XftMatchFont
+ * so that we can use the configured pattern for
+ * "missing glyph" lookups.
+ */
+ configured = FcPatternDuplicate(pattern);
+ if (!configured)
+ return 1;
+
+ FcConfigSubstitute(NULL, configured, FcMatchPattern);
+ XftDefaultSubstitute(xw.dpy, xw.scr, configured);
+
+ match = FcFontMatch(NULL, configured, &result);
+ if (!match) {
+ FcPatternDestroy(configured);
+ return 1;
+ }
+
+ if (!(f->match = XftFontOpenPattern(xw.dpy, match))) {
+ FcPatternDestroy(configured);
+ FcPatternDestroy(match);
+ return 1;
+ }
+
+ if ((XftPatternGetInteger(pattern, "slant", 0, &wantattr) ==
+ XftResultMatch)) {
+ /*
+ * Check if xft was unable to find a font with the appropriate
+ * slant but gave us one anyway. Try to mitigate.
+ */
+ if ((XftPatternGetInteger(f->match->pattern, "slant", 0,
+ &haveattr) != XftResultMatch) || haveattr < wantattr) {
+ f->badslant = 1;
+ fputs("font slant does not match\n", stderr);
+ }
+ }
+
+ if ((XftPatternGetInteger(pattern, "weight", 0, &wantattr) ==
+ XftResultMatch)) {
+ if ((XftPatternGetInteger(f->match->pattern, "weight", 0,
+ &haveattr) != XftResultMatch) || haveattr != wantattr) {
+ f->badweight = 1;
+ fputs("font weight does not match\n", stderr);
+ }
+ }
+
+ XftTextExtentsUtf8(xw.dpy, f->match,
+ (const FcChar8 *) ascii_printable,
+ strlen(ascii_printable), &extents);
+
+ f->set = NULL;
+ f->pattern = configured;
+
+ f->ascent = f->match->ascent;
+ f->descent = f->match->descent;
+ f->lbearing = 0;
+ f->rbearing = f->match->max_advance_width;
+
+ f->height = f->ascent + f->descent;
+ f->width = DIVCEIL(extents.xOff, strlen(ascii_printable));
+
+ return 0;
+}
+
+void
+xloadfonts(char *fontstr, double fontsize)
+{
+ FcPattern *pattern;
+ double fontval;
+
+ if (fontstr[0] == '-')
+ pattern = XftXlfdParse(fontstr, False, False);
+ else
+ pattern = FcNameParse((FcChar8 *)fontstr);
+
+ if (!pattern)
+ die("can't open font %s\n", fontstr);
+
+ if (fontsize > 1) {
+ FcPatternDel(pattern, FC_PIXEL_SIZE);
+ FcPatternDel(pattern, FC_SIZE);
+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, (double)fontsize);
+ usedfontsize = fontsize;
+ } else {
+ if (FcPatternGetDouble(pattern, FC_PIXEL_SIZE, 0, &fontval) ==
+ FcResultMatch) {
+ usedfontsize = fontval;
+ } else if (FcPatternGetDouble(pattern, FC_SIZE, 0, &fontval) ==
+ FcResultMatch) {
+ usedfontsize = -1;
+ } else {
+ /*
+ * Default font size is 12, if none given. This is to
+ * have a known usedfontsize value.
+ */
+ FcPatternAddDouble(pattern, FC_PIXEL_SIZE, 12);
+ usedfontsize = 12;
+ }
+ defaultfontsize = usedfontsize;
+ }
+
+ if (xloadfont(&dc.font, pattern))
+ die("can't open font %s\n", fontstr);
+
+ if (usedfontsize < 0) {
+ FcPatternGetDouble(dc.font.match->pattern,
+ FC_PIXEL_SIZE, 0, &fontval);
+ usedfontsize = fontval;
+ if (fontsize == 0)
+ defaultfontsize = fontval;
+ }
+
+ /* Setting character width and height. */
+ win.cw = ceilf(dc.font.width * cwscale);
+ win.ch = ceilf(dc.font.height * chscale);
+
+ FcPatternDel(pattern, FC_SLANT);
+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ITALIC);
+ if (xloadfont(&dc.ifont, pattern))
+ die("can't open font %s\n", fontstr);
+
+ FcPatternDel(pattern, FC_WEIGHT);
+ FcPatternAddInteger(pattern, FC_WEIGHT, FC_WEIGHT_BOLD);
+ if (xloadfont(&dc.ibfont, pattern))
+ die("can't open font %s\n", fontstr);
+
+ FcPatternDel(pattern, FC_SLANT);
+ FcPatternAddInteger(pattern, FC_SLANT, FC_SLANT_ROMAN);
+ if (xloadfont(&dc.bfont, pattern))
+ die("can't open font %s\n", fontstr);
+
+ FcPatternDestroy(pattern);
+}
+
+void
+xunloadfont(Font *f)
+{
+ XftFontClose(xw.dpy, f->match);
+ FcPatternDestroy(f->pattern);
+ if (f->set)
+ FcFontSetDestroy(f->set);
+}
+
+void
+xunloadfonts(void)
+{
+ /* Free the loaded fonts in the font cache. */
+ while (frclen > 0)
+ XftFontClose(xw.dpy, frc[--frclen].font);
+
+ xunloadfont(&dc.font);
+ xunloadfont(&dc.bfont);
+ xunloadfont(&dc.ifont);
+ xunloadfont(&dc.ibfont);
+}
+
+void
+xinit(int cols, int rows)
+{
+ XGCValues gcvalues;
+ Cursor cursor;
+ Window parent;
+ pid_t thispid = getpid();
+ XColor xmousefg, xmousebg;
+
+ if (!(xw.dpy = XOpenDisplay(NULL)))
+ die("can't open display\n");
+ xw.scr = XDefaultScreen(xw.dpy);
+ xw.vis = XDefaultVisual(xw.dpy, xw.scr);
+
+ /* font */
+ if (!FcInit())
+ die("could not init fontconfig.\n");
+
+ usedfont = (opt_font == NULL)? font : opt_font;
+ xloadfonts(usedfont, 0);
+
+ /* colors */
+ xw.cmap = XDefaultColormap(xw.dpy, xw.scr);
+ xloadcols();
+
+ /* adjust fixed window geometry */
+ win.w = 2 * borderpx + cols * win.cw;
+ win.h = 2 * borderpx + rows * win.ch;
+ if (xw.gm & XNegative)
+ xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2;
+ if (xw.gm & YNegative)
+ xw.t += DisplayHeight(xw.dpy, xw.scr) - win.h - 2;
+
+ /* Events */
+ xw.attrs.background_pixel = dc.col[defaultbg].pixel;
+ xw.attrs.border_pixel = dc.col[defaultbg].pixel;
+ xw.attrs.bit_gravity = NorthWestGravity;
+ xw.attrs.event_mask = FocusChangeMask | KeyPressMask
+ | ExposureMask | VisibilityChangeMask | StructureNotifyMask
+ | ButtonMotionMask | ButtonPressMask | ButtonReleaseMask;
+ xw.attrs.colormap = xw.cmap;
+
+ if (!(opt_embed && (parent = strtol(opt_embed, NULL, 0))))
+ parent = XRootWindow(xw.dpy, xw.scr);
+ xw.win = XCreateWindow(xw.dpy, parent, xw.l, xw.t,
+ win.w, win.h, 0, XDefaultDepth(xw.dpy, xw.scr), InputOutput,
+ xw.vis, CWBackPixel | CWBorderPixel | CWBitGravity
+ | CWEventMask | CWColormap, &xw.attrs);
+
+ memset(&gcvalues, 0, sizeof(gcvalues));
+ gcvalues.graphics_exposures = False;
+ dc.gc = XCreateGC(xw.dpy, parent, GCGraphicsExposures,
+ &gcvalues);
+ xw.buf = XCreatePixmap(xw.dpy, xw.win, win.w, win.h,
+ DefaultDepth(xw.dpy, xw.scr));
+ XSetForeground(xw.dpy, dc.gc, dc.col[defaultbg].pixel);
+ XFillRectangle(xw.dpy, xw.buf, dc.gc, 0, 0, win.w, win.h);
+
+ /* font spec buffer */
+ xw.specbuf = xmalloc(cols * sizeof(GlyphFontSpec));
+
+ /* Xft rendering context */
+ xw.draw = XftDrawCreate(xw.dpy, xw.buf, xw.vis, xw.cmap);
+
+ /* input methods */
+ if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
+ XSetLocaleModifiers("@im=local");
+ if ((xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL)) == NULL) {
+ XSetLocaleModifiers("@im=");
+ if ((xw.xim = XOpenIM(xw.dpy,
+ NULL, NULL, NULL)) == NULL) {
+ die("XOpenIM failed. Could not open input"
+ " device.\n");
+ }
+ }
+ }
+ xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
+ | XIMStatusNothing, XNClientWindow, xw.win,
+ XNFocusWindow, xw.win, NULL);
+ if (xw.xic == NULL)
+ die("XCreateIC failed. Could not obtain input method.\n");
+
+ /* white cursor, black outline */
+ cursor = XCreateFontCursor(xw.dpy, mouseshape);
+ XDefineCursor(xw.dpy, xw.win, cursor);
+
+ if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
+ xmousefg.red = 0xffff;
+ xmousefg.green = 0xffff;
+ xmousefg.blue = 0xffff;
+ }
+
+ if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
+ xmousebg.red = 0x0000;
+ xmousebg.green = 0x0000;
+ xmousebg.blue = 0x0000;
+ }
+
+ XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg);
+
+ xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
+ xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
+ xw.netwmname = XInternAtom(xw.dpy, "_NET_WM_NAME", False);
+ XSetWMProtocols(xw.dpy, xw.win, &xw.wmdeletewin, 1);
+
+ xw.netwmpid = XInternAtom(xw.dpy, "_NET_WM_PID", False);
+ XChangeProperty(xw.dpy, xw.win, xw.netwmpid, XA_CARDINAL, 32,
+ PropModeReplace, (uchar *)&thispid, 1);
+
+ win.mode = MODE_NUMLOCK;
+ resettitle();
+ XMapWindow(xw.dpy, xw.win);
+ xhints();
+ XSync(xw.dpy, False);
+
+ clock_gettime(CLOCK_MONOTONIC, &xsel.tclick1);
+ clock_gettime(CLOCK_MONOTONIC, &xsel.tclick2);
+ xsel.primary = NULL;
+ xsel.clipboard = NULL;
+ xsel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0);
+ if (xsel.xtarget == None)
+ xsel.xtarget = XA_STRING;
+}
+
+int
+xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
+{
+ float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp;
+ ushort mode, prevmode = USHRT_MAX;
+ Font *font = &dc.font;
+ int frcflags = FRC_NORMAL;
+ float runewidth = win.cw;
+ Rune rune;
+ FT_UInt glyphidx;
+ FcResult fcres;
+ FcPattern *fcpattern, *fontpattern;
+ FcFontSet *fcsets[] = { NULL };
+ FcCharSet *fccharset;
+ int i, f, numspecs = 0;
+
+ for (i = 0, xp = winx, yp = winy + font->ascent; i < len; ++i) {
+ /* Fetch rune and mode for current glyph. */
+ rune = glyphs[i].u;
+ mode = glyphs[i].mode;
+
+ /* Skip dummy wide-character spacing. */
+ if (mode == ATTR_WDUMMY)
+ continue;
+
+ /* Determine font for glyph if different from previous glyph. */
+ if (prevmode != mode) {
+ prevmode = mode;
+ font = &dc.font;
+ frcflags = FRC_NORMAL;
+ runewidth = win.cw * ((mode & ATTR_WIDE) ? 2.0f : 1.0f);
+ if ((mode & ATTR_ITALIC) && (mode & ATTR_BOLD)) {
+ font = &dc.ibfont;
+ frcflags = FRC_ITALICBOLD;
+ } else if (mode & ATTR_ITALIC) {
+ font = &dc.ifont;
+ frcflags = FRC_ITALIC;
+ } else if (mode & ATTR_BOLD) {
+ font = &dc.bfont;
+ frcflags = FRC_BOLD;
+ }
+ yp = winy + font->ascent;
+ }
+
+ /* Lookup character index with default font. */
+ glyphidx = XftCharIndex(xw.dpy, font->match, rune);
+ if (glyphidx) {
+ specs[numspecs].font = font->match;
+ specs[numspecs].glyph = glyphidx;
+ specs[numspecs].x = (short)xp;
+ specs[numspecs].y = (short)yp;
+ xp += runewidth;
+ numspecs++;
+ continue;
+ }
+
+ /* Fallback on font cache, search the font cache for match. */
+ for (f = 0; f < frclen; f++) {
+ glyphidx = XftCharIndex(xw.dpy, frc[f].font, rune);
+ /* Everything correct. */
+ if (glyphidx && frc[f].flags == frcflags)
+ break;
+ /* We got a default font for a not found glyph. */
+ if (!glyphidx && frc[f].flags == frcflags
+ && frc[f].unicodep == rune) {
+ break;
+ }
+ }
+
+ /* Nothing was found. Use fontconfig to find matching font. */
+ if (f >= frclen) {
+ if (!font->set)
+ font->set = FcFontSort(0, font->pattern,
+ 1, 0, &fcres);
+ fcsets[0] = font->set;
+
+ /*
+ * Nothing was found in the cache. Now use
+ * some dozen of Fontconfig calls to get the
+ * font for one single character.
+ *
+ * Xft and fontconfig are design failures.
+ */
+ fcpattern = FcPatternDuplicate(font->pattern);
+ fccharset = FcCharSetCreate();
+
+ FcCharSetAddChar(fccharset, rune);
+ FcPatternAddCharSet(fcpattern, FC_CHARSET,
+ fccharset);
+ FcPatternAddBool(fcpattern, FC_SCALABLE, 1);
+
+ FcConfigSubstitute(0, fcpattern,
+ FcMatchPattern);
+ FcDefaultSubstitute(fcpattern);
+
+ fontpattern = FcFontSetMatch(0, fcsets, 1,
+ fcpattern, &fcres);
+
+ /*
+ * Overwrite or create the new cache entry.
+ */
+ if (frclen >= LEN(frc)) {
+ frclen = LEN(frc) - 1;
+ XftFontClose(xw.dpy, frc[frclen].font);
+ frc[frclen].unicodep = 0;
+ }
+
+ frc[frclen].font = XftFontOpenPattern(xw.dpy,
+ fontpattern);
+ if (!frc[frclen].font)
+ die("XftFontOpenPattern failed seeking fallback font: %s\n",
+ strerror(errno));
+ frc[frclen].flags = frcflags;
+ frc[frclen].unicodep = rune;
+
+ glyphidx = XftCharIndex(xw.dpy, frc[frclen].font, rune);
+
+ f = frclen;
+ frclen++;
+
+ FcPatternDestroy(fcpattern);
+ FcCharSetDestroy(fccharset);
+ }
+
+ specs[numspecs].font = frc[f].font;
+ specs[numspecs].glyph = glyphidx;
+ specs[numspecs].x = (short)xp;
+ specs[numspecs].y = (short)yp;
+ xp += runewidth;
+ numspecs++;
+ }
+
+ return numspecs;
+}
+
+void
+xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, int y)
+{
+ int charlen = len * ((base.mode & ATTR_WIDE) ? 2 : 1);
+ int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch,
+ width = charlen * win.cw;
+ Color *fg, *bg, *temp, revfg, revbg, truefg, truebg;
+ XRenderColor colfg, colbg;
+ XRectangle r;
+
+ /* Fallback on color display for attributes not supported by the font */
+ if (base.mode & ATTR_ITALIC && base.mode & ATTR_BOLD) {
+ if (dc.ibfont.badslant || dc.ibfont.badweight)
+ base.fg = defaultattr;
+ } else if ((base.mode & ATTR_ITALIC && dc.ifont.badslant) ||
+ (base.mode & ATTR_BOLD && dc.bfont.badweight)) {
+ base.fg = defaultattr;
+ }
+
+ if (IS_TRUECOL(base.fg)) {
+ colfg.alpha = 0xffff;
+ colfg.red = TRUERED(base.fg);
+ colfg.green = TRUEGREEN(base.fg);
+ colfg.blue = TRUEBLUE(base.fg);
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &truefg);
+ fg = &truefg;
+ } else {
+ fg = &dc.col[base.fg];
+ }
+
+ if (IS_TRUECOL(base.bg)) {
+ colbg.alpha = 0xffff;
+ colbg.green = TRUEGREEN(base.bg);
+ colbg.red = TRUERED(base.bg);
+ colbg.blue = TRUEBLUE(base.bg);
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg, &truebg);
+ bg = &truebg;
+ } else {
+ bg = &dc.col[base.bg];
+ }
+
+ /* Change basic system colors [0-7] to bright system colors [8-15] */
+ if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7))
+ fg = &dc.col[base.fg + 8];
+
+ if (IS_SET(MODE_REVERSE)) {
+ if (fg == &dc.col[defaultfg]) {
+ fg = &dc.col[defaultbg];
+ } else {
+ colfg.red = ~fg->color.red;
+ colfg.green = ~fg->color.green;
+ colfg.blue = ~fg->color.blue;
+ colfg.alpha = fg->color.alpha;
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg,
+ &revfg);
+ fg = &revfg;
+ }
+
+ if (bg == &dc.col[defaultbg]) {
+ bg = &dc.col[defaultfg];
+ } else {
+ colbg.red = ~bg->color.red;
+ colbg.green = ~bg->color.green;
+ colbg.blue = ~bg->color.blue;
+ colbg.alpha = bg->color.alpha;
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colbg,
+ &revbg);
+ bg = &revbg;
+ }
+ }
+
+ if ((base.mode & ATTR_BOLD_FAINT) == ATTR_FAINT) {
+ colfg.red = fg->color.red / 2;
+ colfg.green = fg->color.green / 2;
+ colfg.blue = fg->color.blue / 2;
+ colfg.alpha = fg->color.alpha;
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &colfg, &revfg);
+ fg = &revfg;
+ }
+
+ if (base.mode & ATTR_REVERSE) {
+ temp = fg;
+ fg = bg;
+ bg = temp;
+ }
+
+ if (base.mode & ATTR_BLINK && win.mode & MODE_BLINK)
+ fg = bg;
+
+ if (base.mode & ATTR_INVISIBLE)
+ fg = bg;
+
+ /* Intelligent cleaning up of the borders. */
+ if (x == 0) {
+ xclear(0, (y == 0)? 0 : winy, borderpx,
+ winy + win.ch +
+ ((winy + win.ch >= borderpx + win.th)? win.h : 0));
+ }
+ if (winx + width >= borderpx + win.tw) {
+ xclear(winx + width, (y == 0)? 0 : winy, win.w,
+ ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch)));
+ }
+ if (y == 0)
+ xclear(winx, 0, winx + width, borderpx);
+ if (winy + win.ch >= borderpx + win.th)
+ xclear(winx, winy + win.ch, winx + width, win.h);
+
+ /* Clean up the region we want to draw to. */
+ XftDrawRect(xw.draw, bg, winx, winy, width, win.ch);
+
+ /* Set the clip region because Xft is sometimes dirty. */
+ r.x = 0;
+ r.y = 0;
+ r.height = win.ch;
+ r.width = width;
+ XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1);
+
+ /* Render the glyphs. */
+ XftDrawGlyphFontSpec(xw.draw, fg, specs, len);
+
+ /* Render underline and strikethrough. */
+ if (base.mode & ATTR_UNDERLINE) {
+ XftDrawRect(xw.draw, fg, winx, winy + dc.font.ascent + 1,
+ width, 1);
+ }
+
+ if (base.mode & ATTR_STRUCK) {
+ XftDrawRect(xw.draw, fg, winx, winy + 2 * dc.font.ascent / 3,
+ width, 1);
+ }
+
+ /* Reset clip to none. */
+ XftDrawSetClip(xw.draw, 0);
+}
+
+void
+xdrawglyph(Glyph g, int x, int y)
+{
+ int numspecs;
+ XftGlyphFontSpec spec;
+
+ numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y);
+ xdrawglyphfontspecs(&spec, g, numspecs, x, y);
+}
+
+void
+xdrawcursor(int cx, int cy, Glyph g, int ox, int oy, Glyph og)
+{
+ Color drawcol;
+
+ /* remove the old cursor */
+ if (selected(ox, oy))
+ og.mode ^= ATTR_REVERSE;
+ xdrawglyph(og, ox, oy);
+
+ if (IS_SET(MODE_HIDE))
+ return;
+
+ /*
+ * Select the right color for the right mode.
+ */
+ g.mode &= ATTR_BOLD|ATTR_ITALIC|ATTR_UNDERLINE|ATTR_STRUCK|ATTR_WIDE;
+
+ if (IS_SET(MODE_REVERSE)) {
+ g.mode |= ATTR_REVERSE;
+ g.bg = defaultfg;
+ if (selected(cx, cy)) {
+ drawcol = dc.col[defaultcs];
+ g.fg = defaultrcs;
+ } else {
+ drawcol = dc.col[defaultrcs];
+ g.fg = defaultcs;
+ }
+ } else {
+ if (selected(cx, cy)) {
+ g.fg = defaultfg;
+ g.bg = defaultrcs;
+ } else {
+ g.fg = defaultbg;
+ g.bg = defaultcs;
+ }
+ drawcol = dc.col[g.bg];
+ }
+
+ /* draw the new one */
+ if (IS_SET(MODE_FOCUSED)) {
+ switch (win.cursor) {
+ case 7: /* st extension: snowman (U+2603) */
+ g.u = 0x2603;
+ case 0: /* Blinking Block */
+ case 1: /* Blinking Block (Default) */
+ case 2: /* Steady Block */
+ xdrawglyph(g, cx, cy);
+ break;
+ case 3: /* Blinking Underline */
+ case 4: /* Steady Underline */
+ XftDrawRect(xw.draw, &drawcol,
+ borderpx + cx * win.cw,
+ borderpx + (cy + 1) * win.ch - \
+ cursorthickness,
+ win.cw, cursorthickness);
+ break;
+ case 5: /* Blinking bar */
+ case 6: /* Steady bar */
+ XftDrawRect(xw.draw, &drawcol,
+ borderpx + cx * win.cw,
+ borderpx + cy * win.ch,
+ cursorthickness, win.ch);
+ break;
+ }
+ } else {
+ XftDrawRect(xw.draw, &drawcol,
+ borderpx + cx * win.cw,
+ borderpx + cy * win.ch,
+ win.cw - 1, 1);
+ XftDrawRect(xw.draw, &drawcol,
+ borderpx + cx * win.cw,
+ borderpx + cy * win.ch,
+ 1, win.ch - 1);
+ XftDrawRect(xw.draw, &drawcol,
+ borderpx + (cx + 1) * win.cw - 1,
+ borderpx + cy * win.ch,
+ 1, win.ch - 1);
+ XftDrawRect(xw.draw, &drawcol,
+ borderpx + cx * win.cw,
+ borderpx + (cy + 1) * win.ch - 1,
+ win.cw, 1);
+ }
+}
+
+void
+xsetenv(void)
+{
+ char buf[sizeof(long) * 8 + 1];
+
+ snprintf(buf, sizeof(buf), "%lu", xw.win);
+ setenv("WINDOWID", buf, 1);
+}
+
+void
+xsettitle(char *p)
+{
+ XTextProperty prop;
+ DEFAULT(p, opt_title);
+
+ Xutf8TextListToTextProperty(xw.dpy, &p, 1, XUTF8StringStyle,
+ &prop);
+ XSetWMName(xw.dpy, xw.win, &prop);
+ XSetTextProperty(xw.dpy, xw.win, &prop, xw.netwmname);
+ XFree(prop.value);
+}
+
+int
+xstartdraw(void)
+{
+ return IS_SET(MODE_VISIBLE);
+}
+
+void
+xdrawline(Line line, int x1, int y1, int x2)
+{
+ int i, x, ox, numspecs;
+ Glyph base, new;
+ XftGlyphFontSpec *specs = xw.specbuf;
+
+ numspecs = xmakeglyphfontspecs(specs, &line[x1], x2 - x1, x1, y1);
+ i = ox = 0;
+ for (x = x1; x < x2 && i < numspecs; x++) {
+ new = line[x];
+ if (new.mode == ATTR_WDUMMY)
+ continue;
+ if (selected(x, y1))
+ new.mode ^= ATTR_REVERSE;
+ if (i > 0 && ATTRCMP(base, new)) {
+ xdrawglyphfontspecs(specs, base, i, ox, y1);
+ specs += i;
+ numspecs -= i;
+ i = 0;
+ }
+ if (i == 0) {
+ ox = x;
+ base = new;
+ }
+ i++;
+ }
+ if (i > 0)
+ xdrawglyphfontspecs(specs, base, i, ox, y1);
+}
+
+void
+xfinishdraw(void)
+{
+ XCopyArea(xw.dpy, xw.buf, xw.win, dc.gc, 0, 0, win.w,
+ win.h, 0, 0);
+ XSetForeground(xw.dpy, dc.gc,
+ dc.col[IS_SET(MODE_REVERSE)?
+ defaultfg : defaultbg].pixel);
+}
+
+void
+expose(XEvent *ev)
+{
+ redraw();
+}
+
+void
+visibility(XEvent *ev)
+{
+ XVisibilityEvent *e = &ev->xvisibility;
+
+ MODBIT(win.mode, e->state != VisibilityFullyObscured, MODE_VISIBLE);
+}
+
+void
+unmap(XEvent *ev)
+{
+ win.mode &= ~MODE_VISIBLE;
+}
+
+void
+xsetpointermotion(int set)
+{
+ MODBIT(xw.attrs.event_mask, set, PointerMotionMask);
+ XChangeWindowAttributes(xw.dpy, xw.win, CWEventMask, &xw.attrs);
+}
+
+void
+xsetmode(int set, unsigned int flags)
+{
+ int mode = win.mode;
+ MODBIT(win.mode, set, flags);
+ if ((win.mode & MODE_REVERSE) != (mode & MODE_REVERSE))
+ redraw();
+}
+
+int
+xsetcursor(int cursor)
+{
+ DEFAULT(cursor, 1);
+ if (!BETWEEN(cursor, 0, 6))
+ return 1;
+ win.cursor = cursor;
+ return 0;
+}
+
+void
+xseturgency(int add)
+{
+ XWMHints *h = XGetWMHints(xw.dpy, xw.win);
+
+ MODBIT(h->flags, add, XUrgencyHint);
+ XSetWMHints(xw.dpy, xw.win, h);
+ XFree(h);
+}
+
+void
+xbell(void)
+{
+ if (!(IS_SET(MODE_FOCUSED)))
+ xseturgency(1);
+ if (bellvolume)
+ XkbBell(xw.dpy, xw.win, bellvolume, (Atom)NULL);
+}
+
+void
+focus(XEvent *ev)
+{
+ XFocusChangeEvent *e = &ev->xfocus;
+
+ if (e->mode == NotifyGrab)
+ return;
+
+ if (ev->type == FocusIn) {
+ XSetICFocus(xw.xic);
+ win.mode |= MODE_FOCUSED;
+ xseturgency(0);
+ if (IS_SET(MODE_FOCUS))
+ ttywrite("\033[I", 3, 0);
+ } else {
+ XUnsetICFocus(xw.xic);
+ win.mode &= ~MODE_FOCUSED;
+ if (IS_SET(MODE_FOCUS))
+ ttywrite("\033[O", 3, 0);
+ }
+}
+
+int
+match(uint mask, uint state)
+{
+ return mask == XK_ANY_MOD || mask == (state & ~ignoremod);
+}
+
+char*
+kmap(KeySym k, uint state)
+{
+ Key *kp;
+ int i;
+
+ /* Check for mapped keys out of X11 function keys. */
+ for (i = 0; i < LEN(mappedkeys); i++) {
+ if (mappedkeys[i] == k)
+ break;
+ }
+ if (i == LEN(mappedkeys)) {
+ if ((k & 0xFFFF) < 0xFD00)
+ return NULL;
+ }
+
+ for (kp = key; kp < key + LEN(key); kp++) {
+ if (kp->k != k)
+ continue;
+
+ if (!match(kp->mask, state))
+ continue;
+
+ if (IS_SET(MODE_APPKEYPAD) ? kp->appkey < 0 : kp->appkey > 0)
+ continue;
+ if (IS_SET(MODE_NUMLOCK) && kp->appkey == 2)
+ continue;
+
+ if (IS_SET(MODE_APPCURSOR) ? kp->appcursor < 0 : kp->appcursor > 0)
+ continue;
+
+ return kp->s;
+ }
+
+ return NULL;
+}
+
+void
+kpress(XEvent *ev)
+{
+ XKeyEvent *e = &ev->xkey;
+ KeySym ksym;
+ char buf[32], *customkey;
+ int len;
+ Rune c;
+ Status status;
+ Shortcut *bp;
+
+ if (IS_SET(MODE_KBDLOCK))
+ return;
+
+ len = XmbLookupString(xw.xic, e, buf, sizeof buf, &ksym, &status);
+ /* 1. shortcuts */
+ for (bp = shortcuts; bp < shortcuts + LEN(shortcuts); bp++) {
+ if (ksym == bp->keysym && match(bp->mod, e->state)) {
+ bp->func(&(bp->arg));
+ return;
+ }
+ }
+
+ /* 2. custom keys from config.h */
+ if ((customkey = kmap(ksym, e->state))) {
+ ttywrite(customkey, strlen(customkey), 1);
+ return;
+ }
+
+ /* 3. composed string from input method */
+ if (len == 0)
+ return;
+ if (len == 1 && e->state & Mod1Mask) {
+ if (IS_SET(MODE_8BIT)) {
+ if (*buf < 0177) {
+ c = *buf | 0x80;
+ len = utf8encode(c, buf);
+ }
+ } else {
+ buf[1] = buf[0];
+ buf[0] = '\033';
+ len = 2;
+ }
+ }
+ ttywrite(buf, len, 1);
+}
+
+
+void
+cmessage(XEvent *e)
+{
+ /*
+ * See xembed specs
+ * http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html
+ */
+ if (e->xclient.message_type == xw.xembed && e->xclient.format == 32) {
+ if (e->xclient.data.l[1] == XEMBED_FOCUS_IN) {
+ win.mode |= MODE_FOCUSED;
+ xseturgency(0);
+ } else if (e->xclient.data.l[1] == XEMBED_FOCUS_OUT) {
+ win.mode &= ~MODE_FOCUSED;
+ }
+ } else if (e->xclient.data.l[0] == xw.wmdeletewin) {
+ ttyhangup();
+ exit(0);
+ }
+}
+
+void
+resize(XEvent *e)
+{
+ if (e->xconfigure.width == win.w && e->xconfigure.height == win.h)
+ return;
+
+ cresize(e->xconfigure.width, e->xconfigure.height);
+}
+
+void
+run(void)
+{
+ XEvent ev;
+ int w = win.w, h = win.h;
+ fd_set rfd;
+ int xfd = XConnectionNumber(xw.dpy), xev, blinkset = 0, dodraw = 0;
+ int ttyfd;
+ struct timespec drawtimeout, *tv = NULL, now, last, lastblink;
+ long deltatime;
+
+ /* Waiting for window mapping */
+ do {
+ XNextEvent(xw.dpy, &ev);
+ /*
+ * This XFilterEvent call is required because of XOpenIM. It
+ * does filter out the key event and some client message for
+ * the input method too.
+ */
+ if (XFilterEvent(&ev, None))
+ continue;
+ if (ev.type == ConfigureNotify) {
+ w = ev.xconfigure.width;
+ h = ev.xconfigure.height;
+ }
+ } while (ev.type != MapNotify);
+
+ ttyfd = ttynew(opt_line, shell, opt_io, opt_cmd);
+ cresize(w, h);
+
+ clock_gettime(CLOCK_MONOTONIC, &last);
+ lastblink = last;
+
+ for (xev = actionfps;;) {
+ FD_ZERO(&rfd);
+ FD_SET(ttyfd, &rfd);
+ FD_SET(xfd, &rfd);
+
+ if (pselect(MAX(xfd, ttyfd)+1, &rfd, NULL, NULL, tv, NULL) < 0) {
+ if (errno == EINTR)
+ continue;
+ die("select failed: %s\n", strerror(errno));
+ }
+ if (FD_ISSET(ttyfd, &rfd)) {
+ ttyread();
+ if (blinktimeout) {
+ blinkset = tattrset(ATTR_BLINK);
+ if (!blinkset)
+ MODBIT(win.mode, 0, MODE_BLINK);
+ }
+ }
+
+ if (FD_ISSET(xfd, &rfd))
+ xev = actionfps;
+
+ clock_gettime(CLOCK_MONOTONIC, &now);
+ drawtimeout.tv_sec = 0;
+ drawtimeout.tv_nsec = (1000 * 1E6)/ xfps;
+ tv = &drawtimeout;
+
+ dodraw = 0;
+ if (blinktimeout && TIMEDIFF(now, lastblink) > blinktimeout) {
+ tsetdirtattr(ATTR_BLINK);
+ win.mode ^= MODE_BLINK;
+ lastblink = now;
+ dodraw = 1;
+ }
+ deltatime = TIMEDIFF(now, last);
+ if (deltatime > 1000 / (xev ? xfps : actionfps)) {
+ dodraw = 1;
+ last = now;
+ }
+
+ if (dodraw) {
+ while (XPending(xw.dpy)) {
+ XNextEvent(xw.dpy, &ev);
+ if (XFilterEvent(&ev, None))
+ continue;
+ if (handler[ev.type])
+ (handler[ev.type])(&ev);
+ }
+
+ draw();
+ XFlush(xw.dpy);
+
+ if (xev && !FD_ISSET(xfd, &rfd))
+ xev--;
+ if (!FD_ISSET(ttyfd, &rfd) && !FD_ISSET(xfd, &rfd)) {
+ if (blinkset) {
+ if (TIMEDIFF(now, lastblink) \
+ > blinktimeout) {
+ drawtimeout.tv_nsec = 1000;
+ } else {
+ drawtimeout.tv_nsec = (1E6 * \
+ (blinktimeout - \
+ TIMEDIFF(now,
+ lastblink)));
+ }
+ drawtimeout.tv_sec = \
+ drawtimeout.tv_nsec / 1E9;
+ drawtimeout.tv_nsec %= (long)1E9;
+ } else {
+ tv = NULL;
+ }
+ }
+ }
+ }
+}
+
+void
+usage(void)
+{
+ die("usage: %s [-aiv] [-c class] [-f font] [-g geometry]"
+ " [-n name] [-o file]\n"
+ " [-T title] [-t title] [-w windowid]"
+ " [[-e] command [args ...]]\n"
+ " %s [-aiv] [-c class] [-f font] [-g geometry]"
+ " [-n name] [-o file]\n"
+ " [-T title] [-t title] [-w windowid] -l line"
+ " [stty_args ...]\n", argv0, argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ xw.l = xw.t = 0;
+ xw.isfixed = False;
+ win.cursor = cursorshape;
+
+ ARGBEGIN {
+ case 'a':
+ allowaltscreen = 0;
+ break;
+ case 'c':
+ opt_class = EARGF(usage());
+ break;
+ case 'e':
+ if (argc > 0)
+ --argc, ++argv;
+ goto run;
+ case 'f':
+ opt_font = EARGF(usage());
+ break;
+ case 'g':
+ xw.gm = XParseGeometry(EARGF(usage()),
+ &xw.l, &xw.t, &cols, &rows);
+ break;
+ case 'i':
+ xw.isfixed = 1;
+ break;
+ case 'o':
+ opt_io = EARGF(usage());
+ break;
+ case 'l':
+ opt_line = EARGF(usage());
+ break;
+ case 'n':
+ opt_name = EARGF(usage());
+ break;
+ case 't':
+ case 'T':
+ opt_title = EARGF(usage());
+ break;
+ case 'w':
+ opt_embed = EARGF(usage());
+ break;
+ case 'v':
+ die("%s " VERSION "\n", argv0);
+ break;
+ default:
+ usage();
+ } ARGEND;
+
+run:
+ if (argc > 0) /* eat all remaining arguments */
+ opt_cmd = argv;
+
+ if (!opt_title)
+ opt_title = (opt_line || !opt_cmd) ? "st" : opt_cmd[0];
+
+ setlocale(LC_CTYPE, "");
+ XSetLocaleModifiers("");
+ cols = MAX(cols, 1);
+ rows = MAX(rows, 1);
+ tnew(cols, rows);
+ xinit(cols, rows);
+ xsetenv();
+ selinit();
+ run();
+
+ return 0;
+}
diff --git a/terms/st/st-0.8.2/x.o b/terms/st/st-0.8.2/x.o
new file mode 100644
index 0000000..4d92b78
Binary files /dev/null and b/terms/st/st-0.8.2/x.o differ
diff --git a/terms/urxvt/Xdefaults b/terms/urxvt/Xdefaults
new file mode 100644
index 0000000..eeb6cff
--- /dev/null
+++ b/terms/urxvt/Xdefaults
@@ -0,0 +1,44 @@
+!
+! http://font.gohu.org/
+! mkdir -p ~/.fonts
+! https://askubuntu.com/questions/135633/installed-pcf-fonts-not-available
+!
+urxvt.font: xft:gohufont-11:pixelsize=10
+!urxvt.font: xft:terminus:size=10:antialias=true
+urxvt*termName: rxvt
+urxvt*background: #1a0b02
+urxvt*foreground: #e0cbbb
+urxvt*scrollBar: false
+urxvt.perl-lib: /usr/lib/urxvt/perl/
+urxvt.perl-ext-common: default,matcher,font-size
+urxvt*urlLauncher: /usr/bin/jumanji
+urxvt*matcher.button: 1
+
+Xft*dpi: 96
+Xft*antialias: true
+Xft*hinting: full
+
+
+URxvt.transparent: disabled
+URxvt.tintColor: white
+URxvt.shading: disabled
+
+urxvt.foreground: #E8DFD6
+urxvt.background: #021B21
+urxvt.cursorColor: #2E3340
+urxvt.color0: #032C36
+urxvt.color8: #065F73
+urxvt.color1: #C2454E
+urxvt.color9: #EF5847
+urxvt.color2: #7CBF9E
+urxvt.color10: #A2D9B1
+urxvt.color3: #8A7A63
+urxvt.color11: #BEB090
+urxvt.color4: #2E3340
+urxvt.color12: #61778D
+urxvt.color5: #FF5879
+urxvt.color13: #FF99A1
+urxvt.color6: #44B5B1
+urxvt.color14: #9ED9D8
+urxvt.color7: #F2F1B9
+urxvt.color15: #F6F6C9
diff --git a/vim/.ctags b/vim/.ctags
new file mode 100644
index 0000000..4abd5b5
--- /dev/null
+++ b/vim/.ctags
@@ -0,0 +1,30 @@
+--langdef=Rust
+--langmap=Rust:.rs
+--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/
+--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/
+--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/
+--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/
+--regex-Rust=/^[ \t]*(pub[ \t]+)?mod[ \t]+([a-zA-Z0-9_]+)/\2/m,modules,module names/
+--regex-Rust=/^[ \t]*(pub[ \t]+)?(static|const)[ \t]+(mut[ \t]+)?([a-zA-Z0-9_]+)/\4/c,consts,static constants/
+--regex-Rust=/^[ \t]*(pub[ \t]+)?(unsafe[ \t]+)?trait[ \t]+([a-zA-Z0-9_]+)/\3/t,traits,traits/
+--regex-Rust=/^[ \t]*(pub[ \t]+)?(unsafe[ \t]+)?impl([ \t\n]*<[^>]*>)?[ \t]+(([a-zA-Z0-9_:]+)[ \t]*(<[^>]*>)?[ \t]+(for)[ \t]+)?([a-zA-Z0-9_]+)/\5 \7 \8/i,impls,trait implementations/
+--regex-Rust=/^[ \t]*macro_rules![ \t]+([a-zA-Z0-9_]+)/\1/d,macros,macro definitions/
+
+--langmap=perl:+.pod
+--regex-perl=/with[ \t]+([^;]+)[ \t]*?;/\1/w,role,roles/
+--regex-perl=/extends[ \t]+['"]([^'"]+)['"][ \t]*?;/\1/e,extends/
+--regex-perl=/^[ \t]*?use[ \t]+base[ \t]+['"]([^'"]+)['"][ \t]*?;/\1/e,extends/
+--regex-perl=/^[ \t]*?use[ \t]+parent[ \t]+['"]([^'"]+)['"][ \t]*?;/\1/e,extends/
+--regex-perl=/^[ \t]*?use[ \t]+Mojo::Base[ \t]+['"]([^'"]+)['"][ \t]*?;/\1/e,extends/
+--regex-perl=/^[ \t]*?use[ \t]+([^;]+)[ \t]*?;/\1/u,use,uses/
+--regex-perl=/^[ \t]*?require[ \t]+((\w|\:)+)/\1/r,require,requires/
+--regex-perl=/^[ \t]*?has[ \t]+['"]?(\w+)['"]?/\1/a,property,properties/
+--regex-perl=/^[ \t]*?\*(\w+)[ \t]*?=/\1/b,alias,aliases/
+--regex-perl=/->helper\([ \t]?['"]?(\w+)['"]?/\1/h,helper,helpers/
+--regex-perl=/^[ \t]*?our[ \t]*?[\$@%](\w+)/\1/o,our,ours/
+--regex-perl=/^[ \t]*?my[ \t]*?(\$\w+)[ \t]*?=[ \t]*?sub/\1/s,private subroutine,private subroutines/
+--regex-perl=/^\=head1[ \t]+(.+)/\1/d,pod,POD/
+--regex-perl=/^\=head2[ \t]+(.+)/-- \1/d,pod,POD/
+--regex-perl=/^\=head[3][ \t]+(.+)/--- \1/d,pod,POD/
+--regex-perl=/^\=head[4][ \t]+(.+)/---- \1/d,pod,POD/
+-R
diff --git a/vim/.vimrc b/vim/.vimrc
new file mode 100644
index 0000000..f55cf45
--- /dev/null
+++ b/vim/.vimrc
@@ -0,0 +1,86 @@
+" Install vim-plug
+" # Vim (~/.vim/autoload)
+" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
+" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
+
+" Plugins will be downloaded under the specified directory.
+call plug#begin('~/.vim/plugged')
+
+" Declare the list of plugins.
+Plug 'scrooloose/nerdtree'
+Plug 'majutsushi/tagbar'
+Plug 'itchyny/lightline.vim'
+Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
+Plug 'junegunn/fzf.vim'
+Plug 'tpope/vim-eunuch'
+Plug 'rust-lang/rust.vim'
+Plug 'townk/vim-autoclose'
+Plug 'vim-syntastic/syntastic'
+Plug 'arzg/vim-rust-syntax-ext'
+Plug 'rafi/awesome-vim-colorschemes'
+Plug 'https://gitlab.com/yorickpeterse/vim-paper.git'
+
+
+" List ends here. Plugins become visible to Vim after this call.
+call plug#end()
+
+nmap ; :Files<CR>
+" autocmd vimenter * NERDTree
+map <C-n> :NERDTreeToggle<CR>
+" apt-get install exuberant-ctags
+nmap <F8> :TagbarToggle<CR>
+" GUI settings
+set guifont=GohuFont\ 10
+if has('gui_running')
+ autocmd GUIEnter * set vb t_vb=
+ colorscheme parsec
+endif
+
+silent !mkdir -p ~/.vimbk > /dev/null 2>&1
+set backupdir=$HOME/.vimbk/
+set directory=$HOME/.vimbk/
+
+""" Tagbar for Rust
+let g:tagbar_type_rust = {
+ \ 'ctagstype' : 'rust',
+ \ 'kinds' : [
+ \'T:types,type definitions',
+ \'f:functions,function definitions',
+ \'g:enum,enumeration names',
+ \'s:structure names',
+ \'m:modules,module names',
+ \'c:consts,static constants',
+ \'t:traits',
+ \'i:impls,trait implementations',
+ \]
+ \}
+
+""" Tagbar for Perl
+let g:tagbar_type_perl = {
+ \ 'ctagstype' : 'perl',
+ \ 'kinds' : [
+ \ 'p:package:0:0',
+ \ 'w:roles:0:0',
+ \ 'e:extends:0:0',
+ \ 'u:uses:0:0',
+ \ 'r:requires:0:0',
+ \ 'o:ours:0:0',
+ \ 'a:properties:0:0',
+ \ 'b:aliases:0:0',
+ \ 'h:helpers:0:0',
+ \ 's:subroutines:0:0',
+ \ 'd:POD:1:0'
+ \ ]
+ \ }
+
+" Lightline config
+set laststatus=2
+set noshowmode
+
+if !has('gui_running')
+ set t_Co=256
+endif
+
+let g:lightline = {
+ \ 'colorscheme': 'seoul256',
+ \ }