├── .gitignore
├── Makefile
├── README.md
├── dotfiles
├── .Xresources
├── .bash_aliases
├── .bash_profile
├── .bashrc
├── .config
│ ├── fontconfig
│ │ └── fonts.conf
│ ├── nvim
│ │ └── init.vim
│ ├── picom
│ │ └── picom.conf
│ └── xfce4
│ │ └── xfconf
│ │ └── xfce-perchannel-xml
│ │ └── xfce4-keyboard-shortcuts.xml
├── .gitconfig
├── .ssh
│ └── config
├── .tmux.conf
├── .vimrc
├── .xbindkeysrc
└── .xinitrc
├── dwm
├── LICENSE
├── Makefile
├── README
├── config.def.h
├── config.h
├── config.mk
├── drw.c
├── drw.h
├── dwm.1
├── dwm.c
├── dwm.png
├── transient.c
├── util.c
└── util.h
├── pkg
├── configure-system.sh
├── configure-user.sh
├── install-aur-packages.sh
├── install-official-packages.sh
├── packages-aur.txt
├── packages-official.txt
└── update-config.sh
├── s
├── hidpi.sh
├── lodpi.sh
├── lof
├── lof_chromium
└── lof_intellij
├── scripts
├── status-script.sh
└── usr
│ └── local
│ └── bin
│ ├── bye
│ └── importc
└── st
├── .gitignore
├── FUNDING.yml
├── LICENSE
├── Makefile
├── PKGBUILD
├── README.md
├── Xdefaults
├── arg.h
├── boxdraw.c
├── boxdraw_data.h
├── config.h
├── config.mk
├── hb.c
├── hb.h
├── st-copyout
├── st-urlhandler
├── st.1
├── st.c
├── st.h
├── st.info
├── win.h
└── x.c
/.gitignore:
--------------------------------------------------------------------------------
1 | # dwm/st binary
2 | dwm/dwm
3 | st/st
4 |
5 | ################
6 | # C ignore
7 | ################
8 |
9 | # Prerequisites
10 | *.d
11 |
12 | # Object files
13 | *.o
14 | *.ko
15 | *.obj
16 | *.elf
17 |
18 | # Linker output
19 | *.ilk
20 | *.map
21 | *.exp
22 |
23 | # Precompiled Headers
24 | *.gch
25 | *.pch
26 |
27 | # Libraries
28 | *.lib
29 | *.a
30 | *.la
31 | *.lo
32 |
33 | # Shared objects (inc. Windows DLLs)
34 | *.dll
35 | *.so
36 | *.so.*
37 | *.dylib
38 |
39 | # Executables
40 | *.exe
41 | *.out
42 | *.app
43 | *.i*86
44 | *.x86_64
45 | *.hex
46 |
47 | # Debug files
48 | *.dSYM/
49 | *.su
50 | *.idb
51 | *.pdb
52 |
53 | # Kernel Module Compile Results
54 | *.mod*
55 | *.cmd
56 | .tmp_versions/
57 | modules.order
58 | Module.symvers
59 | Mkfile.old
60 | dkms.conf
61 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | update:
2 | cd pkg && ./update-config.sh
3 |
4 | configure:
5 | cd pkg && sudo ./configure-system.sh && ./configure-user.sh
6 |
7 | install-packages:
8 | cd pkg && sudo ./install-official-packages.sh && ./install-aur-packages.sh
9 |
10 | install-wm:
11 | cd dwm && $(MAKE) install
12 |
13 | install-term:
14 | # clean is important to ensure ~/.terminfo
15 | # is updated on system
16 | cd st && $(MAKE) clean install
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # linux-desktop
2 |
3 | This repository contains [joshrosso](https://twitter.com/joshrosso)'s
4 | configuration for his daily driver.
5 |
6 | ## Commands
7 |
8 | To update this repo's contents based on the local system, run:
9 |
10 | ```
11 | make update
12 | ```
13 |
14 | Install all packages (via AUR & official repos):
15 |
16 | ```
17 | make install-packages
18 | ```
19 |
20 | To configure the machine:
21 |
22 | ```
23 | make configure
24 | ```
25 |
26 | dwm compilation/install:
27 |
28 | ```
29 | sudo make install-wm
30 | ```
31 |
32 | st compilation/install:
33 |
34 | ```
35 | sudo make install-term
36 | ```
37 |
38 | ### Runtime details
39 |
40 | This section contains notes about ensuring specific applications run well.
41 |
42 | ## Zoom
43 |
44 | ### Black screen during screen sharing
45 |
46 | When sharing screens against an X window system, a compositor is required or
47 | else your screen will go black while sharing.
48 |
49 | zoom support page:
50 | https://support.zoom.us/hc/en-us/articles/202082128-Black-Screen-During-Screen-Sharing
51 |
52 | While zoom recommends xcompmgr, picom (previously compton) is a more modern
53 | solution. ref: https://www.reddit.com/r/linuxquestions/comments/89ibgy/compton_vs_xcompmgr
54 |
55 | ## OBS
56 |
57 | ### Linux-Browser Plugin
58 |
59 | For linux browser to work (often used to host a chat window) you need the
60 | dependencies that come along with
61 | [obs-linuxbrowser](https://aur.archlinux.org/packages/obs-linuxbrowser/).
62 | Otherwise a window may not show up.
63 |
64 | ## Making Grub Font Readable
65 |
66 | To set a custom font and size, create a grub-compatible font.
67 |
68 | ```
69 | grub-mkfont -s 60 -o /boot/grubfont.pf2 /usr/share/fonts/TTF/Hack-Regular.ttf
70 | ```
71 |
72 | Then add the following in `/etc/default/grub`.
73 |
74 | ```
75 | GRUB_FONT="/boot/grubfont.pf2"
76 | ```
77 |
78 | Regenerate the grub config.
79 |
80 | ```
81 | grub-mkconfig -o /boot/grub/grub.cfg
82 | ```
83 |
--------------------------------------------------------------------------------
/dotfiles/.Xresources:
--------------------------------------------------------------------------------
1 | *.foreground: #F8F8F2
2 | *.background: #121212
3 | *.color0: #000000
4 | *.color8: #4D4D4D
5 | *.color1: #FF5555
6 | *.color9: #FF6E67
7 | *.color2: #50FA7B
8 | *.color10: #5AF78E
9 | *.color3: #F1FA8C
10 | *.color11: #F4F99D
11 | *.color4: #BD93F9
12 | *.color12: #CAA9FA
13 | *.color5: #FF79C6
14 | *.color13: #FF92D0
15 | *.color6: #8BE9FD
16 | *.color14: #9AEDFE
17 | *.color7: #BFBFBF
18 | *.color15: #E6E6E6
19 |
20 | *depth: 32
21 | Xcursor.size: 16
22 |
23 | *utf8: 1
24 | *saveLines: 999999
25 |
26 | !-- Xft settings -- !
27 | !Xft.dpi: 130,
28 | Xft.rgba: rgb
29 | Xft.autohint: 0
30 | Xft.lcdfilter: lcddefault
31 | Xft.hintstyle: hintfull
32 | Xft.hinting: 1
33 | Xft.antialias: 1
34 |
35 | !! fonts
36 | !! antialias and autohint is enabled to improve crispness
37 | !! if using a terminal like st, the libxft-bgra[0] package may be required
38 | !! [0]: https://aur.archlinux.org/packages/libxft-bgra
39 | *.font: Hack:pixelsize=24:antialias=true:autohint=true
40 |
41 | *faceSize: 10
42 | *bellIsUrgent: true
43 |
44 | !! scrollbar
45 | *scrollBar: false
46 |
--------------------------------------------------------------------------------
/dotfiles/.bash_aliases:
--------------------------------------------------------------------------------
1 | # Shortcuts
2 | alias ls='ls --color=auto'
3 | alias grep='grep --color=auto'
4 | alias fgrep='fgrep --color=auto'
5 | alias egrep='egrep --color=auto'
6 | alias c='clear'
7 | alias l='ls -l'
8 | alias ll='ls -la'
9 | alias xclipc='xclip -selection c'
10 | alias xclipp='xclip -o'
11 | alias k='kubectl'
12 | complete -F __start_kubectl k
13 |
--------------------------------------------------------------------------------
/dotfiles/.bash_profile:
--------------------------------------------------------------------------------
1 | #
2 | # ~/.bash_profile
3 | #
4 |
5 | [[ -f ~/.bashrc ]] && . ~/.bashrc
6 |
--------------------------------------------------------------------------------
/dotfiles/.bashrc:
--------------------------------------------------------------------------------
1 | PS1='\n\u @ \h (\e[38;5;198m\w\e[0m) [\e[38;5;148m$(git branch 2>/dev/null | grep '^*' | colrm 1 2)\e[0m]\n\$ '
2 |
3 | # Environment / Path
4 | #export GOBIN=/home/josh/bin
5 | export SCRIPTS=/home/josh/s
6 | #export GOPATH=/home/josh/f/d/go
7 |
8 |
9 | # Load aliases
10 | if [ -f ~/.bash_aliases ]; then
11 | . ~/.bash_aliases
12 | fi
13 |
14 | # Use bash-completion, if available
15 | [[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
16 | . /usr/share/bash-completion/bash_completion
17 |
18 | source <(kubectl completion bash)
19 |
20 | # History
21 | # Don't put duplicate lines or lines starting with space in the history.
22 | #HISTCONTROL=ignoreboth
23 | ## keep unlimited shell history because it's very useful
24 | #export HISTFILESIZE=-1
25 | #export HISTSIZE=-1
26 | #shopt -s histappend # don't overwrite history file after each session
27 |
28 | # on every prompt, save new history to dedicated file and recreate full history
29 | # by reading all files, always keeping history from current session on top.
30 | #update_history () {
31 | #history -a ${HISTFILE}.$$
32 | #history -c
33 | #history -r # load common history file
34 | ## load histories of other sessions
35 | #for f in `ls ${HISTFILE}.[0-9]* 2>/dev/null | grep -v "${HISTFILE}.$$\$"`; do
36 | #history -r $f
37 | #done
38 | #history -r "${HISTFILE}.$$" # load current session history
39 | #}
40 |
41 | #if [[ "$PROMPT_COMMAND" != *update_history* ]]; then
42 | #export PROMPT_COMMAND="update_history; $PROMPT_COMMAND"
43 | #fi
44 |
45 | ## merge session history into main history file on bash exit
46 | #merge_session_history () {
47 | #if [ -e ${HISTFILE}.$$ ]; then
48 | #cat ${HISTFILE}.$$ >> $HISTFILE
49 | #\rm ${HISTFILE}.$$
50 | #fi
51 | #}
52 | #trap merge_session_history EXIT
53 |
54 | export EDITOR=vim
55 |
56 | # enables alias expansion when running watch
57 | alias watch='watch '
58 |
59 | # use fzf for reverse search
60 | source /usr/share/fzf/key-bindings.bash
61 | source /usr/share/fzf/completion.bash
62 |
63 | export ZOOM="https://VMware.zoom.us/my/joshrosso"
64 |
65 | export FZF_CTRL_R_OPTS='--sort --exact'
66 |
67 | [ -f ~/.fzf.bash ] && source ~/.fzf.bash
68 |
--------------------------------------------------------------------------------
/dotfiles/.config/fontconfig/fonts.conf:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | monospace
7 | Hack
8 |
9 |
--------------------------------------------------------------------------------
/dotfiles/.config/nvim/init.vim:
--------------------------------------------------------------------------------
1 | " joshrosso's vim config
2 | " https://octetz.com
3 |
4 | " -------------------------------------------------------------------------------------------------
5 | " plugins
6 | " -------------------------------------------------------------------------------------------------
7 | call plug#begin('~/.vim/plugged')
8 |
9 | " assuming you're using vim-plug: https://github.com/junegunn/vim-plug
10 | Plug 'roxma/nvim-yarp'
11 | " comment/uncomment code
12 | Plug 'scrooloose/nerdcommenter'
13 | " git integration
14 | Plug 'tpope/vim-fugitive'
15 | " builds on fugitive to work with github
16 | Plug 'tpope/vim-rhubarb'
17 | " file browser
18 | Plug 'scrooloose/nerdtree'
19 | " vim color theme
20 | Plug 'embark-theme/vim', { 'as': 'embark', 'branch': 'main' }
21 | " tag browser
22 | Plug 'majutsushi/tagbar'
23 | " status bar at the bottom of vim
24 | Plug 'itchyny/lightline.vim'
25 | " fuzzy search with several integrations
26 | Plug 'junegunn/fzf.vim'
27 |
28 | Plug 'neovim/nvim-lspconfig'
29 |
30 | Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
31 |
32 | call plug#end()
33 |
34 | " remove delay from vim escape
35 | " https://www.reddit.com/r/vim/comments/2391u5/delay_while_using_esc_to_exit_insert_mode
36 | " delay also must be removed from tmux (if using).
37 | " https://www.johnhawthorn.com/2012/09/vi-escape-delays
38 | augroup FastEscape
39 | "autocmd!
40 | "au InsertEnter * set timeoutlen=0
41 | "au InsertLeave * set timeoutlen=1000
42 | augroup END
43 |
44 | " IMPORTANT: :help Ncm2PopupOpen for more information
45 | set completeopt=noinsert,menuone,noselect
46 |
47 | " -------------------------------------------------------------------------------------------------
48 | " colors
49 | " -------------------------------------------------------------------------------------------------
50 | set t_Co=256 "required for urxvt
51 | "set background=dark "dark or light
52 | colorscheme embark
53 |
54 | hi Normal ctermbg=none
55 | highlight LineNr guifg=#050505
56 | set cursorline
57 |
58 | source /usr/share/vim/vimfiles/plugin/fzf.vim
59 |
60 | " -------------------------------------------------------------------------------------------------
61 | " settings
62 | " -------------------------------------------------------------------------------------------------
63 | filetype on "detect files based on type
64 | filetype plugin on "when a file is edited its plugin file is loaded (if there is one for the
65 | "detected filetype)
66 | filetype indent on "maintain indentation
67 | syntax on
68 |
69 | set incsearch "persist search highlight
70 | set hlsearch "highlight as search matches
71 | set mouse=a "use the mouse; you're a terrible person
72 | set noswapfile "the world is a better place without swap
73 | set nobackup "backups never helped anyone
74 | set nu "enable line numbers
75 | set splitbelow "default open splits below (e.g. :GoDoc)
76 | set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< "sets chars representing "invisibles when
77 | ""`set list!` is called
78 | set expandtab "insert space when tab key is pressed
79 | set tabstop=2 "number of spaces inserted when tab is pressed
80 | set softtabstop=2
81 | set shiftwidth=2 "number of spaces to use for each auto indent
82 | set cc=100 "draw bar down column 100
83 |
84 | let g:ackprg = 'ag --vimgrep' "use ag instead of ack
85 |
86 | " -------------------------------------------------------------------------------------------------
87 | " mapping
88 | " -------------------------------------------------------------------------------------------------
89 | let mapleader = "," "leader key is ','
90 |
91 | noremap o :cnext
92 | noremap p :cprevious
93 |
94 | " fzf
95 | noremap f :Rg!
96 | " nerd tree
97 | noremap n :NERDTreeToggle
98 | "! ensures first result is not auto opened
99 | nnoremap t :Tagbar
100 | " toggle show invisibles
101 | nnoremap l :set list!
102 | "ctl+space for assist
103 | inoremap
104 | nnoremap m :set spell!
105 |
106 | " for markdown files:
107 | " auto wrap at 80 characters
108 | " enable spell check
109 | au BufRead,BufNewFile *.md setlocal spell textwidth=80
110 |
111 | " if hidden is not set, TextEdit might fail.
112 | set hidden
113 |
114 | " Some servers have issues with backup files, see #649
115 | set nobackup
116 | set nowritebackup
117 |
118 | " Better display for messages
119 | set cmdheight=2
120 |
121 | " Smaller updatetime for CursorHold & CursorHoldI
122 | set updatetime=300
123 |
124 | " don't give |ins-completion-menu| messages.
125 | set shortmess+=c
126 |
127 | " always show signcolumns
128 | set signcolumn=yes
129 |
130 | lua << EOF
131 | local nvim_lsp = require('lspconfig')
132 |
133 | -- Use an on_attach function to only map the following keys
134 | -- after the language server attaches to the current buffer
135 | local on_attach = function(client, bufnr)
136 | local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
137 | local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
138 |
139 | -- Enable completion triggered by
140 | buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
141 |
142 | -- Mappings.
143 | local opts = { noremap=true, silent=true }
144 |
145 | -- See `:help vim.lsp.*` for documentation on any of the below functions
146 | buf_set_keymap('n', 'gD', 'lua vim.lsp.buf.declaration()', opts)
147 | buf_set_keymap('n', 'gd', 'lua vim.lsp.buf.definition()', opts)
148 | buf_set_keymap('n', 'K', 'lua vim.lsp.buf.hover()', opts)
149 | buf_set_keymap('n', 'gi', 'lua vim.lsp.buf.implementation()', opts)
150 | buf_set_keymap('n', '', 'lua vim.lsp.buf.signature_help()', opts)
151 | buf_set_keymap('n', 'wa', 'lua vim.lsp.buf.add_workspace_folder()', opts)
152 | buf_set_keymap('n', 'wr', 'lua vim.lsp.buf.remove_workspace_folder()', opts)
153 | buf_set_keymap('n', 'wl', 'lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))', opts)
154 | buf_set_keymap('n', 'D', 'lua vim.lsp.buf.type_definition()', opts)
155 | buf_set_keymap('n', 'rn', 'lua vim.lsp.buf.rename()', opts)
156 | buf_set_keymap('n', 'ca', 'lua vim.lsp.buf.code_action()', opts)
157 | buf_set_keymap('n', 'gr', 'lua vim.lsp.buf.references()', opts)
158 | buf_set_keymap('n', 'e', 'lua vim.diagnostic.open_float()', opts)
159 | buf_set_keymap('n', '[d', 'lua vim.diagnostic.goto_prev()', opts)
160 | buf_set_keymap('n', ']d', 'lua vim.diagnostic.goto_next()', opts)
161 | buf_set_keymap('n', 'q', 'lua vim.lsp.diagnostic.set_qflist()', opts)
162 | buf_set_keymap('n', 'f', 'lua vim.lsp.buf.formatting()', opts)
163 |
164 | end
165 |
166 | -- Use a loop to conveniently call 'setup' on multiple servers and
167 | -- map buffer local keybindings when the language server attaches
168 | local servers = { 'pyright', 'gopls', 'rust_analyzer', 'tsserver' }
169 | for _, lsp in ipairs(servers) do
170 | nvim_lsp[lsp].setup {
171 | on_attach = on_attach,
172 | flags = {
173 | debounce_text_changes = 150,
174 | }
175 | }
176 | end
177 | EOF
178 |
--------------------------------------------------------------------------------
/dotfiles/.config/picom/picom.conf:
--------------------------------------------------------------------------------
1 | # Thank you code_nomad: http://9m.no/ꪯ鵞
2 | # and Arch Wiki contributors: https://wiki.archlinux.org/index.php/Compton
3 |
4 | #################################
5 | #
6 | # Backend
7 | #
8 | #################################
9 |
10 | # Backend to use: "xrender" or "glx".
11 | # GLX backend is typically much faster but depends on a sane driver.
12 | backend = "glx";
13 |
14 | #################################
15 | #
16 | # GLX backend
17 | #
18 | #################################
19 |
20 | glx-no-stencil = true;
21 |
22 | # GLX backend: Copy unmodified regions from front buffer instead of redrawing them all.
23 | # My tests with nvidia-drivers show a 10% decrease in performance when the whole screen is modified,
24 | # but a 20% increase when only 1/4 is.
25 | # My tests on nouveau show terrible slowdown.
26 | glx-copy-from-front = false;
27 |
28 | # GLX backend: Use MESA_copy_sub_buffer to do partial screen update.
29 | # My tests on nouveau shows a 200% performance boost when only 1/4 of the screen is updated.
30 | # May break VSync and is not available on some drivers.
31 | # Overrides --glx-copy-from-front.
32 | # glx-use-copysubbuffermesa = true;
33 |
34 | # GLX backend: Avoid rebinding pixmap on window damage.
35 | # Probably could improve performance on rapid window content changes, but is known to break things on some drivers (LLVMpipe).
36 | # Recommended if it works.
37 | # glx-no-rebind-pixmap = true;
38 |
39 | # GLX backend: GLX buffer swap method we assume.
40 | # Could be undefined (0), copy (1), exchange (2), 3-6, or buffer-age (-1).
41 | # undefined is the slowest and the safest, and the default value.
42 | # copy is fastest, but may fail on some drivers,
43 | # 2-6 are gradually slower but safer (6 is still faster than 0).
44 | # Usually, double buffer means 2, triple buffer means 3.
45 | # buffer-age means auto-detect using GLX_EXT_buffer_age, supported by some drivers.
46 | # Useless with --glx-use-copysubbuffermesa.
47 | # Partially breaks --resize-damage.
48 | # Defaults to undefined.
49 | #glx-swap-method = "undefined";
50 |
51 | #################################
52 | #
53 | # Shadows
54 | #
55 | #################################
56 |
57 | # Enabled client-side shadows on windows.
58 | shadow = true;
59 | # The blur radius for shadows. (default 12)
60 | shadow-radius = 5;
61 | # The left offset for shadows. (default -15)
62 | shadow-offset-x = -5;
63 | # The top offset for shadows. (default -15)
64 | shadow-offset-y = -5;
65 | # The translucency for shadows. (default .75)
66 | shadow-opacity = 0.5;
67 |
68 | # Set if you want different colour shadows
69 | # shadow-red = 0.0;
70 | # shadow-green = 0.0;
71 | # shadow-blue = 0.0;
72 |
73 | # The shadow exclude options are helpful if you have shadows enabled. Due to the way picom draws its shadows, certain applications will have visual glitches
74 | # (most applications are fine, only apps that do weird things with xshapes or argb are affected).
75 | # This list includes all the affected apps I found in my testing. The "! name~=''" part excludes shadows on any "Unknown" windows, this prevents a visual glitch with the XFWM alt tab switcher.
76 | shadow-exclude = [
77 | "! name~=''",
78 | "name = 'Notification'",
79 | "name = 'Plank'",
80 | "name = 'Docky'",
81 | "name = 'Kupfer'",
82 | "name = 'xfce4-notifyd'",
83 | "name *= 'VLC'",
84 | "name *= 'compton'",
85 | "name *= 'picom'",
86 | "name *= 'Chromium'",
87 | "name *= 'Chrome'",
88 | "name = 'cpt_frame_window'",
89 | "class_g = 'Firefox' && argb",
90 | "class_g = 'Conky'",
91 | "class_g = 'Kupfer'",
92 | "class_g = 'Synapse'",
93 | "class_g ?= 'Notify-osd'",
94 | "class_g ?= 'Cairo-dock'",
95 | "class_g ?= 'Xfce4-notifyd'",
96 | "class_g ?= 'Xfce4-power-manager'",
97 | "_GTK_FRAME_EXTENTS@:c",
98 | "_NET_WM_STATE@:32a *= '_NET_WM_STATE_HIDDEN'"
99 | ];
100 | # Avoid drawing shadow on all shaped windows (see also: --detect-rounded-corners)
101 | shadow-ignore-shaped = false;
102 |
103 | #################################
104 | #
105 | # Opacity
106 | #
107 | #################################
108 |
109 | inactive-opacity = 1;
110 | active-opacity = 1;
111 | frame-opacity = 1;
112 | inactive-opacity-override = false;
113 |
114 | # Dim inactive windows. (0.0 - 1.0)
115 | # inactive-dim = 0.2;
116 | # Do not let dimness adjust based on window opacity.
117 | # inactive-dim-fixed = true;
118 | # Blur background of transparent windows. Bad performance with X Render backend. GLX backend is preferred.
119 | # blur-background = true;
120 | # Blur background of opaque windows with transparent frames as well.
121 | # blur-background-frame = true;
122 | # Do not let blur radius adjust based on window opacity.
123 | blur-background-fixed = false;
124 | blur-background-exclude = [
125 | "window_type = 'dock'",
126 | "window_type = 'desktop'"
127 | ];
128 |
129 | #################################
130 | #
131 | # Fading
132 | #
133 | #################################
134 |
135 | # Fade windows during opacity changes.
136 | fading = true;
137 | # The time between steps in a fade in milliseconds. (default 10).
138 | fade-delta = 4;
139 | # Opacity change between steps while fading in. (default 0.028).
140 | fade-in-step = 0.03;
141 | # Opacity change between steps while fading out. (default 0.03).
142 | fade-out-step = 0.03;
143 | # Fade windows in/out when opening/closing
144 | # no-fading-openclose = true;
145 |
146 | # Specify a list of conditions of windows that should not be faded.
147 | fade-exclude = [ ];
148 |
149 | #################################
150 | #
151 | # Other
152 | #
153 | #################################
154 |
155 | # Try to detect WM windows and mark them as active.
156 | mark-wmwin-focused = true;
157 | # Mark all non-WM but override-redirect windows active (e.g. menus).
158 | mark-ovredir-focused = true;
159 | # Use EWMH _NET_WM_ACTIVE_WINDOW to determine which window is focused instead of using FocusIn/Out events.
160 | # Usually more reliable but depends on a EWMH-compliant WM.
161 | use-ewmh-active-win = true;
162 | # Detect rounded corners and treat them as rectangular when --shadow-ignore-shaped is on.
163 | detect-rounded-corners = true;
164 |
165 | # Detect _NET_WM_OPACITY on client windows, useful for window managers not passing _NET_WM_OPACITY of client windows to frame windows.
166 | # This prevents opacity being ignored for some apps.
167 | # For example without this enabled my xfce4-notifyd is 100% opacity no matter what.
168 | detect-client-opacity = true;
169 |
170 | # Specify refresh rate of the screen.
171 | # If not specified or 0, picom will try detecting this with X RandR extension.
172 | refresh-rate = 0;
173 |
174 | # Vertical synchronization: match the refresh rate of the monitor
175 | vsync = false;
176 |
177 | # Enable DBE painting mode, intended to use with VSync to (hopefully) eliminate tearing.
178 | # Reported to have no effect, though.
179 | dbe = false;
180 |
181 | # Limit picom to repaint at most once every 1 / refresh_rate second to boost performance.
182 | # This should not be used with --vsync drm/opengl/opengl-oml as they essentially does --sw-opti's job already,
183 | # unless you wish to specify a lower refresh rate than the actual value.
184 | #sw-opti = true;
185 |
186 | # Unredirect all windows if a full-screen opaque window is detected, to maximize performance for full-screen windows, like games.
187 | # Known to cause flickering when redirecting/unredirecting windows.
188 | unredir-if-possible = false;
189 |
190 | # Specify a list of conditions of windows that should always be considered focused.
191 | focus-exclude = [ ];
192 |
193 | # Use WM_TRANSIENT_FOR to group windows, and consider windows in the same group focused at the same time.
194 | detect-transient = true;
195 | # Use WM_CLIENT_LEADER to group windows, and consider windows in the same group focused at the same time.
196 | # WM_TRANSIENT_FOR has higher priority if --detect-transient is enabled, too.
197 | detect-client-leader = true;
198 |
199 | #################################
200 | #
201 | # Window type settings
202 | #
203 | #################################
204 |
205 | wintypes:
206 | {
207 | tooltip =
208 | {
209 | # fade: Fade the particular type of windows.
210 | fade = true;
211 | # shadow: Give those windows shadow
212 | shadow = false;
213 | # opacity: Default opacity for the type of windows.
214 | opacity = 0.85;
215 | # focus: Whether to always consider windows of this type focused.
216 | focus = true;
217 | };
218 | };
219 |
220 | ######################
221 | #
222 | # XSync
223 | # See: https://github.com/yshui/picom/commit/b18d46bcbdc35a3b5620d817dd46fbc76485c20d
224 | #
225 | ######################
226 |
227 | # Use X Sync fence to sync clients' draw calls. Needed on nvidia-drivers with GLX backend for some users.
228 | xrender-sync-fence = true;
229 |
--------------------------------------------------------------------------------
/dotfiles/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml:
--------------------------------------------------------------------------------
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 |
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 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
--------------------------------------------------------------------------------
/dotfiles/.gitconfig:
--------------------------------------------------------------------------------
1 | [url "git@github.com:"]
2 | insteadOf = https://github.com/
3 |
4 | [include]
5 | path = ~/.config/git/internal-sites
6 |
7 | [user]
8 | email = joshrosso@gmail.com
9 | name = joshrosso
10 |
11 | [code]
12 | editor = vim
13 | [core]
14 | excludesfile = /home/josh/.gitignore_global
15 | [commit]
16 |
--------------------------------------------------------------------------------
/dotfiles/.ssh/config:
--------------------------------------------------------------------------------
1 | Include ~/.config/ssh/internal-sites
2 |
3 | Host github.com
4 | HostName github.com
5 | User joshrosso
6 | IdentityFile ~/.ssh/joshrosso.pem
7 |
8 | Host git.atlas.oreilly.com
9 | HostName git.atlas.oreilly.com
10 | User joshrosso
11 | IdentityFile ~/.ssh/atlas
12 |
13 | # Specifies whether keys should be automatically added to a running ssh-agent(1). If this option is set to yes and a key is loaded from a file, the key and its passphrase are
14 | # added to the agent with the default lifetime, as if by ssh-add(1). If this option is set to ask, ssh(1) will require confirmation using the SSH_ASKPASS program before adding
15 | # a key (see ssh-add(1) for details). If this option is set to confirm, each use of the key must be confirmed, as if the -c option was specified to ssh-add(1). If this option
16 | # is set to no, no keys are added to the agent. The argument must be yes, confirm, ask, or no (the default).
17 | #AddKeysToAgent ask
18 |
--------------------------------------------------------------------------------
/dotfiles/.tmux.conf:
--------------------------------------------------------------------------------
1 | # joshrosso's tmux config
2 | # https://octetz.com
3 |
4 | # -------------------------------------------------------------------------------------------------
5 | # configuration notes
6 | # -------------------------------------------------------------------------------------------------
7 | # set: alias for set-option
8 | # setw: alias for set-window-option
9 | # -g: sets the option globally; not to a specific session
10 |
11 | # bind: alias for bind-key
12 | # -r: specifies binding can repeat
13 | # -T: specifies the key table a binding relates to (e.g. copy-mode)
14 | # can use list-bindings to view what is set
15 | # default sets bindings to the prefix table (ie after (C-b)
16 |
17 | # to reload configuration after change, run:
18 | # source-file ~/.tmux.conf
19 |
20 | # -------------------------------------------------------------------------------------------------
21 | # global configuration
22 | # -------------------------------------------------------------------------------------------------
23 | # no delay when hitting esc in apps like vim
24 | # ref: https://www.johnhawthorn.com/2012/09/vi-escape-delays
25 | set -s escape-time 0
26 | # number of lines available to scroll back
27 | set -g history-limit 10000
28 | # milliseconds after tmux command before needing to hit prefix key again
29 | set -g repeat-time 1000
30 | # do not worry about the terminal buffer for clipboard; especially important for st
31 | set -g set-clipboard off
32 | # mouse interaction is enabled
33 | set -g mouse on
34 | # use vi-style keys in copy mode
35 | setw -g mode-keys vi
36 |
37 | # -------------------------------------------------------------------------------------------------
38 | # key bindings
39 | # -------------------------------------------------------------------------------------------------
40 | # hjkl (vim) naviagation to switch panes after hitting prefix key
41 | bind -r h select-pane -L
42 | bind -r j select-pane -D
43 | bind -r k select-pane -U
44 | bind -r l select-pane -R
45 |
46 | # HJKL resizes panes after hitting prefix key
47 | bind -r J resize-pane -D 5
48 | bind -r K resize-pane -U 5
49 | bind -r H resize-pane -L 5
50 | bind -r L resize-pane -R 5
51 |
52 | # map vi keys when in copy-mode for selection and copy (yank)
53 | bind -T copy-mode-vi 'v' send -X begin-selection
54 | bind -T copy-mode-vi 'V' send -X select-line
55 | bind -T copy-mode-vi 'r' send -X rectangle-toggle
56 | bind -T copy-mode-vi 'y' send -X copy-pipe-and-cancel "xclip -in -selection clipboard"
57 | # mouse selection immediately copies to clipboard
58 | bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-and-cancel\; run "tmux show-buffer | xclip -sel clip -i > /dev/null"
59 |
60 | # drag windows with mouse to reorder
61 | bind -n MouseDrag1Status swap-window -t=
62 |
63 | # -------------------------------------------------------------------------------------------------
64 | # theme
65 | # -------------------------------------------------------------------------------------------------
66 |
67 | # statusbar
68 | set -g status-bg colour240
69 | set -g status-justify left
70 | #set -g status-position bottom
71 |
72 | # make current pane white
73 | setw -g window-status-current-style fg=black,bg=white
74 | setw -g window-status-style fg='#cccccc'
75 |
76 | # remove junk in right status bar
77 | set-option -g status-right ""
78 | set-option -g status-left ""
79 |
80 | # set paneborder color
81 | set -g pane-border-style fg='#3A3B3C'
82 | set -g pane-active-border-style fg='#3A3B3C'
83 |
--------------------------------------------------------------------------------
/dotfiles/.vimrc:
--------------------------------------------------------------------------------
1 | " joshrosso's vim config
2 | " https://octetz.com
3 |
4 | " -------------------------------------------------------------------------------------------------
5 | " plugins
6 | " -------------------------------------------------------------------------------------------------
7 | call plug#begin('~/.vim/plugged')
8 |
9 | " assuming you're using vim-plug: https://github.com/junegunn/vim-plug
10 | Plug 'roxma/nvim-yarp'
11 | " comment/uncomment code
12 | Plug 'scrooloose/nerdcommenter'
13 | " git integration
14 | Plug 'tpope/vim-fugitive'
15 | " builds on fugitive to work with github
16 | Plug 'tpope/vim-rhubarb'
17 | " file browser
18 | Plug 'scrooloose/nerdtree'
19 | " vim color theme
20 | Plug 'embark-theme/vim', { 'as': 'embark', 'branch': 'main' }
21 | " tag browser
22 | Plug 'majutsushi/tagbar'
23 | " status bar at the bottom of vim
24 | Plug 'itchyny/lightline.vim'
25 | " fuzzy search with several integrations
26 | Plug 'junegunn/fzf.vim'
27 | " LSP client, providing language features
28 | Plug 'autozimu/LanguageClient-neovim', {
29 | \ 'branch': 'next',
30 | \ 'do': 'bash install.sh',
31 | \ }
32 |
33 | call plug#end()
34 |
35 | " remove delay from vim escape
36 | " https://www.reddit.com/r/vim/comments/2391u5/delay_while_using_esc_to_exit_insert_mode
37 | " delay also must be removed from tmux (if using).
38 | " https://www.johnhawthorn.com/2012/09/vi-escape-delays
39 | augroup FastEscape
40 | "autocmd!
41 | "au InsertEnter * set timeoutlen=0
42 | "au InsertLeave * set timeoutlen=1000
43 | augroup END
44 |
45 | " IMPORTANT: :help Ncm2PopupOpen for more information
46 | set completeopt=noinsert,menuone,noselect
47 | " -------------------------------------------------------------------------------------------------
48 | " colors
49 | " -------------------------------------------------------------------------------------------------
50 | set t_Co=256 "required for urxvt
51 | "set background=dark "dark or light
52 | colorscheme embark
53 |
54 | hi Normal ctermbg=none
55 | highlight clear LineNr
56 |
57 | source /usr/share/vim/vimfiles/plugin/fzf.vim
58 |
59 | " -------------------------------------------------------------------------------------------------
60 | " settings
61 | " -------------------------------------------------------------------------------------------------
62 | filetype on "detect files based on type
63 | filetype plugin on "when a file is edited its plugin file is loaded (if there is one for the
64 | "detected filetype)
65 | filetype indent on "maintain indentation
66 | syntax on
67 |
68 | set incsearch "persist search highlight
69 | set hlsearch "highlight as search matches
70 | set mouse=a "use the mouse; you're a terrible person
71 | set noswapfile "the world is a better place without swap
72 | set nobackup "backups never helped anyone
73 | set nu "enable line numbers
74 | set splitbelow "default open splits below (e.g. :GoDoc)
75 | set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:< "sets chars representing "invisibles when
76 | ""`set list!` is called
77 | set expandtab "insert space when tab key is pressed
78 | set tabstop=2 "number of spaces inserted when tab is pressed
79 | set softtabstop=2
80 | set shiftwidth=2 "number of spaces to use for each auto indent
81 | set cc=100 "draw bar down column 100
82 |
83 | let g:ackprg = 'ag --vimgrep' "use ag instead of ack
84 |
85 | " -------------------------------------------------------------------------------------------------
86 | " mapping
87 | " -------------------------------------------------------------------------------------------------
88 | let mapleader = "," "leader key is ','
89 |
90 | " fzf
91 | noremap f :Rg!
92 | " nerd tree
93 | noremap n :NERDTreeToggle
94 | "! ensures first result is not auto opened
95 | nnoremap t :Tagbar
96 | " toggle show invisibles
97 | nnoremap l :set list!
98 | "ctl+space for assist
99 | inoremap
100 | nnoremap m :set spell!
101 |
102 | " for markdown files:
103 | " auto wrap at 80 characters
104 | " enable spell check
105 | au BufRead,BufNewFile *.md setlocal spell textwidth=80
106 |
107 | " if hidden is not set, TextEdit might fail.
108 | set hidden
109 |
110 | " Some servers have issues with backup files, see #649
111 | set nobackup
112 | set nowritebackup
113 |
114 | " Better display for messages
115 | set cmdheight=2
116 |
117 | " Smaller updatetime for CursorHold & CursorHoldI
118 | set updatetime=300
119 |
120 | " don't give |ins-completion-menu| messages.
121 | set shortmess+=c
122 |
123 | " always show signcolumns
124 | set signcolumn=yes
125 |
126 | let g:LanguageClient_serverCommands = {
127 | \ 'go': ['/usr/bin/gopls'],
128 | \ 'c': ['/usr/bin/clangd'],
129 | \ 'haskell': ['haskell-language-server-8.10.4'],
130 | \ 'rust': ['/usr/bin/rustup', 'run', 'stable', 'rls'],
131 | \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
132 | \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
133 | \ 'python': ['/usr/local/bin/pyls'],
134 | \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
135 | \ }
136 |
137 | nnoremap :call LanguageClient_contextMenu()
138 | " Or map each action separately
139 | nnoremap K :call LanguageClient#textDocument_hover()
140 | nnoremap gd :call LanguageClient#textDocument_definition()
141 | nnoremap gi :call LanguageClient#textDocument_implementation()
142 | nnoremap gt :call LanguageClient#textDocument_typeDefinition()
143 | nnoremap :call LanguageClient#textDocument_rename()
144 |
--------------------------------------------------------------------------------
/dotfiles/.xbindkeysrc:
--------------------------------------------------------------------------------
1 | # launch blueman-manager
2 | #"lof /usr/bin/python\ /usr/bin/blueman-manager"
3 | #m:0x40 + c:26
4 | #Mod4 + e
5 |
6 | ## launch demu
7 | "dmenu_run -fn Hack-16:normal -l 5"
8 | m:0x40 + c:65
9 | Mod4 + space
10 |
11 | "import -window \"$(xdotool getwindowfocus -f)\" png:- | xclip -selection clipboard -t image/png"
12 | m:0x40 + c:12
13 | Mod4 + 3
14 |
15 | # launch browser
16 | "lof_chromium"
17 | m:0x40 + c:45
18 | Mod4 + k
19 |
20 | # launch or focus terminal
21 | "lof st\ \-e\ tmux"
22 | m:0x40 + c:44
23 | Mod4 + j
24 |
25 | # launch or focus editor
26 | "lof gimp"
27 | m:0x40 + c:42
28 | Mod4 + g
29 |
30 | # launch or focus nemo
31 | "lof thunar"
32 | m:0x40 + c:40
33 | Mod4 + d
34 |
35 | # launch sound control
36 | # lof not required as this is defualt behavior
37 | "pavucontrol"
38 | m:0x40 + c:39
39 | Mod4 + s
40 |
41 | # resize window for OBS
42 | "wmctrl -r :ACTIVE: -e 0,0,0,1520,1080"
43 | m:0x41 + c:10
44 | Shift+Mod4 + 1
45 |
46 | # resize window for sharing in zoom
47 | "wmctrl -r :ACTIVE: -e 0,0,0,1920,1080"
48 | m:0x41 + c:11
49 | Shift+Mod4 + 2
50 |
51 | # launch or focus slack
52 | "lof /usr/lib/slack/slack"
53 | m:0x40 + c:30
54 | Mod4 + u
55 |
--------------------------------------------------------------------------------
/dotfiles/.xinitrc:
--------------------------------------------------------------------------------
1 | xset r rate 150 60
2 | jackd
3 | xbindkeys -p
4 | startxfce4
5 |
--------------------------------------------------------------------------------
/dwm/LICENSE:
--------------------------------------------------------------------------------
1 | MIT/X Consortium License
2 |
3 | © 2006-2019 Anselm R Garbe
4 | © 2006-2009 Jukka Salmi
5 | © 2006-2007 Sander van Dijk
6 | © 2007-2011 Peter Hartlich
7 | © 2007-2009 Szabolcs Nagy
8 | © 2007-2009 Christof Musik
9 | © 2007-2009 Premysl Hruby
10 | © 2007-2008 Enno Gottox Boland
11 | © 2008 Martin Hurton
12 | © 2008 Neale Pickett
13 | © 2009 Mate Nagy
14 | © 2010-2016 Hiltjo Posthuma
15 | © 2010-2012 Connor Lane Smith
16 | © 2011 Christoph Lohmann <20h@r-36.net>
17 | © 2015-2016 Quentin Rameau
18 | © 2015-2016 Eric Pruitt
19 | © 2016-2017 Markus Teich
20 |
21 | Permission is hereby granted, free of charge, to any person obtaining a
22 | copy of this software and associated documentation files (the "Software"),
23 | to deal in the Software without restriction, including without limitation
24 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
25 | and/or sell copies of the Software, and to permit persons to whom the
26 | Software is furnished to do so, subject to the following conditions:
27 |
28 | The above copyright notice and this permission notice shall be included in
29 | all copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
34 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
36 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
37 | DEALINGS IN THE SOFTWARE.
38 |
--------------------------------------------------------------------------------
/dwm/Makefile:
--------------------------------------------------------------------------------
1 | # dwm - dynamic window manager
2 | # See LICENSE file for copyright and license details.
3 |
4 | include config.mk
5 |
6 | SRC = drw.c dwm.c util.c
7 | OBJ = ${SRC:.c=.o}
8 |
9 | all: options dwm
10 |
11 | options:
12 | @echo dwm build options:
13 | @echo "CFLAGS = ${CFLAGS}"
14 | @echo "LDFLAGS = ${LDFLAGS}"
15 | @echo "CC = ${CC}"
16 |
17 | .c.o:
18 | ${CC} -c ${CFLAGS} $<
19 |
20 | ${OBJ}: config.h config.mk
21 |
22 | config.h:
23 | cp config.def.h $@
24 |
25 | dwm: ${OBJ}
26 | ${CC} -o $@ ${OBJ} ${LDFLAGS}
27 |
28 | clean:
29 | rm -f dwm ${OBJ} dwm-${VERSION}.tar.gz
30 |
31 | dist: clean
32 | mkdir -p dwm-${VERSION}
33 | cp -R LICENSE Makefile README config.def.h config.mk\
34 | dwm.1 drw.h util.h ${SRC} dwm.png transient.c dwm-${VERSION}
35 | tar -cf dwm-${VERSION}.tar dwm-${VERSION}
36 | gzip dwm-${VERSION}.tar
37 | rm -rf dwm-${VERSION}
38 |
39 | install: all
40 | mkdir -p ${DESTDIR}${PREFIX}/bin
41 | cp -f dwm ${DESTDIR}${PREFIX}/bin
42 | chmod 755 ${DESTDIR}${PREFIX}/bin/dwm
43 | mkdir -p ${DESTDIR}${MANPREFIX}/man1
44 | sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1
45 | chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1
46 |
47 | uninstall:
48 | rm -f ${DESTDIR}${PREFIX}/bin/dwm\
49 | ${DESTDIR}${MANPREFIX}/man1/dwm.1
50 |
51 | .PHONY: all options clean dist install uninstall
52 |
--------------------------------------------------------------------------------
/dwm/README:
--------------------------------------------------------------------------------
1 | dwm - dynamic window manager
2 | ============================
3 | dwm is an extremely fast, small, and dynamic window manager for X.
4 |
5 |
6 | Requirements
7 | ------------
8 | In order to build dwm you need the Xlib header files.
9 |
10 |
11 | Installation
12 | ------------
13 | Edit config.mk to match your local setup (dwm is installed into
14 | the /usr/local namespace by default).
15 |
16 | Afterwards enter the following command to build and install dwm (if
17 | necessary as root):
18 |
19 | make clean install
20 |
21 |
22 | Running dwm
23 | -----------
24 | Add the following line to your .xinitrc to start dwm using startx:
25 |
26 | exec dwm
27 |
28 | In order to connect dwm to a specific display, make sure that
29 | the DISPLAY environment variable is set correctly, e.g.:
30 |
31 | DISPLAY=foo.bar:1 exec dwm
32 |
33 | (This will start dwm on display :1 of the host foo.bar.)
34 |
35 | In order to display status info in the bar, you can do something
36 | like this in your .xinitrc:
37 |
38 | while xsetroot -name "`date` `uptime | sed 's/.*,//'`"
39 | do
40 | sleep 1
41 | done &
42 | exec dwm
43 |
44 |
45 | Configuration
46 | -------------
47 | The configuration of dwm is done by creating a custom config.h
48 | and (re)compiling the source code.
49 |
--------------------------------------------------------------------------------
/dwm/config.def.h:
--------------------------------------------------------------------------------
1 | /* See LICENSE file for copyright and license details. */
2 |
3 | /* appearance */
4 | static const unsigned int borderpx = 1; /* border pixel of windows */
5 | static const unsigned int snap = 32; /* snap pixel */
6 | static const int showbar = 1; /* 0 means no bar */
7 | static const int topbar = 1; /* 0 means bottom bar */
8 | static const char *fonts[] = { "monospace:size=10" };
9 | static const char dmenufont[] = "monospace:size=10";
10 | static const char col_gray1[] = "#222222";
11 | static const char col_gray2[] = "#444444";
12 | static const char col_gray3[] = "#bbbbbb";
13 | static const char col_gray4[] = "#eeeeee";
14 | static const char col_cyan[] = "#005577";
15 | static const char *colors[][3] = {
16 | /* fg bg border */
17 | [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
18 | [SchemeSel] = { col_gray4, col_cyan, col_cyan },
19 | };
20 |
21 | /* tagging */
22 | static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
23 |
24 | static const Rule rules[] = {
25 | /* xprop(1):
26 | * WM_CLASS(STRING) = instance, class
27 | * WM_NAME(STRING) = title
28 | */
29 | /* class instance title tags mask isfloating monitor */
30 | { "Gimp", NULL, NULL, 0, 1, -1 },
31 | { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
32 | };
33 |
34 | /* layout(s) */
35 | static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
36 | static const int nmaster = 1; /* number of clients in master area */
37 | static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
38 |
39 | static const Layout layouts[] = {
40 | /* symbol arrange function */
41 | { "[]=", tile }, /* first entry is default */
42 | { "><>", NULL }, /* no layout function means floating behavior */
43 | { "[M]", monocle },
44 | };
45 |
46 | /* key definitions */
47 | #define MODKEY Mod1Mask
48 | #define TAGKEYS(KEY,TAG) \
49 | { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
50 | { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
51 | { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
52 | { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
53 |
54 | /* helper for spawning shell commands in the pre dwm-5.0 fashion */
55 | #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
56 |
57 | /* commands */
58 | static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
59 | static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
60 | static const char *termcmd[] = { "st", NULL };
61 |
62 | static Key keys[] = {
63 | /* modifier key function argument */
64 | { MODKEY, XK_p, spawn, {.v = dmenucmd } },
65 | { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
66 | { MODKEY, XK_b, togglebar, {0} },
67 | { MODKEY, XK_j, focusstack, {.i = +1 } },
68 | { MODKEY, XK_k, focusstack, {.i = -1 } },
69 | { MODKEY, XK_i, incnmaster, {.i = +1 } },
70 | { MODKEY, XK_d, incnmaster, {.i = -1 } },
71 | { MODKEY, XK_h, setmfact, {.f = -0.05} },
72 | { MODKEY, XK_l, setmfact, {.f = +0.05} },
73 | { MODKEY, XK_Return, zoom, {0} },
74 | { MODKEY, XK_Tab, view, {0} },
75 | { MODKEY|ShiftMask, XK_c, killclient, {0} },
76 | { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
77 | { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
78 | { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
79 | { MODKEY, XK_space, setlayout, {0} },
80 | { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
81 | { MODKEY, XK_0, view, {.ui = ~0 } },
82 | { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
83 | { MODKEY, XK_comma, focusmon, {.i = -1 } },
84 | { MODKEY, XK_period, focusmon, {.i = +1 } },
85 | { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
86 | { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
87 | TAGKEYS( XK_1, 0)
88 | TAGKEYS( XK_2, 1)
89 | TAGKEYS( XK_3, 2)
90 | TAGKEYS( XK_4, 3)
91 | TAGKEYS( XK_5, 4)
92 | TAGKEYS( XK_6, 5)
93 | TAGKEYS( XK_7, 6)
94 | TAGKEYS( XK_8, 7)
95 | TAGKEYS( XK_9, 8)
96 | { MODKEY|ShiftMask, XK_q, quit, {0} },
97 | };
98 |
99 | /* button definitions */
100 | /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
101 | static Button buttons[] = {
102 | /* click event mask button function argument */
103 | { ClkLtSymbol, 0, Button1, setlayout, {0} },
104 | { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
105 | { ClkWinTitle, 0, Button2, zoom, {0} },
106 | { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
107 | { ClkClientWin, MODKEY, Button1, movemouse, {0} },
108 | { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
109 | { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
110 | { ClkTagBar, 0, Button1, view, {0} },
111 | { ClkTagBar, 0, Button3, toggleview, {0} },
112 | { ClkTagBar, MODKEY, Button1, tag, {0} },
113 | { ClkTagBar, MODKEY, Button3, toggletag, {0} },
114 | };
115 |
116 |
--------------------------------------------------------------------------------
/dwm/config.h:
--------------------------------------------------------------------------------
1 | /* See LICENSE file for copyright and license details. */
2 |
3 | /* appearance */
4 | static const unsigned int borderpx = 1; /* border pixel of windows */
5 | static const unsigned int snap = 32; /* snap pixel */
6 | static const int showbar = 1; /* 0 means no bar */
7 | static const int topbar = 1; /* 0 means bottom bar */
8 | static const char *fonts[] = { "hack:size=10" };
9 | static const char dmenufont[] = "hack:size=10";
10 | static const char col_gray1[] = "#222222";
11 | static const char col_gray2[] = "#444444";
12 | static const char col_gray3[] = "#bbbbbb";
13 | static const char col_gray4[] = "#eeeeee";
14 | static const char col_cyan[] = "#005577";
15 | static const char *colors[][3] = {
16 | /* fg bg border */
17 | [SchemeNorm] = { col_gray3, col_gray1, col_gray2 },
18 | [SchemeSel] = { col_gray4, col_cyan, col_cyan },
19 | };
20 |
21 | /* tagging */
22 | static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
23 |
24 | static const Rule rules[] = {
25 | /* xprop(1):
26 | * WM_CLASS(STRING) = instance, class
27 | * WM_NAME(STRING) = title
28 | */
29 | /* class instance title tags mask isfloating monitor */
30 | { "Gimp", NULL, NULL, 0, 1, -1 },
31 | { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
32 | };
33 |
34 | /* layout(s) */
35 | static const float mfact = 0.55; /* factor of master area size [0.05..0.95] */
36 | static const int nmaster = 1; /* number of clients in master area */
37 | static const int resizehints = 1; /* 1 means respect size hints in tiled resizals */
38 |
39 | static const Layout layouts[] = {
40 | /* symbol arrange function */
41 | { "[]=", tile }, /* first entry is default */
42 | { "><>", NULL }, /* no layout function means floating behavior */
43 | { "[M]", monocle },
44 | };
45 |
46 | /* key definitions */
47 | #define MODKEY Mod4Mask
48 | #define TAGKEYS(KEY,TAG) \
49 | { MODKEY, KEY, view, {.ui = 1 << TAG} }, \
50 | { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
51 | { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
52 | { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
53 |
54 | /* helper for spawning shell commands in the pre dwm-5.0 fashion */
55 | #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
56 |
57 | /* commands */
58 | static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
59 | static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
60 | static const char *termcmd[] = { "st", NULL };
61 |
62 | static Key keys[] = {
63 | /* modifier key function argument */
64 | { MODKEY, XK_p, spawn, {.v = dmenucmd } },
65 | { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } },
66 | { MODKEY, XK_b, togglebar, {0} },
67 | { MODKEY, XK_j, focusstack, {.i = +1 } },
68 | { MODKEY, XK_k, focusstack, {.i = -1 } },
69 | { MODKEY, XK_i, incnmaster, {.i = +1 } },
70 | { MODKEY, XK_d, incnmaster, {.i = -1 } },
71 | { MODKEY, XK_h, setmfact, {.f = -0.05} },
72 | { MODKEY, XK_l, setmfact, {.f = +0.05} },
73 | { MODKEY, XK_Return, zoom, {0} },
74 | { MODKEY, XK_Tab, view, {0} },
75 | { MODKEY|ShiftMask, XK_c, killclient, {0} },
76 | { MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
77 | { MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
78 | { MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
79 | { MODKEY, XK_space, setlayout, {0} },
80 | { MODKEY|ShiftMask, XK_space, togglefloating, {0} },
81 | { MODKEY, XK_0, view, {.ui = ~0 } },
82 | { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
83 | { MODKEY, XK_comma, focusmon, {.i = -1 } },
84 | { MODKEY, XK_period, focusmon, {.i = +1 } },
85 | { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
86 | { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
87 | TAGKEYS( XK_1, 0)
88 | TAGKEYS( XK_2, 1)
89 | TAGKEYS( XK_3, 2)
90 | TAGKEYS( XK_4, 3)
91 | TAGKEYS( XK_5, 4)
92 | TAGKEYS( XK_6, 5)
93 | TAGKEYS( XK_7, 6)
94 | TAGKEYS( XK_8, 7)
95 | TAGKEYS( XK_9, 8)
96 | { MODKEY|ShiftMask, XK_q, quit, {0} },
97 | };
98 |
99 | /* button definitions */
100 | /* click can be ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle, ClkClientWin, or ClkRootWin */
101 | static Button buttons[] = {
102 | /* click event mask button function argument */
103 | { ClkLtSymbol, 0, Button1, setlayout, {0} },
104 | { ClkLtSymbol, 0, Button3, setlayout, {.v = &layouts[2]} },
105 | { ClkWinTitle, 0, Button2, zoom, {0} },
106 | { ClkStatusText, 0, Button2, spawn, {.v = termcmd } },
107 | { ClkClientWin, MODKEY, Button1, movemouse, {0} },
108 | { ClkClientWin, MODKEY, Button2, togglefloating, {0} },
109 | { ClkClientWin, MODKEY, Button3, resizemouse, {0} },
110 | { ClkTagBar, 0, Button1, view, {0} },
111 | { ClkTagBar, 0, Button3, toggleview, {0} },
112 | { ClkTagBar, MODKEY, Button1, tag, {0} },
113 | { ClkTagBar, MODKEY, Button3, toggletag, {0} },
114 | };
115 |
116 |
--------------------------------------------------------------------------------
/dwm/config.mk:
--------------------------------------------------------------------------------
1 | # dwm version
2 | VERSION = 6.2
3 |
4 | # Customize below to fit your system
5 |
6 | # paths
7 | PREFIX = /usr/local
8 | MANPREFIX = ${PREFIX}/share/man
9 |
10 | X11INC = /usr/X11R6/include
11 | X11LIB = /usr/X11R6/lib
12 |
13 | # Xinerama, comment if you don't want it
14 | XINERAMALIBS = -lXinerama
15 | XINERAMAFLAGS = -DXINERAMA
16 |
17 | # freetype
18 | FREETYPELIBS = -lfontconfig -lXft
19 | FREETYPEINC = /usr/include/freetype2
20 | # OpenBSD (uncomment)
21 | #FREETYPEINC = ${X11INC}/freetype2
22 |
23 | # includes and libs
24 | INCS = -I${X11INC} -I${FREETYPEINC}
25 | LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS}
26 |
27 | # flags
28 | CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
29 | #CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
30 | CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os ${INCS} ${CPPFLAGS}
31 | LDFLAGS = ${LIBS}
32 |
33 | # Solaris
34 | #CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
35 | #LDFLAGS = ${LIBS}
36 |
37 | # compiler and linker
38 | CC = cc
39 |
--------------------------------------------------------------------------------
/dwm/drw.c:
--------------------------------------------------------------------------------
1 | /* See LICENSE file for copyright and license details. */
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "drw.h"
9 | #include "util.h"
10 |
11 | #define UTF_INVALID 0xFFFD
12 | #define UTF_SIZ 4
13 |
14 | static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
15 | static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
16 | static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
17 | static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
18 |
19 | static long
20 | utf8decodebyte(const char c, size_t *i)
21 | {
22 | for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
23 | if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
24 | return (unsigned char)c & ~utfmask[*i];
25 | return 0;
26 | }
27 |
28 | static size_t
29 | utf8validate(long *u, size_t i)
30 | {
31 | if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
32 | *u = UTF_INVALID;
33 | for (i = 1; *u > utfmax[i]; ++i)
34 | ;
35 | return i;
36 | }
37 |
38 | static size_t
39 | utf8decode(const char *c, long *u, size_t clen)
40 | {
41 | size_t i, j, len, type;
42 | long udecoded;
43 |
44 | *u = UTF_INVALID;
45 | if (!clen)
46 | return 0;
47 | udecoded = utf8decodebyte(c[0], &len);
48 | if (!BETWEEN(len, 1, UTF_SIZ))
49 | return 1;
50 | for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
51 | udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
52 | if (type)
53 | return j;
54 | }
55 | if (j < len)
56 | return 0;
57 | *u = udecoded;
58 | utf8validate(u, len);
59 |
60 | return len;
61 | }
62 |
63 | Drw *
64 | drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
65 | {
66 | Drw *drw = ecalloc(1, sizeof(Drw));
67 |
68 | drw->dpy = dpy;
69 | drw->screen = screen;
70 | drw->root = root;
71 | drw->w = w;
72 | drw->h = h;
73 | drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
74 | drw->gc = XCreateGC(dpy, root, 0, NULL);
75 | XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
76 |
77 | return drw;
78 | }
79 |
80 | void
81 | drw_resize(Drw *drw, unsigned int w, unsigned int h)
82 | {
83 | if (!drw)
84 | return;
85 |
86 | drw->w = w;
87 | drw->h = h;
88 | if (drw->drawable)
89 | XFreePixmap(drw->dpy, drw->drawable);
90 | drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
91 | }
92 |
93 | void
94 | drw_free(Drw *drw)
95 | {
96 | XFreePixmap(drw->dpy, drw->drawable);
97 | XFreeGC(drw->dpy, drw->gc);
98 | drw_fontset_free(drw->fonts);
99 | free(drw);
100 | }
101 |
102 | /* This function is an implementation detail. Library users should use
103 | * drw_fontset_create instead.
104 | */
105 | static Fnt *
106 | xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
107 | {
108 | Fnt *font;
109 | XftFont *xfont = NULL;
110 | FcPattern *pattern = NULL;
111 |
112 | if (fontname) {
113 | /* Using the pattern found at font->xfont->pattern does not yield the
114 | * same substitution results as using the pattern returned by
115 | * FcNameParse; using the latter results in the desired fallback
116 | * behaviour whereas the former just results in missing-character
117 | * rectangles being drawn, at least with some fonts. */
118 | if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
119 | fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
120 | return NULL;
121 | }
122 | if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
123 | fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
124 | XftFontClose(drw->dpy, xfont);
125 | return NULL;
126 | }
127 | } else if (fontpattern) {
128 | if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
129 | fprintf(stderr, "error, cannot load font from pattern.\n");
130 | return NULL;
131 | }
132 | } else {
133 | die("no font specified.");
134 | }
135 |
136 | /* Do not allow using color fonts. This is a workaround for a BadLength
137 | * error from Xft with color glyphs. Modelled on the Xterm workaround. See
138 | * https://bugzilla.redhat.com/show_bug.cgi?id=1498269
139 | * https://lists.suckless.org/dev/1701/30932.html
140 | * https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916349
141 | * and lots more all over the internet.
142 | */
143 | FcBool iscol;
144 | if(FcPatternGetBool(xfont->pattern, FC_COLOR, 0, &iscol) == FcResultMatch && iscol) {
145 | XftFontClose(drw->dpy, xfont);
146 | return NULL;
147 | }
148 |
149 | font = ecalloc(1, sizeof(Fnt));
150 | font->xfont = xfont;
151 | font->pattern = pattern;
152 | font->h = xfont->ascent + xfont->descent;
153 | font->dpy = drw->dpy;
154 |
155 | return font;
156 | }
157 |
158 | static void
159 | xfont_free(Fnt *font)
160 | {
161 | if (!font)
162 | return;
163 | if (font->pattern)
164 | FcPatternDestroy(font->pattern);
165 | XftFontClose(font->dpy, font->xfont);
166 | free(font);
167 | }
168 |
169 | Fnt*
170 | drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
171 | {
172 | Fnt *cur, *ret = NULL;
173 | size_t i;
174 |
175 | if (!drw || !fonts)
176 | return NULL;
177 |
178 | for (i = 1; i <= fontcount; i++) {
179 | if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
180 | cur->next = ret;
181 | ret = cur;
182 | }
183 | }
184 | return (drw->fonts = ret);
185 | }
186 |
187 | void
188 | drw_fontset_free(Fnt *font)
189 | {
190 | if (font) {
191 | drw_fontset_free(font->next);
192 | xfont_free(font);
193 | }
194 | }
195 |
196 | void
197 | drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
198 | {
199 | if (!drw || !dest || !clrname)
200 | return;
201 |
202 | if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
203 | DefaultColormap(drw->dpy, drw->screen),
204 | clrname, dest))
205 | die("error, cannot allocate color '%s'", clrname);
206 | }
207 |
208 | /* Wrapper to create color schemes. The caller has to call free(3) on the
209 | * returned color scheme when done using it. */
210 | Clr *
211 | drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
212 | {
213 | size_t i;
214 | Clr *ret;
215 |
216 | /* need at least two colors for a scheme */
217 | if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
218 | return NULL;
219 |
220 | for (i = 0; i < clrcount; i++)
221 | drw_clr_create(drw, &ret[i], clrnames[i]);
222 | return ret;
223 | }
224 |
225 | void
226 | drw_setfontset(Drw *drw, Fnt *set)
227 | {
228 | if (drw)
229 | drw->fonts = set;
230 | }
231 |
232 | void
233 | drw_setscheme(Drw *drw, Clr *scm)
234 | {
235 | if (drw)
236 | drw->scheme = scm;
237 | }
238 |
239 | void
240 | drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
241 | {
242 | if (!drw || !drw->scheme)
243 | return;
244 | XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
245 | if (filled)
246 | XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
247 | else
248 | XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
249 | }
250 |
251 | int
252 | drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
253 | {
254 | char buf[1024];
255 | int ty;
256 | unsigned int ew;
257 | XftDraw *d = NULL;
258 | Fnt *usedfont, *curfont, *nextfont;
259 | size_t i, len;
260 | int utf8strlen, utf8charlen, render = x || y || w || h;
261 | long utf8codepoint = 0;
262 | const char *utf8str;
263 | FcCharSet *fccharset;
264 | FcPattern *fcpattern;
265 | FcPattern *match;
266 | XftResult result;
267 | int charexists = 0;
268 |
269 | if (!drw || (render && !drw->scheme) || !text || !drw->fonts)
270 | return 0;
271 |
272 | if (!render) {
273 | w = ~w;
274 | } else {
275 | XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
276 | XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
277 | d = XftDrawCreate(drw->dpy, drw->drawable,
278 | DefaultVisual(drw->dpy, drw->screen),
279 | DefaultColormap(drw->dpy, drw->screen));
280 | x += lpad;
281 | w -= lpad;
282 | }
283 |
284 | usedfont = drw->fonts;
285 | while (1) {
286 | utf8strlen = 0;
287 | utf8str = text;
288 | nextfont = NULL;
289 | while (*text) {
290 | utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
291 | for (curfont = drw->fonts; curfont; curfont = curfont->next) {
292 | charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
293 | if (charexists) {
294 | if (curfont == usedfont) {
295 | utf8strlen += utf8charlen;
296 | text += utf8charlen;
297 | } else {
298 | nextfont = curfont;
299 | }
300 | break;
301 | }
302 | }
303 |
304 | if (!charexists || nextfont)
305 | break;
306 | else
307 | charexists = 0;
308 | }
309 |
310 | if (utf8strlen) {
311 | drw_font_getexts(usedfont, utf8str, utf8strlen, &ew, NULL);
312 | /* shorten text if necessary */
313 | for (len = MIN(utf8strlen, sizeof(buf) - 1); len && ew > w; len--)
314 | drw_font_getexts(usedfont, utf8str, len, &ew, NULL);
315 |
316 | if (len) {
317 | memcpy(buf, utf8str, len);
318 | buf[len] = '\0';
319 | if (len < utf8strlen)
320 | for (i = len; i && i > len - 3; buf[--i] = '.')
321 | ; /* NOP */
322 |
323 | if (render) {
324 | ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
325 | XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
326 | usedfont->xfont, x, ty, (XftChar8 *)buf, len);
327 | }
328 | x += ew;
329 | w -= ew;
330 | }
331 | }
332 |
333 | if (!*text) {
334 | break;
335 | } else if (nextfont) {
336 | charexists = 0;
337 | usedfont = nextfont;
338 | } else {
339 | /* Regardless of whether or not a fallback font is found, the
340 | * character must be drawn. */
341 | charexists = 1;
342 |
343 | fccharset = FcCharSetCreate();
344 | FcCharSetAddChar(fccharset, utf8codepoint);
345 |
346 | if (!drw->fonts->pattern) {
347 | /* Refer to the comment in xfont_create for more information. */
348 | die("the first font in the cache must be loaded from a font string.");
349 | }
350 |
351 | fcpattern = FcPatternDuplicate(drw->fonts->pattern);
352 | FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
353 | FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
354 | FcPatternAddBool(fcpattern, FC_COLOR, FcFalse);
355 |
356 | FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
357 | FcDefaultSubstitute(fcpattern);
358 | match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
359 |
360 | FcCharSetDestroy(fccharset);
361 | FcPatternDestroy(fcpattern);
362 |
363 | if (match) {
364 | usedfont = xfont_create(drw, NULL, match);
365 | if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
366 | for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
367 | ; /* NOP */
368 | curfont->next = usedfont;
369 | } else {
370 | xfont_free(usedfont);
371 | usedfont = drw->fonts;
372 | }
373 | }
374 | }
375 | }
376 | if (d)
377 | XftDrawDestroy(d);
378 |
379 | return x + (render ? w : 0);
380 | }
381 |
382 | void
383 | drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
384 | {
385 | if (!drw)
386 | return;
387 |
388 | XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
389 | XSync(drw->dpy, False);
390 | }
391 |
392 | unsigned int
393 | drw_fontset_getwidth(Drw *drw, const char *text)
394 | {
395 | if (!drw || !drw->fonts || !text)
396 | return 0;
397 | return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
398 | }
399 |
400 | void
401 | drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
402 | {
403 | XGlyphInfo ext;
404 |
405 | if (!font || !text)
406 | return;
407 |
408 | XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
409 | if (w)
410 | *w = ext.xOff;
411 | if (h)
412 | *h = font->h;
413 | }
414 |
415 | Cur *
416 | drw_cur_create(Drw *drw, int shape)
417 | {
418 | Cur *cur;
419 |
420 | if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
421 | return NULL;
422 |
423 | cur->cursor = XCreateFontCursor(drw->dpy, shape);
424 |
425 | return cur;
426 | }
427 |
428 | void
429 | drw_cur_free(Drw *drw, Cur *cursor)
430 | {
431 | if (!cursor)
432 | return;
433 |
434 | XFreeCursor(drw->dpy, cursor->cursor);
435 | free(cursor);
436 | }
437 |
--------------------------------------------------------------------------------
/dwm/drw.h:
--------------------------------------------------------------------------------
1 | /* See LICENSE file for copyright and license details. */
2 |
3 | typedef struct {
4 | Cursor cursor;
5 | } Cur;
6 |
7 | typedef struct Fnt {
8 | Display *dpy;
9 | unsigned int h;
10 | XftFont *xfont;
11 | FcPattern *pattern;
12 | struct Fnt *next;
13 | } Fnt;
14 |
15 | enum { ColFg, ColBg, ColBorder }; /* Clr scheme index */
16 | typedef XftColor Clr;
17 |
18 | typedef struct {
19 | unsigned int w, h;
20 | Display *dpy;
21 | int screen;
22 | Window root;
23 | Drawable drawable;
24 | GC gc;
25 | Clr *scheme;
26 | Fnt *fonts;
27 | } Drw;
28 |
29 | /* Drawable abstraction */
30 | Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
31 | void drw_resize(Drw *drw, unsigned int w, unsigned int h);
32 | void drw_free(Drw *drw);
33 |
34 | /* Fnt abstraction */
35 | Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
36 | void drw_fontset_free(Fnt* set);
37 | unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
38 | void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
39 |
40 | /* Colorscheme abstraction */
41 | void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
42 | Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
43 |
44 | /* Cursor abstraction */
45 | Cur *drw_cur_create(Drw *drw, int shape);
46 | void drw_cur_free(Drw *drw, Cur *cursor);
47 |
48 | /* Drawing context manipulation */
49 | void drw_setfontset(Drw *drw, Fnt *set);
50 | void drw_setscheme(Drw *drw, Clr *scm);
51 |
52 | /* Drawing functions */
53 | void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
54 | int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
55 |
56 | /* Map functions */
57 | void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
58 |
--------------------------------------------------------------------------------
/dwm/dwm.1:
--------------------------------------------------------------------------------
1 | .TH DWM 1 dwm\-VERSION
2 | .SH NAME
3 | dwm \- dynamic window manager
4 | .SH SYNOPSIS
5 | .B dwm
6 | .RB [ \-v ]
7 | .SH DESCRIPTION
8 | dwm is a dynamic window manager for X. It manages windows in tiled, monocle
9 | and floating layouts. Either layout can be applied dynamically, optimising the
10 | environment for the application in use and the task performed.
11 | .P
12 | In tiled layouts windows are managed in a master and stacking area. The master
13 | area on the left contains one window by default, and the stacking area on the
14 | right contains all other windows. The number of master area windows can be
15 | adjusted from zero to an arbitrary number. In monocle layout all windows are
16 | maximised to the screen size. In floating layout windows can be resized and
17 | moved freely. Dialog windows are always managed floating, regardless of the
18 | layout applied.
19 | .P
20 | Windows are grouped by tags. Each window can be tagged with one or multiple
21 | tags. Selecting certain tags displays all windows with these tags.
22 | .P
23 | Each screen contains a small status bar which displays all available tags, the
24 | layout, the title of the focused window, and the text read from the root window
25 | name property, if the screen is focused. A floating window is indicated with an
26 | empty square and a maximised floating window is indicated with a filled square
27 | before the windows title. The selected tags are indicated with a different
28 | color. The tags of the focused window are indicated with a filled square in the
29 | top left corner. The tags which are applied to one or more windows are
30 | indicated with an empty square in the top left corner.
31 | .P
32 | dwm draws a small border around windows to indicate the focus state.
33 | .SH OPTIONS
34 | .TP
35 | .B \-v
36 | prints version information to stderr, then exits.
37 | .SH USAGE
38 | .SS Status bar
39 | .TP
40 | .B X root window name
41 | is read and displayed in the status text area. It can be set with the
42 | .BR xsetroot (1)
43 | command.
44 | .TP
45 | .B Button1
46 | click on a tag label to display all windows with that tag, click on the layout
47 | label toggles between tiled and floating layout.
48 | .TP
49 | .B Button3
50 | click on a tag label adds/removes all windows with that tag to/from the view.
51 | .TP
52 | .B Mod1\-Button1
53 | click on a tag label applies that tag to the focused window.
54 | .TP
55 | .B Mod1\-Button3
56 | click on a tag label adds/removes that tag to/from the focused window.
57 | .SS Keyboard commands
58 | .TP
59 | .B Mod1\-Shift\-Return
60 | Start
61 | .BR st(1).
62 | .TP
63 | .B Mod1\-p
64 | Spawn
65 | .BR dmenu(1)
66 | for launching other programs.
67 | .TP
68 | .B Mod1\-,
69 | Focus previous screen, if any.
70 | .TP
71 | .B Mod1\-.
72 | Focus next screen, if any.
73 | .TP
74 | .B Mod1\-Shift\-,
75 | Send focused window to previous screen, if any.
76 | .TP
77 | .B Mod1\-Shift\-.
78 | Send focused window to next screen, if any.
79 | .TP
80 | .B Mod1\-b
81 | Toggles bar on and off.
82 | .TP
83 | .B Mod1\-t
84 | Sets tiled layout.
85 | .TP
86 | .B Mod1\-f
87 | Sets floating layout.
88 | .TP
89 | .B Mod1\-m
90 | Sets monocle layout.
91 | .TP
92 | .B Mod1\-space
93 | Toggles between current and previous layout.
94 | .TP
95 | .B Mod1\-j
96 | Focus next window.
97 | .TP
98 | .B Mod1\-k
99 | Focus previous window.
100 | .TP
101 | .B Mod1\-i
102 | Increase number of windows in master area.
103 | .TP
104 | .B Mod1\-d
105 | Decrease number of windows in master area.
106 | .TP
107 | .B Mod1\-l
108 | Increase master area size.
109 | .TP
110 | .B Mod1\-h
111 | Decrease master area size.
112 | .TP
113 | .B Mod1\-Return
114 | Zooms/cycles focused window to/from master area (tiled layouts only).
115 | .TP
116 | .B Mod1\-Shift\-c
117 | Close focused window.
118 | .TP
119 | .B Mod1\-Shift\-space
120 | Toggle focused window between tiled and floating state.
121 | .TP
122 | .B Mod1\-Tab
123 | Toggles to the previously selected tags.
124 | .TP
125 | .B Mod1\-Shift\-[1..n]
126 | Apply nth tag to focused window.
127 | .TP
128 | .B Mod1\-Shift\-0
129 | Apply all tags to focused window.
130 | .TP
131 | .B Mod1\-Control\-Shift\-[1..n]
132 | Add/remove nth tag to/from focused window.
133 | .TP
134 | .B Mod1\-[1..n]
135 | View all windows with nth tag.
136 | .TP
137 | .B Mod1\-0
138 | View all windows with any tag.
139 | .TP
140 | .B Mod1\-Control\-[1..n]
141 | Add/remove all windows with nth tag to/from the view.
142 | .TP
143 | .B Mod1\-Shift\-q
144 | Quit dwm.
145 | .SS Mouse commands
146 | .TP
147 | .B Mod1\-Button1
148 | Move focused window while dragging. Tiled windows will be toggled to the floating state.
149 | .TP
150 | .B Mod1\-Button2
151 | Toggles focused window between floating and tiled state.
152 | .TP
153 | .B Mod1\-Button3
154 | Resize focused window while dragging. Tiled windows will be toggled to the floating state.
155 | .SH CUSTOMIZATION
156 | dwm is customized by creating a custom config.h and (re)compiling the source
157 | code. This keeps it fast, secure and simple.
158 | .SH SEE ALSO
159 | .BR dmenu (1),
160 | .BR st (1)
161 | .SH ISSUES
162 | Java applications which use the XToolkit/XAWT backend may draw grey windows
163 | only. The XToolkit/XAWT backend breaks ICCCM-compliance in recent JDK 1.5 and early
164 | JDK 1.6 versions, because it assumes a reparenting window manager. Possible workarounds
165 | are using JDK 1.4 (which doesn't contain the XToolkit/XAWT backend) or setting the
166 | environment variable
167 | .BR AWT_TOOLKIT=MToolkit
168 | (to use the older Motif backend instead) or running
169 | .B xprop -root -f _NET_WM_NAME 32a -set _NET_WM_NAME LG3D
170 | or
171 | .B wmname LG3D
172 | (to pretend that a non-reparenting window manager is running that the
173 | XToolkit/XAWT backend can recognize) or when using OpenJDK setting the environment variable
174 | .BR _JAVA_AWT_WM_NONREPARENTING=1 .
175 | .SH BUGS
176 | Send all bug reports with a patch to hackers@suckless.org.
177 |
--------------------------------------------------------------------------------
/dwm/dwm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joshrosso/linux-desktop/3d7d3f93cb0e51c6e31ba0716e098afbce935665/dwm/dwm.png
--------------------------------------------------------------------------------
/dwm/transient.c:
--------------------------------------------------------------------------------
1 | /* cc transient.c -o transient -lX11 */
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | int main(void) {
9 | Display *d;
10 | Window r, f, t = None;
11 | XSizeHints h;
12 | XEvent e;
13 |
14 | d = XOpenDisplay(NULL);
15 | if (!d)
16 | exit(1);
17 | r = DefaultRootWindow(d);
18 |
19 | f = XCreateSimpleWindow(d, r, 100, 100, 400, 400, 0, 0, 0);
20 | h.min_width = h.max_width = h.min_height = h.max_height = 400;
21 | h.flags = PMinSize | PMaxSize;
22 | XSetWMNormalHints(d, f, &h);
23 | XStoreName(d, f, "floating");
24 | XMapWindow(d, f);
25 |
26 | XSelectInput(d, f, ExposureMask);
27 | while (1) {
28 | XNextEvent(d, &e);
29 |
30 | if (t == None) {
31 | sleep(5);
32 | t = XCreateSimpleWindow(d, r, 50, 50, 100, 100, 0, 0, 0);
33 | XSetTransientForHint(d, t, f);
34 | XStoreName(d, t, "transient");
35 | XMapWindow(d, t);
36 | XSelectInput(d, t, ExposureMask);
37 | }
38 | }
39 |
40 | XCloseDisplay(d);
41 | exit(0);
42 | }
43 |
--------------------------------------------------------------------------------
/dwm/util.c:
--------------------------------------------------------------------------------
1 | /* See LICENSE file for copyright and license details. */
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | #include "util.h"
8 |
9 | void *
10 | ecalloc(size_t nmemb, size_t size)
11 | {
12 | void *p;
13 |
14 | if (!(p = calloc(nmemb, size)))
15 | die("calloc:");
16 | return p;
17 | }
18 |
19 | void
20 | die(const char *fmt, ...) {
21 | va_list ap;
22 |
23 | va_start(ap, fmt);
24 | vfprintf(stderr, fmt, ap);
25 | va_end(ap);
26 |
27 | if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
28 | fputc(' ', stderr);
29 | perror(NULL);
30 | } else {
31 | fputc('\n', stderr);
32 | }
33 |
34 | exit(1);
35 | }
36 |
--------------------------------------------------------------------------------
/dwm/util.h:
--------------------------------------------------------------------------------
1 | /* See LICENSE file for copyright and license details. */
2 |
3 | #define MAX(A, B) ((A) > (B) ? (A) : (B))
4 | #define MIN(A, B) ((A) < (B) ? (A) : (B))
5 | #define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
6 |
7 | void die(const char *fmt, ...);
8 | void *ecalloc(size_t nmemb, size_t size);
9 |
--------------------------------------------------------------------------------
/pkg/configure-system.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$EUID" -ne 0 ]
4 | then echo "must run as root"
5 | exit
6 | fi
7 |
8 | # running commands to configure the system
9 | printf "[main]\ndhcp=dhclient" > /etc/NetworkManager/conf.d/dhcp-client.conf
10 | printf "[Policy]\nAutoEnable=true" > /etc/bluetooth/main.conf
11 | echo "ControllerMode = bredr" >> /etc/bluetooth/main.conf
12 | echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf
13 | systemctl enable NetworkManager
14 | systemctl enable bluetooth
15 | timedatectl set-ntp true
16 |
17 | # disable annoying beep
18 | echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist
19 | mkinitcpio -p linux
20 |
21 | localectl set-locale LANG=en_US.UTF-8
22 |
23 | cp -r ../scripts/usr/local/bin/bye /usr/local/bin/
24 | cp -r ../scripts/usr/local/bin/importc /usr/local/bin/
25 |
26 | # make vconsole font larger
27 | VCONSOLE_FONT=FONT=ter-v32n.psf.gz
28 | touch /etc/vconsole.conf
29 | grep -qxF ${VCONSOLE_FONT} /etc/vconsole.conf || sudo echo ${VCONSOLE_FONT} >> /etc/vconsole.conf
30 |
31 | # set grub font size
32 | grub-mkfont -s 60 -o /boot/grubfont.pf2 /usr/share/fonts/TTF/Hack-Regular.ttf
33 | GRUB_FONT=GRUB_FONT=\"/boot/grubfont.pf2\"
34 | grep -qxF ${GRUB_FONT} /etc/default/grub || echo ${GRUB_FONT} >> /etc/default/grub
35 |
36 | # update grub config
37 | grub-mkconfig -o /boot/grub/grub.cfg
38 |
--------------------------------------------------------------------------------
/pkg/configure-user.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$EUID" -eq 0 ]
4 | then echo "do not run as root"
5 | exit
6 | fi
7 |
8 | echo "installing vim-plug"
9 | echo
10 | if [ ! -e ${HOME}/.vim/autoload/plug.vim ]; then
11 | curl -fLo ${HOME}/.vim/autoload/plug.vim --create-dirs \
12 | https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
13 | fi
14 |
15 | mkdir -p \
16 | ${HOME}/s \
17 | ${HOME}/.ssh \
18 | ${HOME}/.config/picom \
19 | ${HOME}/.config/xfce4/xfconf/xfce-perchannel-xml
20 |
21 | cp -fvr \
22 | ../dotfiles/.bash_aliases \
23 | ../dotfiles/.bash_profile \
24 | ../dotfiles/.bashrc \
25 | ../dotfiles/.gitconfig \
26 | ../dotfiles/.tmux.conf \
27 | ../dotfiles/.xinitrc \
28 | ../dotfiles/.Xresources \
29 | ../dotfiles/.xbindkeysrc \
30 | ${HOME}/
31 |
32 | cp -vr ../dotfiles/.ssh/config ${HOME}/.ssh/
33 | cp -vr ../dotfiles/.config/picom/picom.conf ${HOME}/.config/picom/
34 | cp -vr ../dotfiles/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml ${HOME}/.config/xfce4/xfconf/xfce-perchannel-xml/
35 | cp -vr ../s/* ${HOME}/s/
36 |
37 | # update xfce settings
38 | killall xfconfd
39 | /usr/lib/xfce4/xfconf/xfconfd &
40 | xfsettingsd --replace &
41 |
--------------------------------------------------------------------------------
/pkg/install-aur-packages.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo
4 | echo "installing aur packages"
5 | echo
6 | TEMP_DIR=$(mktemp -d)
7 | CURRENT_DIR=$(pwd)
8 |
9 | # Load extra keys
10 | # dropbox
11 | gpg --recv-keys 1C61A2656FB57B7E4DE0F4C1FC918B335044912E
12 | # spotify
13 | gpg --recv-keys 4773BD5E130D1D45
14 |
15 | while read AUR_PKG
16 | do
17 | if ! pacman -Q ${AUR_PKG} > /dev/null; then
18 | cd $TEMP_DIR
19 | git clone https://aur.archlinux.org/${AUR_PKG}.git
20 | cd ${AUR_PKG} && makepkg -si --noconfirm && cd $TEMP_DIR
21 | fi
22 | done < packages-aur.txt
23 |
--------------------------------------------------------------------------------
/pkg/install-official-packages.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$EUID" -ne 0 ]
4 | then echo "must run as root"
5 | exit
6 | fi
7 |
8 | echo "=====> downloading official packages"
9 | echo
10 | # requires sudo
11 | # --noconfirm is used to select all packages from groups
12 | pacman -Sy --needed $(
4 | © 2018 Devin J. Pohly
5 | © 2014-2017 Quentin Rameau
6 | © 2009-2012 Aurélien APTEL
7 | © 2008-2017 Anselm R Garbe
8 | © 2012-2017 Roberto E. Vargas Caballero
9 | © 2012-2016 Christoph Lohmann <20h at r-36 dot net>
10 | © 2013 Eon S. Jeon
11 | © 2013 Alexander Sedov
12 | © 2013 Mark Edgar
13 | © 2013-2014 Eric Pruitt
14 | © 2013 Michael Forney
15 | © 2013-2014 Markus Teich
16 | © 2014-2015 Laslo Hunhold
17 |
18 | Permission is hereby granted, free of charge, to any person obtaining a
19 | copy of this software and associated documentation files (the "Software"),
20 | to deal in the Software without restriction, including without limitation
21 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
22 | and/or sell copies of the Software, and to permit persons to whom the
23 | Software is furnished to do so, subject to the following conditions:
24 |
25 | The above copyright notice and this permission notice shall be included in
26 | all copies or substantial portions of the Software.
27 |
28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
31 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
33 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
34 | DEALINGS IN THE SOFTWARE.
35 |
--------------------------------------------------------------------------------
/st/Makefile:
--------------------------------------------------------------------------------
1 | # st - simple terminal
2 | # See LICENSE file for copyright and license details.
3 | .POSIX:
4 |
5 | include config.mk
6 |
7 | SRC = st.c x.c boxdraw.c hb.c
8 | OBJ = $(SRC:.c=.o)
9 |
10 | all: options st
11 |
12 | options:
13 | @echo st build options:
14 | @echo "CFLAGS = $(STCFLAGS)"
15 | @echo "LDFLAGS = $(STLDFLAGS)"
16 | @echo "CC = $(CC)"
17 |
18 | .c.o:
19 | $(CC) $(STCFLAGS) -c $<
20 |
21 | st.o: config.h st.h win.h
22 | x.o: arg.h config.h st.h win.h hb.h
23 | hb.o: st.h
24 | boxdraw.o: config.h st.h boxdraw_data.h
25 |
26 | $(OBJ): config.h config.mk
27 |
28 | st: $(OBJ)
29 | $(CC) -o $@ $(OBJ) $(STLDFLAGS)
30 |
31 | clean:
32 | rm -f st $(OBJ) st-$(VERSION).tar.gz *.rej *.orig *.o
33 |
34 | dist: clean
35 | mkdir -p st-$(VERSION)
36 | cp -R FAQ LEGACY TODO LICENSE Makefile README config.mk\
37 | config.h st.info st.1 arg.h st.h win.h $(SRC)\
38 | st-$(VERSION)
39 | tar -cf - st-$(VERSION) | gzip > st-$(VERSION).tar.gz
40 | rm -rf st-$(VERSION)
41 |
42 | install: st
43 | git submodule init
44 | git submodule update
45 | mkdir -p $(DESTDIR)$(PREFIX)/bin
46 | cp -f st $(DESTDIR)$(PREFIX)/bin
47 | cp -f st-copyout $(DESTDIR)$(PREFIX)/bin
48 | cp -f st-urlhandler $(DESTDIR)$(PREFIX)/bin
49 | chmod 755 $(DESTDIR)$(PREFIX)/bin/st
50 | chmod 755 $(DESTDIR)$(PREFIX)/bin/st-copyout
51 | chmod 755 $(DESTDIR)$(PREFIX)/bin/st-urlhandler
52 | mkdir -p $(DESTDIR)$(MANPREFIX)/man1
53 | sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1
54 | chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1
55 | tic -sx st.info
56 | @echo Please see the README file regarding the terminfo entry of st.
57 |
58 | uninstall:
59 | rm -f $(DESTDIR)$(PREFIX)/bin/st
60 | rm -f $(DESTDIR)$(PREFIX)/bin/st-copyout
61 | rm -f $(DESTDIR)$(PREFIX)/bin/st-urlhandler
62 | rm -f $(DESTDIR)$(MANPREFIX)/man1/st.1
63 |
64 | .PHONY: all options clean dist install uninstall
65 |
--------------------------------------------------------------------------------
/st/PKGBUILD:
--------------------------------------------------------------------------------
1 | # Maintainer:
2 |
3 | pkgname=st-luke-git
4 | _pkgname=st
5 | pkgver=0.8.2.r1062.2087ab9
6 | pkgrel=1
7 | epoch=1
8 | pkgdesc="Luke's simple (suckless) terminal with vim-bindings, transparency, xresources, etc. "
9 | url='https://github.com/LukeSmithxyz/st'
10 | arch=('i686' 'x86_64')
11 | license=('MIT')
12 | options=('zipman')
13 | depends=('libxft')
14 | makedepends=('ncurses' 'libxext' 'git')
15 | optdepends=('dmenu: feed urls to dmenu')
16 | source=('git://github.com/LukeSmithxyz/st')
17 | sha1sums=('SKIP')
18 |
19 | provides=("${_pkgname}")
20 | conflicts=("${_pkgname}")
21 |
22 | pkgver() {
23 | cd "${_pkgname}"
24 | printf "%s.r%s.%s" "$(awk '/^VERSION =/ {print $3}' config.mk)" \
25 | "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
26 | }
27 |
28 | prepare() {
29 | cd $srcdir/${_pkgname}
30 | # skip terminfo which conflicts with ncurses
31 | sed -i '/tic /d' Makefile
32 | }
33 |
34 | build() {
35 | cd "${_pkgname}"
36 | make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11
37 | }
38 |
39 | package() {
40 | cd "${_pkgname}"
41 | make PREFIX=/usr DESTDIR="${pkgdir}" install
42 | install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
43 | install -Dm644 README.md "${pkgdir}/usr/share/doc/${pkgname}/README.md"
44 | install -Dm644 Xdefaults "${pkgdir}/usr/share/doc/${pkgname}/Xdefaults.example"
45 | }
46 |
--------------------------------------------------------------------------------
/st/README.md:
--------------------------------------------------------------------------------
1 | # Luke's build of st - the simple (suckless) terminal
2 |
3 | The [suckless terminal (st)](https://st.suckless.org/) with some additional
4 | features that make it literally the best terminal emulator ever:
5 |
6 | ## Unique features (using dmenu)
7 |
8 | + **follow urls** by pressing `alt-l`
9 | + **copy urls** in the same way with `alt-y`
10 | + **copy the output of commands** with `alt-o`
11 |
12 | ## Bindings for
13 |
14 | + scroll with `alt-↑/↓` or `alt-pageup/down` or `shift` while scrolling the
15 | mouse (via [scroll](https://github.com/lukesmithxyz/scroll)).
16 | + OR **vim-bindings**: scroll up/down in history with `alt-k` and `alt-j`.
17 | Faster with `alt-u`/`alt-d`.
18 | + **zoom/change font size**: same bindings as above, but holding down shift as
19 | well. `alt-home` returns to default
20 | + **copy text** with `alt-c`, **paste** is `alt-v` or `shift-insert`
21 |
22 | ## Pretty stuff
23 |
24 | + Compatibility with `Xresources` and `pywal` for dynamic colors.
25 | + Default [gruvbox](https://github.com/morhetz/gruvbox) colors otherwise.
26 | + Transparency/alpha, which is also adjustable from your `Xresources`.
27 | + Default font is system "mono" at 14pt, meaning the font will match your
28 | system font.
29 |
30 | ## Other st patches
31 |
32 | + Boxdraw
33 | + Ligatures
34 | + font2
35 | + updated to latest version 0.8.4
36 |
37 | ## Installation for newbs
38 |
39 | You should have xlib header files and libharfbuzz build files installed.
40 |
41 | ```
42 | git clone https://github.com/LukeSmithxyz/st
43 | cd st
44 | sudo make install
45 | ```
46 |
47 | Note that [scroll](https://github.com/lukesmithxyz/scroll) is automatically
48 | pulled and installed when you make this build of st.
49 |
50 | Users of Arch-based distros can also install it from the AUR as
51 | [st-luke-git](https://aur.archlinux.org/packages/st-luke-git/).
52 |
53 | Obviously, `make` is required to build. `fontconfig` is required for the
54 | default build, since it asks `fontconfig` for your system monospace font. It
55 | might be obvious, but `libX11` and `libXft` are required as well. Chances are,
56 | you have all of this installed already.
57 |
58 | On OpenBSD, be sure to edit `config.mk` first and remove `-lrt` from the
59 | `$LIBS` before compiling.
60 |
61 | Be sure to have a composite manager (`xcompmgr`, `picom`, etc.) running if you
62 | want transparency.
63 |
64 | ## How to configure dynamically with Xresources
65 |
66 | For many key variables, this build of `st` will look for X settings set in
67 | either `~/.Xdefaults` or `~/.Xresources`. You must run `xrdb` on one of these
68 | files to load the settings.
69 |
70 | For example, you can define your desired fonts, transparency or colors:
71 |
72 | ```
73 | *.font: Liberation Mono:pixelsize=12:antialias=true:autohint=true;
74 | *.alpha: 0.9
75 | *.color0: #111
76 | ...
77 | ```
78 |
79 | The `alpha` value (for transparency) goes from `0` (transparent) to `1`
80 | (opaque). There is an example `Xdefaults` file in this respository.
81 |
82 | ### Colors
83 |
84 | To be clear about the color settings:
85 |
86 | - This build will use gruvbox colors by default and as a fallback.
87 | - If there are Xresources colors defined, those will take priority.
88 | - But if `wal` has run in your session, its colors will take priority.
89 |
90 | Note that when you run `wal`, it will negate the transparency of existing windows, but new windows will continue with the previously defined transparency.
91 |
92 | ## Notes on Emojis and Special Characters
93 |
94 | If st crashes when viewing emojis, install
95 | [libxft-bgra](https://aur.archlinux.org/packages/libxft-bgra/) from the AUR.
96 |
97 | Note that some special characters may appear truncated if too wide. You might
98 | want to manually set your prefered emoji/special character font to a lower size
99 | in the `config.h` file to avoid this. By default, JoyPixels is used at a
100 | smaller size than the usual text.
101 |
102 | ## Contact
103 |
104 | - Luke Smith
105 | - [https://lukesmith.xyz](https://lukesmith.xyz)
106 |
--------------------------------------------------------------------------------
/st/Xdefaults:
--------------------------------------------------------------------------------
1 | !! Transparency (0-1):
2 | st.alpha: 0.92
3 |
4 | !! Set a default font and font size as below:
5 | st.font: Monospace-11;
6 |
7 | ! st.termname: st-256color
8 | ! st.borderpx: 2
9 |
10 | !! Set the background, foreground and cursor colors as below:
11 |
12 | !! gruvbox:
13 | *.color0: #1d2021
14 | *.color1: #cc241d
15 | *.color2: #98971a
16 | *.color3: #d79921
17 | *.color4: #458588
18 | *.color5: #b16286
19 | *.color6: #689d6a
20 | *.color7: #a89984
21 | *.color8: #928374
22 | *.color9: #fb4934
23 | *.color10: #b8bb26
24 | *.color11: #fabd2f
25 | *.color12: #83a598
26 | *.color13: #d3869b
27 | *.color14: #8ec07c
28 | *.color15: #ebdbb2
29 | *.background: #282828
30 | *.foreground: white
31 | *.cursorColor: white
32 |
33 | /* /1* !! gruvbox light: *1/ */
34 | /* *.color0: #fbf1c7 */
35 | /* *.color1: #cc241d */
36 | /* *.color2: #98971a */
37 | /* *.color3: #d79921 */
38 | /* *.color4: #458588 */
39 | /* *.color5: #b16286 */
40 | /* *.color6: #689d6a */
41 | /* *.color7: #7c6f64 */
42 | /* *.color8: #928374 */
43 | /* *.color9: #9d0006 */
44 | /* *.color10: #79740e */
45 | /* *.color11: #b57614 */
46 | /* *.color12: #076678 */
47 | /* *.color13: #8f3f71 */
48 | /* *.color14: #427b58 */
49 | /* *.color15: #3c3836 */
50 | /* *.background: #fbf1c7 */
51 | /* *.foreground: #282828 */
52 | /* *.cursorColor: #282828 */
53 |
54 | /* !! brogrammer: */
55 | /* *.foreground: #d6dbe5 */
56 | /* *.background: #131313 */
57 | /* *.color0: #1f1f1f */
58 | /* *.color8: #d6dbe5 */
59 | /* *.color1: #f81118 */
60 | /* *.color9: #de352e */
61 | /* *.color2: #2dc55e */
62 | /* *.color10: #1dd361 */
63 | /* *.color3: #ecba0f */
64 | /* *.color11: #f3bd09 */
65 | /* *.color4: #2a84d2 */
66 | /* *.color12: #1081d6 */
67 | /* *.color5: #4e5ab7 */
68 | /* *.color13: #5350b9 */
69 | /* *.color6: #1081d6 */
70 | /* *.color14: #0f7ddb */
71 | /* *.color7: #d6dbe5 */
72 | /* *.color15: #ffffff */
73 | /* *.colorBD: #d6dbe5 */
74 |
75 | /* ! base16 */
76 | /* *.color0: #181818 */
77 | /* *.color1: #ab4642 */
78 | /* *.color2: #a1b56c */
79 | /* *.color3: #f7ca88 */
80 | /* *.color4: #7cafc2 */
81 | /* *.color5: #ba8baf */
82 | /* *.color6: #86c1b9 */
83 | /* *.color7: #d8d8d8 */
84 | /* *.color8: #585858 */
85 | /* *.color9: #ab4642 */
86 | /* *.color10: #a1b56c */
87 | /* *.color11: #f7ca88 */
88 | /* *.color12: #7cafc2 */
89 | /* *.color13: #ba8baf */
90 | /* *.color14: #86c1b9 */
91 | /* *.color15: #f8f8f8 */
92 |
93 | /* !! solarized */
94 | /* *.color0: #073642 */
95 | /* *.color1: #dc322f */
96 | /* *.color2: #859900 */
97 | /* *.color3: #b58900 */
98 | /* *.color4: #268bd2 */
99 | /* *.color5: #d33682 */
100 | /* *.color6: #2aa198 */
101 | /* *.color7: #eee8d5 */
102 | /* *.color9: #cb4b16 */
103 | /* *.color8: #fdf6e3 */
104 | /* *.color10: #586e75 */
105 | /* *.color11: #657b83 */
106 | /* *.color12: #839496 */
107 | /* *.color13: #6c71c4 */
108 | /* *.color14: #93a1a1 */
109 | /* *.color15: #fdf6e3 */
110 |
111 | /* !! xterm */
112 | /* *.color0: #000000 */
113 | /* *.color1: #cd0000 */
114 | /* *.color2: #00cd00 */
115 | /* *.color3: #cdcd00 */
116 | /* *.color4: #0000cd */
117 | /* *.color5: #cd00cd */
118 | /* *.color6: #00cdcd */
119 | /* *.color7: #e5e5e5 */
120 | /* *.color8: #4d4d4d */
121 | /* *.color9: #ff0000 */
122 | /* *.color10: #00ff00 */
123 | /* *.color11: #ffff00 */
124 | /* *.color12: #0000ff */
125 | /* *.color13: #ff00ff */
126 | /* *.color14: #00ffff */
127 | /* *.color15: #aabac8 */
128 |
--------------------------------------------------------------------------------
/st/arg.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copy me if you can.
3 | * by 20h
4 | */
5 |
6 | #ifndef ARG_H__
7 | #define ARG_H__
8 |
9 | extern char *argv0;
10 |
11 | /* use main(int argc, char *argv[]) */
12 | #define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
13 | argv[0] && argv[0][0] == '-'\
14 | && argv[0][1];\
15 | argc--, argv++) {\
16 | char argc_;\
17 | char **argv_;\
18 | int brk_;\
19 | if (argv[0][1] == '-' && argv[0][2] == '\0') {\
20 | argv++;\
21 | argc--;\
22 | break;\
23 | }\
24 | int i_;\
25 | for (i_ = 1, brk_ = 0, argv_ = argv;\
26 | argv[0][i_] && !brk_;\
27 | i_++) {\
28 | if (argv_ != argv)\
29 | break;\
30 | argc_ = argv[0][i_];\
31 | switch (argc_)
32 |
33 | #define ARGEND }\
34 | }
35 |
36 | #define ARGC() argc_
37 |
38 | #define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
39 | ((x), abort(), (char *)0) :\
40 | (brk_ = 1, (argv[0][i_+1] != '\0')?\
41 | (&argv[0][i_+1]) :\
42 | (argc--, argv++, argv[0])))
43 |
44 | #define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\
45 | (char *)0 :\
46 | (brk_ = 1, (argv[0][i_+1] != '\0')?\
47 | (&argv[0][i_+1]) :\
48 | (argc--, argv++, argv[0])))
49 |
50 | #endif
51 |
--------------------------------------------------------------------------------
/st/boxdraw.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Avi Halachmi (:avih) avihpit@yahoo.com https://github.com/avih
3 | * MIT/X Consortium License
4 | */
5 |
6 | #include
7 | #include "st.h"
8 | #include "boxdraw_data.h"
9 |
10 | /* Rounded non-negative integers division of n / d */
11 | #define DIV(n, d) (((n) + (d) / 2) / (d))
12 |
13 | static Display *xdpy;
14 | static Colormap xcmap;
15 | static XftDraw *xd;
16 | static Visual *xvis;
17 |
18 | static void drawbox(int, int, int, int, XftColor *, XftColor *, ushort);
19 | static void drawboxlines(int, int, int, int, XftColor *, ushort);
20 |
21 | /* public API */
22 |
23 | void
24 | boxdraw_xinit(Display *dpy, Colormap cmap, XftDraw *draw, Visual *vis)
25 | {
26 | xdpy = dpy; xcmap = cmap; xd = draw, xvis = vis;
27 | }
28 |
29 | int
30 | isboxdraw(Rune u)
31 | {
32 | Rune block = u & ~0xff;
33 | return (boxdraw && block == 0x2500 && boxdata[(uint8_t)u]) ||
34 | (boxdraw_braille && block == 0x2800);
35 | }
36 |
37 | /* the "index" is actually the entire shape data encoded as ushort */
38 | ushort
39 | boxdrawindex(const Glyph *g)
40 | {
41 | if (boxdraw_braille && (g->u & ~0xff) == 0x2800)
42 | return BRL | (uint8_t)g->u;
43 | if (boxdraw_bold && (g->mode & ATTR_BOLD))
44 | return BDB | boxdata[(uint8_t)g->u];
45 | return boxdata[(uint8_t)g->u];
46 | }
47 |
48 | void
49 | drawboxes(int x, int y, int cw, int ch, XftColor *fg, XftColor *bg,
50 | const XftGlyphFontSpec *specs, int len)
51 | {
52 | for ( ; len-- > 0; x += cw, specs++)
53 | drawbox(x, y, cw, ch, fg, bg, (ushort)specs->glyph);
54 | }
55 |
56 | /* implementation */
57 |
58 | void
59 | drawbox(int x, int y, int w, int h, XftColor *fg, XftColor *bg, ushort bd)
60 | {
61 | ushort cat = bd & ~(BDB | 0xff); /* mask out bold and data */
62 | if (bd & (BDL | BDA)) {
63 | /* lines (light/double/heavy/arcs) */
64 | drawboxlines(x, y, w, h, fg, bd);
65 |
66 | } else if (cat == BBD) {
67 | /* lower (8-X)/8 block */
68 | int d = DIV((uint8_t)bd * h, 8);
69 | XftDrawRect(xd, fg, x, y + d, w, h - d);
70 |
71 | } else if (cat == BBU) {
72 | /* upper X/8 block */
73 | XftDrawRect(xd, fg, x, y, w, DIV((uint8_t)bd * h, 8));
74 |
75 | } else if (cat == BBL) {
76 | /* left X/8 block */
77 | XftDrawRect(xd, fg, x, y, DIV((uint8_t)bd * w, 8), h);
78 |
79 | } else if (cat == BBR) {
80 | /* right (8-X)/8 block */
81 | int d = DIV((uint8_t)bd * w, 8);
82 | XftDrawRect(xd, fg, x + d, y, w - d, h);
83 |
84 | } else if (cat == BBQ) {
85 | /* Quadrants */
86 | int w2 = DIV(w, 2), h2 = DIV(h, 2);
87 | if (bd & TL)
88 | XftDrawRect(xd, fg, x, y, w2, h2);
89 | if (bd & TR)
90 | XftDrawRect(xd, fg, x + w2, y, w - w2, h2);
91 | if (bd & BL)
92 | XftDrawRect(xd, fg, x, y + h2, w2, h - h2);
93 | if (bd & BR)
94 | XftDrawRect(xd, fg, x + w2, y + h2, w - w2, h - h2);
95 |
96 | } else if (bd & BBS) {
97 | /* Shades - data is 1/2/3 for 25%/50%/75% alpha, respectively */
98 | int d = (uint8_t)bd;
99 | XftColor xfc;
100 | XRenderColor xrc = { .alpha = 0xffff };
101 |
102 | xrc.red = DIV(fg->color.red * d + bg->color.red * (4 - d), 4);
103 | xrc.green = DIV(fg->color.green * d + bg->color.green * (4 - d), 4);
104 | xrc.blue = DIV(fg->color.blue * d + bg->color.blue * (4 - d), 4);
105 |
106 | XftColorAllocValue(xdpy, xvis, xcmap, &xrc, &xfc);
107 | XftDrawRect(xd, &xfc, x, y, w, h);
108 | XftColorFree(xdpy, xvis, xcmap, &xfc);
109 |
110 | } else if (cat == BRL) {
111 | /* braille, each data bit corresponds to one dot at 2x4 grid */
112 | int w1 = DIV(w, 2);
113 | int h1 = DIV(h, 4), h2 = DIV(h, 2), h3 = DIV(3 * h, 4);
114 |
115 | if (bd & 1) XftDrawRect(xd, fg, x, y, w1, h1);
116 | if (bd & 2) XftDrawRect(xd, fg, x, y + h1, w1, h2 - h1);
117 | if (bd & 4) XftDrawRect(xd, fg, x, y + h2, w1, h3 - h2);
118 | if (bd & 8) XftDrawRect(xd, fg, x + w1, y, w - w1, h1);
119 | if (bd & 16) XftDrawRect(xd, fg, x + w1, y + h1, w - w1, h2 - h1);
120 | if (bd & 32) XftDrawRect(xd, fg, x + w1, y + h2, w - w1, h3 - h2);
121 | if (bd & 64) XftDrawRect(xd, fg, x, y + h3, w1, h - h3);
122 | if (bd & 128) XftDrawRect(xd, fg, x + w1, y + h3, w - w1, h - h3);
123 |
124 | }
125 | }
126 |
127 | void
128 | drawboxlines(int x, int y, int w, int h, XftColor *fg, ushort bd)
129 | {
130 | /* s: stem thickness. width/8 roughly matches underscore thickness. */
131 | /* We draw bold as 1.5 * normal-stem and at least 1px thicker. */
132 | /* doubles draw at least 3px, even when w or h < 3. bold needs 6px. */
133 | int mwh = MIN(w, h);
134 | int base_s = MAX(1, DIV(mwh, 8));
135 | int bold = (bd & BDB) && mwh >= 6; /* possibly ignore boldness */
136 | int s = bold ? MAX(base_s + 1, DIV(3 * base_s, 2)) : base_s;
137 | int w2 = DIV(w - s, 2), h2 = DIV(h - s, 2);
138 | /* the s-by-s square (x + w2, y + h2, s, s) is the center texel. */
139 | /* The base length (per direction till edge) includes this square. */
140 |
141 | int light = bd & (LL | LU | LR | LD);
142 | int double_ = bd & (DL | DU | DR | DD);
143 |
144 | if (light) {
145 | /* d: additional (negative) length to not-draw the center */
146 | /* texel - at arcs and avoid drawing inside (some) doubles */
147 | int arc = bd & BDA;
148 | int multi_light = light & (light - 1);
149 | int multi_double = double_ & (double_ - 1);
150 | /* light crosses double only at DH+LV, DV+LH (ref. shapes) */
151 | int d = arc || (multi_double && !multi_light) ? -s : 0;
152 |
153 | if (bd & LL)
154 | XftDrawRect(xd, fg, x, y + h2, w2 + s + d, s);
155 | if (bd & LU)
156 | XftDrawRect(xd, fg, x + w2, y, s, h2 + s + d);
157 | if (bd & LR)
158 | XftDrawRect(xd, fg, x + w2 - d, y + h2, w - w2 + d, s);
159 | if (bd & LD)
160 | XftDrawRect(xd, fg, x + w2, y + h2 - d, s, h - h2 + d);
161 | }
162 |
163 | /* double lines - also align with light to form heavy when combined */
164 | if (double_) {
165 | /*
166 | * going clockwise, for each double-ray: p is additional length
167 | * to the single-ray nearer to the previous direction, and n to
168 | * the next. p and n adjust from the base length to lengths
169 | * which consider other doubles - shorter to avoid intersections
170 | * (p, n), or longer to draw the far-corner texel (n).
171 | */
172 | int dl = bd & DL, du = bd & DU, dr = bd & DR, dd = bd & DD;
173 | if (dl) {
174 | int p = dd ? -s : 0, n = du ? -s : dd ? s : 0;
175 | XftDrawRect(xd, fg, x, y + h2 + s, w2 + s + p, s);
176 | XftDrawRect(xd, fg, x, y + h2 - s, w2 + s + n, s);
177 | }
178 | if (du) {
179 | int p = dl ? -s : 0, n = dr ? -s : dl ? s : 0;
180 | XftDrawRect(xd, fg, x + w2 - s, y, s, h2 + s + p);
181 | XftDrawRect(xd, fg, x + w2 + s, y, s, h2 + s + n);
182 | }
183 | if (dr) {
184 | int p = du ? -s : 0, n = dd ? -s : du ? s : 0;
185 | XftDrawRect(xd, fg, x + w2 - p, y + h2 - s, w - w2 + p, s);
186 | XftDrawRect(xd, fg, x + w2 - n, y + h2 + s, w - w2 + n, s);
187 | }
188 | if (dd) {
189 | int p = dr ? -s : 0, n = dl ? -s : dr ? s : 0;
190 | XftDrawRect(xd, fg, x + w2 + s, y + h2 - p, s, h - h2 + p);
191 | XftDrawRect(xd, fg, x + w2 - s, y + h2 - n, s, h - h2 + n);
192 | }
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/st/boxdraw_data.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 Avi Halachmi (:avih) avihpit@yahoo.com https://github.com/avih
3 | * MIT/X Consortium License
4 | */
5 |
6 | /*
7 | * U+25XX codepoints data
8 | *
9 | * References:
10 | * http://www.unicode.org/charts/PDF/U2500.pdf
11 | * http://www.unicode.org/charts/PDF/U2580.pdf
12 | *
13 | * Test page:
14 | * https://github.com/GNOME/vte/blob/master/doc/boxes.txt
15 | */
16 |
17 | /* Each shape is encoded as 16-bits. Higher bits are category, lower are data */
18 | /* Categories (mutually exclusive except BDB): */
19 | /* For convenience, BDL/BDA/BBS/BDB are 1 bit each, the rest are enums */
20 | #define BDL (1<<8) /* Box Draw Lines (light/double/heavy) */
21 | #define BDA (1<<9) /* Box Draw Arc (light) */
22 |
23 | #define BBD (1<<10) /* Box Block Down (lower) X/8 */
24 | #define BBL (2<<10) /* Box Block Left X/8 */
25 | #define BBU (3<<10) /* Box Block Upper X/8 */
26 | #define BBR (4<<10) /* Box Block Right X/8 */
27 | #define BBQ (5<<10) /* Box Block Quadrants */
28 | #define BRL (6<<10) /* Box Braille (data is lower byte of U28XX) */
29 |
30 | #define BBS (1<<14) /* Box Block Shades */
31 | #define BDB (1<<15) /* Box Draw is Bold */
32 |
33 | /* (BDL/BDA) Light/Double/Heavy x Left/Up/Right/Down/Horizontal/Vertical */
34 | /* Heavy is light+double (literally drawing light+double align to form heavy) */
35 | #define LL (1<<0)
36 | #define LU (1<<1)
37 | #define LR (1<<2)
38 | #define LD (1<<3)
39 | #define LH (LL+LR)
40 | #define LV (LU+LD)
41 |
42 | #define DL (1<<4)
43 | #define DU (1<<5)
44 | #define DR (1<<6)
45 | #define DD (1<<7)
46 | #define DH (DL+DR)
47 | #define DV (DU+DD)
48 |
49 | #define HL (LL+DL)
50 | #define HU (LU+DU)
51 | #define HR (LR+DR)
52 | #define HD (LD+DD)
53 | #define HH (HL+HR)
54 | #define HV (HU+HD)
55 |
56 | /* (BBQ) Quadrants Top/Bottom x Left/Right */
57 | #define TL (1<<0)
58 | #define TR (1<<1)
59 | #define BL (1<<2)
60 | #define BR (1<<3)
61 |
62 | /* Data for U+2500 - U+259F except dashes/diagonals */
63 | static const unsigned short boxdata[256] = {
64 | /* light lines */
65 | [0x00] = BDL + LH, /* light horizontal */
66 | [0x02] = BDL + LV, /* light vertical */
67 | [0x0c] = BDL + LD + LR, /* light down and right */
68 | [0x10] = BDL + LD + LL, /* light down and left */
69 | [0x14] = BDL + LU + LR, /* light up and right */
70 | [0x18] = BDL + LU + LL, /* light up and left */
71 | [0x1c] = BDL + LV + LR, /* light vertical and right */
72 | [0x24] = BDL + LV + LL, /* light vertical and left */
73 | [0x2c] = BDL + LH + LD, /* light horizontal and down */
74 | [0x34] = BDL + LH + LU, /* light horizontal and up */
75 | [0x3c] = BDL + LV + LH, /* light vertical and horizontal */
76 | [0x74] = BDL + LL, /* light left */
77 | [0x75] = BDL + LU, /* light up */
78 | [0x76] = BDL + LR, /* light right */
79 | [0x77] = BDL + LD, /* light down */
80 |
81 | /* heavy [+light] lines */
82 | [0x01] = BDL + HH,
83 | [0x03] = BDL + HV,
84 | [0x0d] = BDL + HR + LD,
85 | [0x0e] = BDL + HD + LR,
86 | [0x0f] = BDL + HD + HR,
87 | [0x11] = BDL + HL + LD,
88 | [0x12] = BDL + HD + LL,
89 | [0x13] = BDL + HD + HL,
90 | [0x15] = BDL + HR + LU,
91 | [0x16] = BDL + HU + LR,
92 | [0x17] = BDL + HU + HR,
93 | [0x19] = BDL + HL + LU,
94 | [0x1a] = BDL + HU + LL,
95 | [0x1b] = BDL + HU + HL,
96 | [0x1d] = BDL + HR + LV,
97 | [0x1e] = BDL + HU + LD + LR,
98 | [0x1f] = BDL + HD + LR + LU,
99 | [0x20] = BDL + HV + LR,
100 | [0x21] = BDL + HU + HR + LD,
101 | [0x22] = BDL + HD + HR + LU,
102 | [0x23] = BDL + HV + HR,
103 | [0x25] = BDL + HL + LV,
104 | [0x26] = BDL + HU + LD + LL,
105 | [0x27] = BDL + HD + LU + LL,
106 | [0x28] = BDL + HV + LL,
107 | [0x29] = BDL + HU + HL + LD,
108 | [0x2a] = BDL + HD + HL + LU,
109 | [0x2b] = BDL + HV + HL,
110 | [0x2d] = BDL + HL + LD + LR,
111 | [0x2e] = BDL + HR + LL + LD,
112 | [0x2f] = BDL + HH + LD,
113 | [0x30] = BDL + HD + LH,
114 | [0x31] = BDL + HD + HL + LR,
115 | [0x32] = BDL + HR + HD + LL,
116 | [0x33] = BDL + HH + HD,
117 | [0x35] = BDL + HL + LU + LR,
118 | [0x36] = BDL + HR + LU + LL,
119 | [0x37] = BDL + HH + LU,
120 | [0x38] = BDL + HU + LH,
121 | [0x39] = BDL + HU + HL + LR,
122 | [0x3a] = BDL + HU + HR + LL,
123 | [0x3b] = BDL + HH + HU,
124 | [0x3d] = BDL + HL + LV + LR,
125 | [0x3e] = BDL + HR + LV + LL,
126 | [0x3f] = BDL + HH + LV,
127 | [0x40] = BDL + HU + LH + LD,
128 | [0x41] = BDL + HD + LH + LU,
129 | [0x42] = BDL + HV + LH,
130 | [0x43] = BDL + HU + HL + LD + LR,
131 | [0x44] = BDL + HU + HR + LD + LL,
132 | [0x45] = BDL + HD + HL + LU + LR,
133 | [0x46] = BDL + HD + HR + LU + LL,
134 | [0x47] = BDL + HH + HU + LD,
135 | [0x48] = BDL + HH + HD + LU,
136 | [0x49] = BDL + HV + HL + LR,
137 | [0x4a] = BDL + HV + HR + LL,
138 | [0x4b] = BDL + HV + HH,
139 | [0x78] = BDL + HL,
140 | [0x79] = BDL + HU,
141 | [0x7a] = BDL + HR,
142 | [0x7b] = BDL + HD,
143 | [0x7c] = BDL + HR + LL,
144 | [0x7d] = BDL + HD + LU,
145 | [0x7e] = BDL + HL + LR,
146 | [0x7f] = BDL + HU + LD,
147 |
148 | /* double [+light] lines */
149 | [0x50] = BDL + DH,
150 | [0x51] = BDL + DV,
151 | [0x52] = BDL + DR + LD,
152 | [0x53] = BDL + DD + LR,
153 | [0x54] = BDL + DR + DD,
154 | [0x55] = BDL + DL + LD,
155 | [0x56] = BDL + DD + LL,
156 | [0x57] = BDL + DL + DD,
157 | [0x58] = BDL + DR + LU,
158 | [0x59] = BDL + DU + LR,
159 | [0x5a] = BDL + DU + DR,
160 | [0x5b] = BDL + DL + LU,
161 | [0x5c] = BDL + DU + LL,
162 | [0x5d] = BDL + DL + DU,
163 | [0x5e] = BDL + DR + LV,
164 | [0x5f] = BDL + DV + LR,
165 | [0x60] = BDL + DV + DR,
166 | [0x61] = BDL + DL + LV,
167 | [0x62] = BDL + DV + LL,
168 | [0x63] = BDL + DV + DL,
169 | [0x64] = BDL + DH + LD,
170 | [0x65] = BDL + DD + LH,
171 | [0x66] = BDL + DD + DH,
172 | [0x67] = BDL + DH + LU,
173 | [0x68] = BDL + DU + LH,
174 | [0x69] = BDL + DH + DU,
175 | [0x6a] = BDL + DH + LV,
176 | [0x6b] = BDL + DV + LH,
177 | [0x6c] = BDL + DH + DV,
178 |
179 | /* (light) arcs */
180 | [0x6d] = BDA + LD + LR,
181 | [0x6e] = BDA + LD + LL,
182 | [0x6f] = BDA + LU + LL,
183 | [0x70] = BDA + LU + LR,
184 |
185 | /* Lower (Down) X/8 block (data is 8 - X) */
186 | [0x81] = BBD + 7, [0x82] = BBD + 6, [0x83] = BBD + 5, [0x84] = BBD + 4,
187 | [0x85] = BBD + 3, [0x86] = BBD + 2, [0x87] = BBD + 1, [0x88] = BBD + 0,
188 |
189 | /* Left X/8 block (data is X) */
190 | [0x89] = BBL + 7, [0x8a] = BBL + 6, [0x8b] = BBL + 5, [0x8c] = BBL + 4,
191 | [0x8d] = BBL + 3, [0x8e] = BBL + 2, [0x8f] = BBL + 1,
192 |
193 | /* upper 1/2 (4/8), 1/8 block (X), right 1/2, 1/8 block (8-X) */
194 | [0x80] = BBU + 4, [0x94] = BBU + 1,
195 | [0x90] = BBR + 4, [0x95] = BBR + 7,
196 |
197 | /* Quadrants */
198 | [0x96] = BBQ + BL,
199 | [0x97] = BBQ + BR,
200 | [0x98] = BBQ + TL,
201 | [0x99] = BBQ + TL + BL + BR,
202 | [0x9a] = BBQ + TL + BR,
203 | [0x9b] = BBQ + TL + TR + BL,
204 | [0x9c] = BBQ + TL + TR + BR,
205 | [0x9d] = BBQ + TR,
206 | [0x9e] = BBQ + BL + TR,
207 | [0x9f] = BBQ + BL + TR + BR,
208 |
209 | /* Shades, data is an alpha value in 25% units (1/4, 1/2, 3/4) */
210 | [0x91] = BBS + 1, [0x92] = BBS + 2, [0x93] = BBS + 3,
211 |
212 | /* U+2504 - U+250B, U+254C - U+254F: unsupported (dashes) */
213 | /* U+2571 - U+2573: unsupported (diagonals) */
214 | };
215 |
--------------------------------------------------------------------------------
/st/config.h:
--------------------------------------------------------------------------------
1 | /* See LICENSE file for copyright and license details. */
2 |
3 | /*
4 | * appearance
5 | *
6 | * font: see http://freedesktop.org/software/fontconfig/fontconfig-user.html
7 | */
8 | static char *font = "Hack:pixelsize=12:antialias=true:autohint=true";
9 | static char *font2[] = { "JoyPixels:pixelsize=10:antialias=true:autohint=true" };
10 | static int borderpx = 2;
11 |
12 | /*
13 | * What program is execed by st depends of these precedence rules:
14 | * 1: program passed with -e
15 | * 2: scroll and/or utmp
16 | * 3: SHELL environment variable
17 | * 4: value of shell in /etc/passwd
18 | * 5: value of shell in config.h
19 | */
20 | static char *shell = "/bin/sh";
21 | char *utmp = NULL;
22 | /* scroll program: to enable use a string like "scroll" */
23 | char *scroll = NULL;
24 | char *stty_args = "stty raw pass8 nl -echo -iexten -cstopb 38400";
25 |
26 | /* identification sequence returned in DA and DECID */
27 | char *vtiden = "\033[?6c";
28 |
29 | /* Kerning / character bounding-box multipliers */
30 | static float cwscale = 1.0;
31 | static float chscale = 1.0;
32 |
33 | /*
34 | * word delimiter string
35 | *
36 | * More advanced example: L" `'\"()[]{}"
37 | */
38 | wchar_t *worddelimiters = L" ";
39 |
40 | /* selection timeouts (in milliseconds) */
41 | static unsigned int doubleclicktimeout = 300;
42 | static unsigned int tripleclicktimeout = 600;
43 |
44 | /* alt screens */
45 | int allowaltscreen = 1;
46 |
47 | /* allow certain non-interactive (insecure) window operations such as:
48 | setting the clipboard text */
49 | int allowwindowops = 0;
50 |
51 | /*
52 | * draw latency range in ms - from new content/keypress/etc until drawing.
53 | * within this range, st draws when content stops arriving (idle). mostly it's
54 | * near minlatency, but it waits longer for slow updates to avoid partial draw.
55 | * low minlatency will tear/flicker more, as it can "detect" idle too early.
56 | */
57 | static double minlatency = 8;
58 | static double maxlatency = 33;
59 |
60 | /*
61 | * blinking timeout (set to 0 to disable blinking) for the terminal blinking
62 | * attribute.
63 | */
64 | static unsigned int blinktimeout = 800;
65 |
66 | /*
67 | * thickness of underline and bar cursors
68 | */
69 | static unsigned int cursorthickness = 2;
70 |
71 | /*
72 | * 1: render most of the lines/blocks characters without using the font for
73 | * perfect alignment between cells (U2500 - U259F except dashes/diagonals).
74 | * Bold affects lines thickness if boxdraw_bold is not 0. Italic is ignored.
75 | * 0: disable (render all U25XX glyphs normally from the font).
76 | */
77 | const int boxdraw = 1;
78 | const int boxdraw_bold = 0;
79 |
80 | /* braille (U28XX): 1: render as adjacent "pixels", 0: use font */
81 | const int boxdraw_braille = 0;
82 |
83 | /*
84 | * bell volume. It must be a value between -100 and 100. Use 0 for disabling
85 | * it
86 | */
87 | static int bellvolume = 0;
88 |
89 | /* default TERM value */
90 | char *termname = "st-256color";
91 |
92 | /*
93 | * spaces per tab
94 | *
95 | * When you are changing this value, don't forget to adapt the »it« value in
96 | * the st.info and appropriately install the st.info in the environment where
97 | * you use this st version.
98 | *
99 | * it#$tabspaces,
100 | *
101 | * Secondly make sure your kernel is not expanding tabs. When running `stty
102 | * -a` »tab0« should appear. You can tell the terminal to not expand tabs by
103 | * running following command:
104 | *
105 | * stty tabs
106 | */
107 | unsigned int tabspaces = 8;
108 |
109 | /* bg opacity */
110 | float alpha = 1.0;
111 |
112 | /* Terminal colors (16 first used in escape sequence) */
113 | static const char *colorname[] = {
114 | "#282828", /* hard contrast: #1d2021 / soft contrast: #32302f */
115 | "#cc241d",
116 | "#98971a",
117 | "#d79921",
118 | "#458588",
119 | "#b16286",
120 | "#689d6a",
121 | "#a89984",
122 | "#928374",
123 | "#fb4934",
124 | "#b8bb26",
125 | "#fabd2f",
126 | "#83a598",
127 | "#d3869b",
128 | "#8ec07c",
129 | "#ebdbb2",
130 | [255] = 0,
131 | /* more colors can be added after 255 to use with DefaultXX */
132 | "#add8e6", /* 256 -> cursor */
133 | "#555555", /* 257 -> rev cursor*/
134 | "#282828", /* 258 -> bg */
135 | "#ebdbb2", /* 259 -> fg */
136 | };
137 |
138 |
139 | /*
140 | * Default colors (colorname index)
141 | * foreground, background, cursor, reverse cursor
142 | */
143 | unsigned int defaultfg = 259;
144 | unsigned int defaultbg = 258;
145 | unsigned int defaultcs = 256;
146 | unsigned int defaultrcs = 257;
147 |
148 | /*
149 | * Default shape of cursor
150 | * 2: Block ("█")
151 | * 4: Underline ("_")
152 | * 6: Bar ("|")
153 | * 7: Snowman ("☃")
154 | */
155 | static unsigned int cursorshape = 2;
156 |
157 | /*
158 | * Default columns and rows numbers
159 | */
160 |
161 | static unsigned int cols = 80;
162 | static unsigned int rows = 24;
163 |
164 | /*
165 | * Default colour and shape of the mouse cursor
166 | */
167 | static unsigned int mouseshape = XC_xterm;
168 | static unsigned int mousefg = 7;
169 | static unsigned int mousebg = 0;
170 |
171 | /*
172 | * Color used to display font attributes when fontconfig selected a font which
173 | * doesn't match the ones requested.
174 | */
175 | static unsigned int defaultattr = 11;
176 |
177 | /*
178 | * Force mouse select/shortcuts while mask is active (when MODE_MOUSE is set).
179 | * Note that if you want to use ShiftMask with selmasks, set this to an other
180 | * modifier, set to 0 to not use it.
181 | */
182 | static uint forcemousemod = ShiftMask;
183 |
184 | /*
185 | * Xresources preferences to load at startup
186 | */
187 | ResourcePref resources[] = {
188 | { "font", STRING, &font },
189 | { "fontalt0", STRING, &font2[0] },
190 | { "color0", STRING, &colorname[0] },
191 | { "color1", STRING, &colorname[1] },
192 | { "color2", STRING, &colorname[2] },
193 | { "color3", STRING, &colorname[3] },
194 | { "color4", STRING, &colorname[4] },
195 | { "color5", STRING, &colorname[5] },
196 | { "color6", STRING, &colorname[6] },
197 | { "color7", STRING, &colorname[7] },
198 | { "color8", STRING, &colorname[8] },
199 | { "color9", STRING, &colorname[9] },
200 | { "color10", STRING, &colorname[10] },
201 | { "color11", STRING, &colorname[11] },
202 | { "color12", STRING, &colorname[12] },
203 | { "color13", STRING, &colorname[13] },
204 | { "color14", STRING, &colorname[14] },
205 | { "color15", STRING, &colorname[15] },
206 | { "background", STRING, &colorname[258] },
207 | { "foreground", STRING, &colorname[259] },
208 | { "cursorColor", STRING, &colorname[256] },
209 | { "termname", STRING, &termname },
210 | { "shell", STRING, &shell },
211 | { "minlatency", INTEGER, &minlatency },
212 | { "maxlatency", INTEGER, &maxlatency },
213 | { "blinktimeout", INTEGER, &blinktimeout },
214 | { "bellvolume", INTEGER, &bellvolume },
215 | { "tabspaces", INTEGER, &tabspaces },
216 | { "borderpx", INTEGER, &borderpx },
217 | { "cwscale", FLOAT, &cwscale },
218 | { "chscale", FLOAT, &chscale },
219 | { "alpha", FLOAT, &alpha },
220 | };
221 |
222 | /*
223 | * Internal mouse shortcuts.
224 | * Beware that overloading Button1 will disable the selection.
225 | */
226 | static MouseShortcut mshortcuts[] = {
227 | /* mask button function argument release */
228 | { XK_NO_MOD, Button4, kscrollup, {.i = 1} },
229 | { XK_NO_MOD, Button5, kscrolldown, {.i = 1} },
230 | { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
231 | { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
232 | { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
233 | { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
234 | { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
235 | };
236 |
237 | /* Internal keyboard shortcuts. */
238 | #define MODKEY Mod1Mask
239 | #define TERMMOD (Mod1Mask|ShiftMask)
240 |
241 | static char *openurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -o", "externalpipe", NULL };
242 | static char *copyurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -c", "externalpipe", NULL };
243 | static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NULL };
244 |
245 |
246 | static Shortcut shortcuts[] = {
247 | /* mask keysym function argument */
248 | { XK_ANY_MOD, XK_Break, sendbreak, {.i = 0} },
249 | { ControlMask, XK_Print, toggleprinter, {.i = 0} },
250 | { ShiftMask, XK_Print, printscreen, {.i = 0} },
251 | { XK_ANY_MOD, XK_Print, printsel, {.i = 0} },
252 | { TERMMOD, XK_Prior, zoom, {.f = +1} },
253 | { TERMMOD, XK_Next, zoom, {.f = -1} },
254 | { TERMMOD, XK_Home, zoomreset, {.f = 0} },
255 | { TERMMOD, XK_C, clipcopy, {.i = 0} },
256 | { TERMMOD, XK_V, clippaste, {.i = 0} },
257 | { MODKEY, XK_c, clipcopy, {.i = 0} },
258 | { ShiftMask, XK_Insert, clippaste, {.i = 0} },
259 | { MODKEY, XK_v, clippaste, {.i = 0} },
260 | { ShiftMask, XK_Insert, selpaste, {.i = 0} },
261 | { TERMMOD, XK_Num_Lock, numlock, {.i = 0} },
262 | { ShiftMask, XK_Page_Up, kscrollup, {.i = -1} },
263 | { ShiftMask, XK_Page_Down, kscrolldown, {.i = -1} },
264 | { MODKEY, XK_Page_Up, kscrollup, {.i = -1} },
265 | { MODKEY, XK_Page_Down, kscrolldown, {.i = -1} },
266 | { MODKEY, XK_k, kscrollup, {.i = 1} },
267 | { MODKEY, XK_j, kscrolldown, {.i = 1} },
268 | { MODKEY, XK_Up, kscrollup, {.i = 1} },
269 | { MODKEY, XK_Down, kscrolldown, {.i = 1} },
270 | { MODKEY, XK_u, kscrollup, {.i = -1} },
271 | { MODKEY, XK_d, kscrolldown, {.i = -1} },
272 | { MODKEY, XK_s, changealpha, {.f = -0.05} },
273 | { MODKEY, XK_a, changealpha, {.f = +0.05} },
274 | { TERMMOD, XK_Up, zoom, {.f = +1} },
275 | { TERMMOD, XK_Down, zoom, {.f = -1} },
276 | { TERMMOD, XK_K, zoom, {.f = +1} },
277 | { TERMMOD, XK_J, zoom, {.f = -1} },
278 | { TERMMOD, XK_U, zoom, {.f = +2} },
279 | { TERMMOD, XK_D, zoom, {.f = -2} },
280 | { MODKEY, XK_l, externalpipe, {.v = openurlcmd } },
281 | { MODKEY, XK_y, externalpipe, {.v = copyurlcmd } },
282 | { MODKEY, XK_o, externalpipe, {.v = copyoutput } },
283 | };
284 |
285 | /*
286 | * Special keys (change & recompile st.info accordingly)
287 | *
288 | * Mask value:
289 | * * Use XK_ANY_MOD to match the key no matter modifiers state
290 | * * Use XK_NO_MOD to match the key alone (no modifiers)
291 | * appkey value:
292 | * * 0: no value
293 | * * > 0: keypad application mode enabled
294 | * * = 2: term.numlock = 1
295 | * * < 0: keypad application mode disabled
296 | * appcursor value:
297 | * * 0: no value
298 | * * > 0: cursor application mode enabled
299 | * * < 0: cursor application mode disabled
300 | *
301 | * Be careful with the order of the definitions because st searches in
302 | * this table sequentially, so any XK_ANY_MOD must be in the last
303 | * position for a key.
304 | */
305 |
306 | /*
307 | * If you want keys other than the X11 function keys (0xFD00 - 0xFFFF)
308 | * to be mapped below, add them to this array.
309 | */
310 | static KeySym mappedkeys[] = { -1 };
311 |
312 | /*
313 | * State bits to ignore when matching key or button events. By default,
314 | * numlock (Mod2Mask) and keyboard layout (XK_SWITCH_MOD) are ignored.
315 | */
316 | static uint ignoremod = Mod2Mask|XK_SWITCH_MOD;
317 |
318 | /*
319 | * This is the huge key array which defines all compatibility to the Linux
320 | * world. Please decide about changes wisely.
321 | */
322 | static Key key[] = {
323 | /* keysym mask string appkey appcursor */
324 | { XK_KP_Home, ShiftMask, "\033[2J", 0, -1},
325 | { XK_KP_Home, ShiftMask, "\033[1;2H", 0, +1},
326 | { XK_KP_Home, XK_ANY_MOD, "\033[H", 0, -1},
327 | { XK_KP_Home, XK_ANY_MOD, "\033[1~", 0, +1},
328 | { XK_KP_Up, XK_ANY_MOD, "\033Ox", +1, 0},
329 | { XK_KP_Up, XK_ANY_MOD, "\033[A", 0, -1},
330 | { XK_KP_Up, XK_ANY_MOD, "\033OA", 0, +1},
331 | { XK_KP_Down, XK_ANY_MOD, "\033Or", +1, 0},
332 | { XK_KP_Down, XK_ANY_MOD, "\033[B", 0, -1},
333 | { XK_KP_Down, XK_ANY_MOD, "\033OB", 0, +1},
334 | { XK_KP_Left, XK_ANY_MOD, "\033Ot", +1, 0},
335 | { XK_KP_Left, XK_ANY_MOD, "\033[D", 0, -1},
336 | { XK_KP_Left, XK_ANY_MOD, "\033OD", 0, +1},
337 | { XK_KP_Right, XK_ANY_MOD, "\033Ov", +1, 0},
338 | { XK_KP_Right, XK_ANY_MOD, "\033[C", 0, -1},
339 | { XK_KP_Right, XK_ANY_MOD, "\033OC", 0, +1},
340 | { XK_KP_Prior, ShiftMask, "\033[5;2~", 0, 0},
341 | { XK_KP_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
342 | { XK_KP_Begin, XK_ANY_MOD, "\033[E", 0, 0},
343 | { XK_KP_End, ControlMask, "\033[J", -1, 0},
344 | { XK_KP_End, ControlMask, "\033[1;5F", +1, 0},
345 | { XK_KP_End, ShiftMask, "\033[K", -1, 0},
346 | { XK_KP_End, ShiftMask, "\033[1;2F", +1, 0},
347 | { XK_KP_End, XK_ANY_MOD, "\033[4~", 0, 0},
348 | { XK_KP_Next, ShiftMask, "\033[6;2~", 0, 0},
349 | { XK_KP_Next, XK_ANY_MOD, "\033[6~", 0, 0},
350 | { XK_KP_Insert, ShiftMask, "\033[2;2~", +1, 0},
351 | { XK_KP_Insert, ShiftMask, "\033[4l", -1, 0},
352 | { XK_KP_Insert, ControlMask, "\033[L", -1, 0},
353 | { XK_KP_Insert, ControlMask, "\033[2;5~", +1, 0},
354 | { XK_KP_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
355 | { XK_KP_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
356 | { XK_KP_Delete, ControlMask, "\033[M", -1, 0},
357 | { XK_KP_Delete, ControlMask, "\033[3;5~", +1, 0},
358 | { XK_KP_Delete, ShiftMask, "\033[2K", -1, 0},
359 | { XK_KP_Delete, ShiftMask, "\033[3;2~", +1, 0},
360 | { XK_KP_Delete, XK_ANY_MOD, "\033[P", -1, 0},
361 | { XK_KP_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
362 | { XK_KP_Multiply, XK_ANY_MOD, "\033Oj", +2, 0},
363 | { XK_KP_Add, XK_ANY_MOD, "\033Ok", +2, 0},
364 | { XK_KP_Enter, XK_ANY_MOD, "\033OM", +2, 0},
365 | { XK_KP_Enter, XK_ANY_MOD, "\r", -1, 0},
366 | { XK_KP_Subtract, XK_ANY_MOD, "\033Om", +2, 0},
367 | { XK_KP_Decimal, XK_ANY_MOD, "\033On", +2, 0},
368 | { XK_KP_Divide, XK_ANY_MOD, "\033Oo", +2, 0},
369 | { XK_KP_0, XK_ANY_MOD, "\033Op", +2, 0},
370 | { XK_KP_1, XK_ANY_MOD, "\033Oq", +2, 0},
371 | { XK_KP_2, XK_ANY_MOD, "\033Or", +2, 0},
372 | { XK_KP_3, XK_ANY_MOD, "\033Os", +2, 0},
373 | { XK_KP_4, XK_ANY_MOD, "\033Ot", +2, 0},
374 | { XK_KP_5, XK_ANY_MOD, "\033Ou", +2, 0},
375 | { XK_KP_6, XK_ANY_MOD, "\033Ov", +2, 0},
376 | { XK_KP_7, XK_ANY_MOD, "\033Ow", +2, 0},
377 | { XK_KP_8, XK_ANY_MOD, "\033Ox", +2, 0},
378 | { XK_KP_9, XK_ANY_MOD, "\033Oy", +2, 0},
379 | { XK_Up, ShiftMask, "\033[1;2A", 0, 0},
380 | { XK_Up, Mod1Mask, "\033[1;3A", 0, 0},
381 | { XK_Up, ShiftMask|Mod1Mask,"\033[1;4A", 0, 0},
382 | { XK_Up, ControlMask, "\033[1;5A", 0, 0},
383 | { XK_Up, ShiftMask|ControlMask,"\033[1;6A", 0, 0},
384 | { XK_Up, ControlMask|Mod1Mask,"\033[1;7A", 0, 0},
385 | { XK_Up,ShiftMask|ControlMask|Mod1Mask,"\033[1;8A", 0, 0},
386 | { XK_Up, XK_ANY_MOD, "\033[A", 0, -1},
387 | { XK_Up, XK_ANY_MOD, "\033OA", 0, +1},
388 | { XK_Down, ShiftMask, "\033[1;2B", 0, 0},
389 | { XK_Down, Mod1Mask, "\033[1;3B", 0, 0},
390 | { XK_Down, ShiftMask|Mod1Mask,"\033[1;4B", 0, 0},
391 | { XK_Down, ControlMask, "\033[1;5B", 0, 0},
392 | { XK_Down, ShiftMask|ControlMask,"\033[1;6B", 0, 0},
393 | { XK_Down, ControlMask|Mod1Mask,"\033[1;7B", 0, 0},
394 | { XK_Down,ShiftMask|ControlMask|Mod1Mask,"\033[1;8B",0, 0},
395 | { XK_Down, XK_ANY_MOD, "\033[B", 0, -1},
396 | { XK_Down, XK_ANY_MOD, "\033OB", 0, +1},
397 | { XK_Left, ShiftMask, "\033[1;2D", 0, 0},
398 | { XK_Left, Mod1Mask, "\033[1;3D", 0, 0},
399 | { XK_Left, ShiftMask|Mod1Mask,"\033[1;4D", 0, 0},
400 | { XK_Left, ControlMask, "\033[1;5D", 0, 0},
401 | { XK_Left, ShiftMask|ControlMask,"\033[1;6D", 0, 0},
402 | { XK_Left, ControlMask|Mod1Mask,"\033[1;7D", 0, 0},
403 | { XK_Left,ShiftMask|ControlMask|Mod1Mask,"\033[1;8D",0, 0},
404 | { XK_Left, XK_ANY_MOD, "\033[D", 0, -1},
405 | { XK_Left, XK_ANY_MOD, "\033OD", 0, +1},
406 | { XK_Right, ShiftMask, "\033[1;2C", 0, 0},
407 | { XK_Right, Mod1Mask, "\033[1;3C", 0, 0},
408 | { XK_Right, ShiftMask|Mod1Mask,"\033[1;4C", 0, 0},
409 | { XK_Right, ControlMask, "\033[1;5C", 0, 0},
410 | { XK_Right, ShiftMask|ControlMask,"\033[1;6C", 0, 0},
411 | { XK_Right, ControlMask|Mod1Mask,"\033[1;7C", 0, 0},
412 | { XK_Right,ShiftMask|ControlMask|Mod1Mask,"\033[1;8C",0, 0},
413 | { XK_Right, XK_ANY_MOD, "\033[C", 0, -1},
414 | { XK_Right, XK_ANY_MOD, "\033OC", 0, +1},
415 | { XK_ISO_Left_Tab, ShiftMask, "\033[Z", 0, 0},
416 | { XK_Return, Mod1Mask, "\033\r", 0, 0},
417 | { XK_Return, XK_ANY_MOD, "\r", 0, 0},
418 | { XK_Insert, ShiftMask, "\033[4l", -1, 0},
419 | { XK_Insert, ShiftMask, "\033[2;2~", +1, 0},
420 | { XK_Insert, ControlMask, "\033[L", -1, 0},
421 | { XK_Insert, ControlMask, "\033[2;5~", +1, 0},
422 | { XK_Insert, XK_ANY_MOD, "\033[4h", -1, 0},
423 | { XK_Insert, XK_ANY_MOD, "\033[2~", +1, 0},
424 | { XK_Delete, ControlMask, "\033[M", -1, 0},
425 | { XK_Delete, ControlMask, "\033[3;5~", +1, 0},
426 | { XK_Delete, ShiftMask, "\033[2K", -1, 0},
427 | { XK_Delete, ShiftMask, "\033[3;2~", +1, 0},
428 | { XK_Delete, XK_ANY_MOD, "\033[P", -1, 0},
429 | { XK_Delete, XK_ANY_MOD, "\033[3~", +1, 0},
430 | { XK_BackSpace, XK_NO_MOD, "\177", 0, 0},
431 | { XK_BackSpace, Mod1Mask, "\033\177", 0, 0},
432 | { XK_Home, ShiftMask, "\033[2J", 0, -1},
433 | { XK_Home, ShiftMask, "\033[1;2H", 0, +1},
434 | { XK_Home, XK_ANY_MOD, "\033[H", 0, -1},
435 | { XK_Home, XK_ANY_MOD, "\033[1~", 0, +1},
436 | { XK_End, ControlMask, "\033[J", -1, 0},
437 | { XK_End, ControlMask, "\033[1;5F", +1, 0},
438 | { XK_End, ShiftMask, "\033[K", -1, 0},
439 | { XK_End, ShiftMask, "\033[1;2F", +1, 0},
440 | { XK_End, XK_ANY_MOD, "\033[4~", 0, 0},
441 | { XK_Prior, ControlMask, "\033[5;5~", 0, 0},
442 | { XK_Prior, ShiftMask, "\033[5;2~", 0, 0},
443 | { XK_Prior, XK_ANY_MOD, "\033[5~", 0, 0},
444 | { XK_Next, ControlMask, "\033[6;5~", 0, 0},
445 | { XK_Next, ShiftMask, "\033[6;2~", 0, 0},
446 | { XK_Next, XK_ANY_MOD, "\033[6~", 0, 0},
447 | { XK_F1, XK_NO_MOD, "\033OP" , 0, 0},
448 | { XK_F1, /* F13 */ ShiftMask, "\033[1;2P", 0, 0},
449 | { XK_F1, /* F25 */ ControlMask, "\033[1;5P", 0, 0},
450 | { XK_F1, /* F37 */ Mod4Mask, "\033[1;6P", 0, 0},
451 | { XK_F1, /* F49 */ Mod1Mask, "\033[1;3P", 0, 0},
452 | { XK_F1, /* F61 */ Mod3Mask, "\033[1;4P", 0, 0},
453 | { XK_F2, XK_NO_MOD, "\033OQ" , 0, 0},
454 | { XK_F2, /* F14 */ ShiftMask, "\033[1;2Q", 0, 0},
455 | { XK_F2, /* F26 */ ControlMask, "\033[1;5Q", 0, 0},
456 | { XK_F2, /* F38 */ Mod4Mask, "\033[1;6Q", 0, 0},
457 | { XK_F2, /* F50 */ Mod1Mask, "\033[1;3Q", 0, 0},
458 | { XK_F2, /* F62 */ Mod3Mask, "\033[1;4Q", 0, 0},
459 | { XK_F3, XK_NO_MOD, "\033OR" , 0, 0},
460 | { XK_F3, /* F15 */ ShiftMask, "\033[1;2R", 0, 0},
461 | { XK_F3, /* F27 */ ControlMask, "\033[1;5R", 0, 0},
462 | { XK_F3, /* F39 */ Mod4Mask, "\033[1;6R", 0, 0},
463 | { XK_F3, /* F51 */ Mod1Mask, "\033[1;3R", 0, 0},
464 | { XK_F3, /* F63 */ Mod3Mask, "\033[1;4R", 0, 0},
465 | { XK_F4, XK_NO_MOD, "\033OS" , 0, 0},
466 | { XK_F4, /* F16 */ ShiftMask, "\033[1;2S", 0, 0},
467 | { XK_F4, /* F28 */ ControlMask, "\033[1;5S", 0, 0},
468 | { XK_F4, /* F40 */ Mod4Mask, "\033[1;6S", 0, 0},
469 | { XK_F4, /* F52 */ Mod1Mask, "\033[1;3S", 0, 0},
470 | { XK_F5, XK_NO_MOD, "\033[15~", 0, 0},
471 | { XK_F5, /* F17 */ ShiftMask, "\033[15;2~", 0, 0},
472 | { XK_F5, /* F29 */ ControlMask, "\033[15;5~", 0, 0},
473 | { XK_F5, /* F41 */ Mod4Mask, "\033[15;6~", 0, 0},
474 | { XK_F5, /* F53 */ Mod1Mask, "\033[15;3~", 0, 0},
475 | { XK_F6, XK_NO_MOD, "\033[17~", 0, 0},
476 | { XK_F6, /* F18 */ ShiftMask, "\033[17;2~", 0, 0},
477 | { XK_F6, /* F30 */ ControlMask, "\033[17;5~", 0, 0},
478 | { XK_F6, /* F42 */ Mod4Mask, "\033[17;6~", 0, 0},
479 | { XK_F6, /* F54 */ Mod1Mask, "\033[17;3~", 0, 0},
480 | { XK_F7, XK_NO_MOD, "\033[18~", 0, 0},
481 | { XK_F7, /* F19 */ ShiftMask, "\033[18;2~", 0, 0},
482 | { XK_F7, /* F31 */ ControlMask, "\033[18;5~", 0, 0},
483 | { XK_F7, /* F43 */ Mod4Mask, "\033[18;6~", 0, 0},
484 | { XK_F7, /* F55 */ Mod1Mask, "\033[18;3~", 0, 0},
485 | { XK_F8, XK_NO_MOD, "\033[19~", 0, 0},
486 | { XK_F8, /* F20 */ ShiftMask, "\033[19;2~", 0, 0},
487 | { XK_F8, /* F32 */ ControlMask, "\033[19;5~", 0, 0},
488 | { XK_F8, /* F44 */ Mod4Mask, "\033[19;6~", 0, 0},
489 | { XK_F8, /* F56 */ Mod1Mask, "\033[19;3~", 0, 0},
490 | { XK_F9, XK_NO_MOD, "\033[20~", 0, 0},
491 | { XK_F9, /* F21 */ ShiftMask, "\033[20;2~", 0, 0},
492 | { XK_F9, /* F33 */ ControlMask, "\033[20;5~", 0, 0},
493 | { XK_F9, /* F45 */ Mod4Mask, "\033[20;6~", 0, 0},
494 | { XK_F9, /* F57 */ Mod1Mask, "\033[20;3~", 0, 0},
495 | { XK_F10, XK_NO_MOD, "\033[21~", 0, 0},
496 | { XK_F10, /* F22 */ ShiftMask, "\033[21;2~", 0, 0},
497 | { XK_F10, /* F34 */ ControlMask, "\033[21;5~", 0, 0},
498 | { XK_F10, /* F46 */ Mod4Mask, "\033[21;6~", 0, 0},
499 | { XK_F10, /* F58 */ Mod1Mask, "\033[21;3~", 0, 0},
500 | { XK_F11, XK_NO_MOD, "\033[23~", 0, 0},
501 | { XK_F11, /* F23 */ ShiftMask, "\033[23;2~", 0, 0},
502 | { XK_F11, /* F35 */ ControlMask, "\033[23;5~", 0, 0},
503 | { XK_F11, /* F47 */ Mod4Mask, "\033[23;6~", 0, 0},
504 | { XK_F11, /* F59 */ Mod1Mask, "\033[23;3~", 0, 0},
505 | { XK_F12, XK_NO_MOD, "\033[24~", 0, 0},
506 | { XK_F12, /* F24 */ ShiftMask, "\033[24;2~", 0, 0},
507 | { XK_F12, /* F36 */ ControlMask, "\033[24;5~", 0, 0},
508 | { XK_F12, /* F48 */ Mod4Mask, "\033[24;6~", 0, 0},
509 | { XK_F12, /* F60 */ Mod1Mask, "\033[24;3~", 0, 0},
510 | { XK_F13, XK_NO_MOD, "\033[1;2P", 0, 0},
511 | { XK_F14, XK_NO_MOD, "\033[1;2Q", 0, 0},
512 | { XK_F15, XK_NO_MOD, "\033[1;2R", 0, 0},
513 | { XK_F16, XK_NO_MOD, "\033[1;2S", 0, 0},
514 | { XK_F17, XK_NO_MOD, "\033[15;2~", 0, 0},
515 | { XK_F18, XK_NO_MOD, "\033[17;2~", 0, 0},
516 | { XK_F19, XK_NO_MOD, "\033[18;2~", 0, 0},
517 | { XK_F20, XK_NO_MOD, "\033[19;2~", 0, 0},
518 | { XK_F21, XK_NO_MOD, "\033[20;2~", 0, 0},
519 | { XK_F22, XK_NO_MOD, "\033[21;2~", 0, 0},
520 | { XK_F23, XK_NO_MOD, "\033[23;2~", 0, 0},
521 | { XK_F24, XK_NO_MOD, "\033[24;2~", 0, 0},
522 | { XK_F25, XK_NO_MOD, "\033[1;5P", 0, 0},
523 | { XK_F26, XK_NO_MOD, "\033[1;5Q", 0, 0},
524 | { XK_F27, XK_NO_MOD, "\033[1;5R", 0, 0},
525 | { XK_F28, XK_NO_MOD, "\033[1;5S", 0, 0},
526 | { XK_F29, XK_NO_MOD, "\033[15;5~", 0, 0},
527 | { XK_F30, XK_NO_MOD, "\033[17;5~", 0, 0},
528 | { XK_F31, XK_NO_MOD, "\033[18;5~", 0, 0},
529 | { XK_F32, XK_NO_MOD, "\033[19;5~", 0, 0},
530 | { XK_F33, XK_NO_MOD, "\033[20;5~", 0, 0},
531 | { XK_F34, XK_NO_MOD, "\033[21;5~", 0, 0},
532 | { XK_F35, XK_NO_MOD, "\033[23;5~", 0, 0},
533 | };
534 |
535 | /*
536 | * Selection types' masks.
537 | * Use the same masks as usual.
538 | * Button1Mask is always unset, to make masks match between ButtonPress.
539 | * ButtonRelease and MotionNotify.
540 | * If no match is found, regular selection is used.
541 | */
542 | static uint selmasks[] = {
543 | [SEL_RECTANGULAR] = Mod1Mask,
544 | };
545 |
546 | /*
547 | * Printable characters in ASCII, used to estimate the advance width
548 | * of single wide characters.
549 | */
550 | static char ascii_printable[] =
551 | " !\"#$%&'()*+,-./0123456789:;<=>?"
552 | "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
553 | "`abcdefghijklmnopqrstuvwxyz{|}~";
554 |
--------------------------------------------------------------------------------
/st/config.mk:
--------------------------------------------------------------------------------
1 | # st version
2 | VERSION = 0.8.4
3 |
4 | # Customize below to fit your system
5 |
6 | # paths
7 | PREFIX = /usr/local
8 | MANPREFIX = $(PREFIX)/share/man
9 |
10 | X11INC = /usr/X11R6/include
11 | X11LIB = /usr/X11R6/lib
12 |
13 | PKG_CONFIG = pkg-config
14 |
15 | # includes and libs
16 | INCS = -I$(X11INC) \
17 | `$(PKG_CONFIG) --cflags fontconfig` \
18 | `$(PKG_CONFIG) --cflags freetype2` \
19 | `$(PKG_CONFIG) --cflags harfbuzz`
20 | LIBS = -L$(X11LIB) -lm -lrt -lX11 -lutil -lXft -lXrender\
21 | `$(PKG_CONFIG) --libs fontconfig` \
22 | `$(PKG_CONFIG) --libs freetype2` \
23 | `$(PKG_CONFIG) --libs harfbuzz`
24 |
25 | # flags
26 | STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
27 | STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
28 | STLDFLAGS = $(LIBS) $(LDFLAGS)
29 |
30 | # OpenBSD:
31 | #CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600 -D_BSD_SOURCE
32 | #LIBS = -L$(X11LIB) -lm -lX11 -lutil -lXft \
33 | # `$(PKG_CONFIG) --libs fontconfig` \
34 | # `$(PKG_CONFIG) --libs freetype2`
35 |
36 | # compiler and linker
37 | # CC = c99
38 |
--------------------------------------------------------------------------------
/st/hb.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | #include "st.h"
9 |
10 | void hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length);
11 | hb_font_t *hbfindfont(XftFont *match);
12 |
13 | typedef struct {
14 | XftFont *match;
15 | hb_font_t *font;
16 | } HbFontMatch;
17 |
18 | static int hbfontslen = 0;
19 | static HbFontMatch *hbfontcache = NULL;
20 |
21 | void
22 | hbunloadfonts()
23 | {
24 | for (int i = 0; i < hbfontslen; i++) {
25 | hb_font_destroy(hbfontcache[i].font);
26 | XftUnlockFace(hbfontcache[i].match);
27 | }
28 |
29 | if (hbfontcache != NULL) {
30 | free(hbfontcache);
31 | hbfontcache = NULL;
32 | }
33 | hbfontslen = 0;
34 | }
35 |
36 | hb_font_t *
37 | hbfindfont(XftFont *match)
38 | {
39 | for (int i = 0; i < hbfontslen; i++) {
40 | if (hbfontcache[i].match == match)
41 | return hbfontcache[i].font;
42 | }
43 |
44 | /* Font not found in cache, caching it now. */
45 | hbfontcache = realloc(hbfontcache, sizeof(HbFontMatch) * (hbfontslen + 1));
46 | FT_Face face = XftLockFace(match);
47 | hb_font_t *font = hb_ft_font_create(face, NULL);
48 | if (font == NULL)
49 | die("Failed to load Harfbuzz font.");
50 |
51 | hbfontcache[hbfontslen].match = match;
52 | hbfontcache[hbfontslen].font = font;
53 | hbfontslen += 1;
54 |
55 | return font;
56 | }
57 |
58 | void
59 | hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y)
60 | {
61 | int start = 0, length = 1, gstart = 0;
62 | hb_codepoint_t *codepoints = calloc(len, sizeof(hb_codepoint_t));
63 |
64 | for (int idx = 1, specidx = 1; idx < len; idx++) {
65 | if (glyphs[idx].mode & ATTR_WDUMMY) {
66 | length += 1;
67 | continue;
68 | }
69 |
70 | if (specs[specidx].font != specs[start].font || ATTRCMP(glyphs[gstart], glyphs[idx]) || selected(x + idx, y) != selected(x + gstart, y)) {
71 | hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length);
72 |
73 | /* Reset the sequence. */
74 | length = 1;
75 | start = specidx;
76 | gstart = idx;
77 | } else {
78 | length += 1;
79 | }
80 |
81 | specidx++;
82 | }
83 |
84 | /* EOL. */
85 | hbtransformsegment(specs[start].font, glyphs, codepoints, gstart, length);
86 |
87 | /* Apply the transformation to glyph specs. */
88 | for (int i = 0, specidx = 0; i < len; i++) {
89 | if (glyphs[i].mode & ATTR_WDUMMY)
90 | continue;
91 | if (glyphs[i].mode & ATTR_BOXDRAW) {
92 | specidx++;
93 | continue;
94 | }
95 |
96 | if (codepoints[i] != specs[specidx].glyph)
97 | ((Glyph *)glyphs)[i].mode |= ATTR_LIGA;
98 |
99 | specs[specidx++].glyph = codepoints[i];
100 | }
101 |
102 | free(codepoints);
103 | }
104 |
105 | void
106 | hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length)
107 | {
108 | hb_font_t *font = hbfindfont(xfont);
109 | if (font == NULL)
110 | return;
111 |
112 | Rune rune;
113 | ushort mode = USHRT_MAX;
114 | hb_buffer_t *buffer = hb_buffer_create();
115 | hb_buffer_set_direction(buffer, HB_DIRECTION_LTR);
116 |
117 | /* Fill buffer with codepoints. */
118 | for (int i = start; i < (start+length); i++) {
119 | rune = string[i].u;
120 | mode = string[i].mode;
121 | if (mode & ATTR_WDUMMY)
122 | rune = 0x0020;
123 | hb_buffer_add_codepoints(buffer, &rune, 1, 0, 1);
124 | }
125 |
126 | /* Shape the segment. */
127 | hb_shape(font, buffer, NULL, 0);
128 |
129 | /* Get new glyph info. */
130 | hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);
131 |
132 | /* Write new codepoints. */
133 | for (int i = 0; i < length; i++) {
134 | hb_codepoint_t gid = info[i].codepoint;
135 | codepoints[start+i] = gid;
136 | }
137 |
138 | /* Cleanup. */
139 | hb_buffer_destroy(buffer);
140 | }
141 |
--------------------------------------------------------------------------------
/st/hb.h:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | void hbunloadfonts();
6 | void hbtransform(XftGlyphFontSpec *, const Glyph *, size_t, int, int);
7 |
8 |
--------------------------------------------------------------------------------
/st/st-copyout:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | # Using external pipe with st, give a dmenu prompt of recent commands,
3 | # allowing the user to copy the output of one.
4 | # xclip required for this script.
5 | # By Jaywalker and Luke
6 | tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX)
7 | trap 'rm "$tmpfile"' 0 1 15
8 | sed -n "w $tmpfile"
9 | sed -i 's/\x0//g' "$tmpfile"
10 | ps1="$(grep "\S" "$tmpfile" | tail -n 1 | sed 's/^\s*//' | cut -d' ' -f1)"
11 | chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | dmenu -p "Copy which command's output?" -i -l 10 | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
12 | eps1="$(echo "$ps1" | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
13 | awk "/^$chosen$/{p=1;print;next} p&&/$eps1/{p=0};p" "$tmpfile" | xclip -selection clipboard
14 |
--------------------------------------------------------------------------------
/st/st-urlhandler:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
4 |
5 | urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars:
6 | grep -aEo "$urlregex" | # grep only urls as defined above.
7 | uniq | # Ignore neighboring duplicates.
8 | sed "s/\(\.\|,\|;\|\!\\|\?\)$//;
9 | s/^www./http:\/\/www\./")" # xdg-open will not detect url without http
10 |
11 | [ -z "$urls" ] && exit 1
12 |
13 | while getopts "hoc" o; do case "${o}" in
14 | h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;;
15 | o) chosen="$(echo "$urls" | dmenu -i -p 'Follow which url?' -l 10)"
16 | setsid xdg-open "$chosen" >/dev/null 2>&1 & ;;
17 | c) echo "$urls" | dmenu -i -p 'Copy which url?' -l 10 | tr -d '\n' | xclip -selection clipboard ;;
18 | *) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;;
19 | esac done
20 |
--------------------------------------------------------------------------------
/st/st.1:
--------------------------------------------------------------------------------
1 | .TH ST 1 st\-VERSION
2 | .SH NAME
3 | st \- simple terminal
4 | .SH SYNOPSIS
5 | .B st
6 | .RB [ \-aiv ]
7 | .RB [ \-c
8 | .IR class ]
9 | .RB [ \-f
10 | .IR font ]
11 | .RB [ \-g
12 | .IR geometry ]
13 | .RB [ \-n
14 | .IR name ]
15 | .RB [ \-o
16 | .IR iofile ]
17 | .RB [ \-T
18 | .IR title ]
19 | .RB [ \-t
20 | .IR title ]
21 | .RB [ \-l
22 | .IR line ]
23 | .RB [ \-w
24 | .IR windowid ]
25 | .RB [[ \-e ]
26 | .IR command
27 | .RI [ arguments ...]]
28 | .PP
29 | .B st
30 | .RB [ \-aiv ]
31 | .RB [ \-c
32 | .IR class ]
33 | .RB [ \-f
34 | .IR font ]
35 | .RB [ \-g
36 | .IR geometry ]
37 | .RB [ \-n
38 | .IR name ]
39 | .RB [ \-o
40 | .IR iofile ]
41 | .RB [ \-T
42 | .IR title ]
43 | .RB [ \-t
44 | .IR title ]
45 | .RB [ \-w
46 | .IR windowid ]
47 | .RB \-l
48 | .IR line
49 | .RI [ stty_args ...]
50 | .SH DESCRIPTION
51 | .B st
52 | is a simple terminal emulator.
53 | .SH OPTIONS
54 | .TP
55 | .B \-a
56 | disable alternate screens in terminal
57 | .TP
58 | .BI \-c " class"
59 | defines the window class (default $TERM).
60 | .TP
61 | .BI \-f " font"
62 | defines the
63 | .I font
64 | to use when st is run.
65 | .TP
66 | .BI \-g " geometry"
67 | defines the X11 geometry string.
68 | The form is [=][{xX}][{+-}{+-}]. See
69 | .BR XParseGeometry (3)
70 | for further details.
71 | .TP
72 | .B \-i
73 | will fixate the position given with the -g option.
74 | .TP
75 | .BI \-n " name"
76 | defines the window instance name (default $TERM).
77 | .TP
78 | .BI \-o " iofile"
79 | writes all the I/O to
80 | .I iofile.
81 | This feature is useful when recording st sessions. A value of "-" means
82 | standard output.
83 | .TP
84 | .BI \-T " title"
85 | defines the window title (default 'st').
86 | .TP
87 | .BI \-t " title"
88 | defines the window title (default 'st').
89 | .TP
90 | .BI \-w " windowid"
91 | embeds st within the window identified by
92 | .I windowid
93 | .TP
94 | .BI \-l " line"
95 | use a tty
96 | .I line
97 | instead of a pseudo terminal.
98 | .I line
99 | should be a (pseudo-)serial device (e.g. /dev/ttyS0 on Linux for serial port
100 | 0).
101 | When this flag is given
102 | remaining arguments are used as flags for
103 | .BR stty(1).
104 | By default st initializes the serial line to 8 bits, no parity, 1 stop bit
105 | and a 38400 baud rate. The speed is set by appending it as last argument
106 | (e.g. 'st -l /dev/ttyS0 115200'). Arguments before the last one are
107 | .BR stty(1)
108 | flags. If you want to set odd parity on 115200 baud use for example 'st -l
109 | /dev/ttyS0 parenb parodd 115200'. Set the number of bits by using for
110 | example 'st -l /dev/ttyS0 cs7 115200'. See
111 | .BR stty(1)
112 | for more arguments and cases.
113 | .TP
114 | .B \-v
115 | prints version information to stderr, then exits.
116 | .TP
117 | .BI \-e " command " [ " arguments " "... ]"
118 | st executes
119 | .I command
120 | instead of the shell. If this is used it
121 | .B must be the last option
122 | on the command line, as in xterm / rxvt.
123 | This option is only intended for compatibility,
124 | and all the remaining arguments are used as a command
125 | even without it.
126 | .SH SHORTCUTS
127 | .TP
128 | .B Alt-j/k or Alt-Up/Down or Alt-Mouse Wheel
129 | Scroll up/down one line at a time.
130 | .TP
131 | .B Alt-u/d or Alt-Page Up/Page Down
132 | Scroll up/down one screen at a time.
133 | .TP
134 | .B Alt-Shift-k/j or Alt-Shift-Page Up/Page Down or Alt-Shift-Mouse Wheel
135 | Increase or decrease font size.
136 | .TP
137 | .B Alt-Home
138 | Reset to default font size.
139 | .TP
140 | .B Shift-Insert or Alt-v
141 | Paste from clipboard.
142 | .TP
143 | .B Alt-c
144 | Copy to clipboard.
145 | .TP
146 | .B Alt-p
147 | Paste/input primary selection.
148 | .TP
149 | .B Alt-l
150 | Show dmenu menu of all URLs on screen and choose one to open.
151 | .TP
152 | .B Alt-y
153 | Show dmenu menu of all URLs on screen and choose one to copy.
154 | .TP
155 | .B Alt-o
156 | Show dmenu menu of all recently run commands and copy the output of the chosen command to the clipboard.
157 | .I xclip
158 | required.
159 | .TP
160 | .B Alt-a/s
161 | Increase or decrease opacity/alpha value (make window more or less transparent).
162 | .TP
163 | .B Break
164 | Send a break in the serial line.
165 | Break key is obtained in PC keyboards
166 | pressing at the same time control and pause.
167 | .TP
168 | .B Ctrl-Print Screen
169 | Toggle if st should print to the
170 | .I iofile.
171 | .TP
172 | .B Shift-Print Screen
173 | Print the full screen to the
174 | .I iofile.
175 | .TP
176 | .B Print Screen
177 | Print the selection to the
178 | .I iofile.
179 | .SH CUSTOMIZATION
180 | .B st
181 | can be customized by creating a custom config.h and (re)compiling the source
182 | code. This keeps it fast, secure and simple.
183 | .SH AUTHORS
184 | See the LICENSE file for the authors.
185 | .SH LICENSE
186 | See the LICENSE file for the terms of redistribution.
187 | .SH SEE ALSO
188 | .BR tabbed (1),
189 | .BR utmp (1),
190 | .BR stty (1),
191 | .BR scroll (1)
192 | .SH BUGS
193 | See the TODO file in the distribution.
194 |
--------------------------------------------------------------------------------
/st/st.h:
--------------------------------------------------------------------------------
1 | /* See LICENSE for license details. */
2 |
3 | #include
4 | #include
5 |
6 | /* macros */
7 | #define MIN(a, b) ((a) < (b) ? (a) : (b))
8 | #define MAX(a, b) ((a) < (b) ? (b) : (a))
9 | #define LEN(a) (sizeof(a) / sizeof(a)[0])
10 | #define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))
11 | #define DIVCEIL(n, d) (((n) + ((d) - 1)) / (d))
12 | #define DEFAULT(a, b) (a) = (a) ? (a) : (b)
13 | #define LIMIT(x, a, b) (x) = (x) < (a) ? (a) : (x) > (b) ? (b) : (x)
14 | #define ATTRCMP(a, b) (((a).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) != ((b).mode & (~ATTR_WRAP) & (~ATTR_LIGA)) || \
15 | (a).fg != (b).fg || \
16 | (a).bg != (b).bg)
17 | #define TIMEDIFF(t1, t2) ((t1.tv_sec-t2.tv_sec)*1000 + \
18 | (t1.tv_nsec-t2.tv_nsec)/1E6)
19 | #define MODBIT(x, set, bit) ((set) ? ((x) |= (bit)) : ((x) &= ~(bit)))
20 |
21 | #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b))
22 | #define IS_TRUECOL(x) (1 << 24 & (x))
23 |
24 | enum glyph_attribute {
25 | ATTR_NULL = 0,
26 | ATTR_BOLD = 1 << 0,
27 | ATTR_FAINT = 1 << 1,
28 | ATTR_ITALIC = 1 << 2,
29 | ATTR_UNDERLINE = 1 << 3,
30 | ATTR_BLINK = 1 << 4,
31 | ATTR_REVERSE = 1 << 5,
32 | ATTR_INVISIBLE = 1 << 6,
33 | ATTR_STRUCK = 1 << 7,
34 | ATTR_WRAP = 1 << 8,
35 | ATTR_WIDE = 1 << 9,
36 | ATTR_WDUMMY = 1 << 10,
37 | ATTR_BOXDRAW = 1 << 11,
38 | ATTR_LIGA = 1 << 12,
39 | ATTR_BOLD_FAINT = ATTR_BOLD | ATTR_FAINT,
40 | };
41 |
42 | enum selection_mode {
43 | SEL_IDLE = 0,
44 | SEL_EMPTY = 1,
45 | SEL_READY = 2
46 | };
47 |
48 | enum selection_type {
49 | SEL_REGULAR = 1,
50 | SEL_RECTANGULAR = 2
51 | };
52 |
53 | enum selection_snap {
54 | SNAP_WORD = 1,
55 | SNAP_LINE = 2
56 | };
57 |
58 | typedef unsigned char uchar;
59 | typedef unsigned int uint;
60 | typedef unsigned long ulong;
61 | typedef unsigned short ushort;
62 |
63 | typedef uint_least32_t Rune;
64 |
65 | #define Glyph Glyph_
66 | typedef struct {
67 | Rune u; /* character code */
68 | ushort mode; /* attribute flags */
69 | uint32_t fg; /* foreground */
70 | uint32_t bg; /* background */
71 | } Glyph;
72 |
73 | typedef Glyph *Line;
74 |
75 | typedef union {
76 | int i;
77 | uint ui;
78 | float f;
79 | const void *v;
80 | const char *s;
81 | } Arg;
82 |
83 | void die(const char *, ...);
84 | void redraw(void);
85 | void draw(void);
86 |
87 | void externalpipe(const Arg *);
88 | void kscrolldown(const Arg *);
89 | void kscrollup(const Arg *);
90 | void printscreen(const Arg *);
91 | void printsel(const Arg *);
92 | void sendbreak(const Arg *);
93 | void toggleprinter(const Arg *);
94 |
95 | int tattrset(int);
96 | void tnew(int, int);
97 | void tresize(int, int);
98 | void tsetdirtattr(int);
99 | void ttyhangup(void);
100 | int ttynew(char *, char *, char *, char **);
101 | size_t ttyread(void);
102 | void ttyresize(int, int);
103 | void ttywrite(const char *, size_t, int);
104 |
105 | void resettitle(void);
106 |
107 | void selclear(void);
108 | void selinit(void);
109 | void selstart(int, int, int);
110 | void selextend(int, int, int, int);
111 | int selected(int, int);
112 | char *getsel(void);
113 |
114 | size_t utf8encode(Rune, char *);
115 |
116 | void *xmalloc(size_t);
117 | void *xrealloc(void *, size_t);
118 | char *xstrdup(char *);
119 |
120 | int isboxdraw(Rune);
121 | ushort boxdrawindex(const Glyph *);
122 | #ifdef XFT_VERSION
123 | /* only exposed to x.c, otherwise we'll need Xft.h for the types */
124 | void boxdraw_xinit(Display *, Colormap, XftDraw *, Visual *);
125 | void drawboxes(int, int, int, int, XftColor *, XftColor *, const XftGlyphFontSpec *, int);
126 | #endif
127 |
128 | /* config.h globals */
129 | extern char *utmp;
130 | extern char *scroll;
131 | extern char *stty_args;
132 | extern char *vtiden;
133 | extern wchar_t *worddelimiters;
134 | extern int allowaltscreen;
135 | extern int allowwindowops;
136 | extern char *termname;
137 | extern unsigned int tabspaces;
138 | extern unsigned int defaultfg;
139 | extern unsigned int defaultbg;
140 | extern float alpha;
141 | extern const int boxdraw, boxdraw_bold, boxdraw_braille;
142 |
--------------------------------------------------------------------------------
/st/st.info:
--------------------------------------------------------------------------------
1 | st-mono| simpleterm monocolor,
2 | acsc=+C\,D-A.B0E``aaffgghFiGjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
3 | am,
4 | bce,
5 | bel=^G,
6 | blink=\E[5m,
7 | bold=\E[1m,
8 | cbt=\E[Z,
9 | cvvis=\E[?25h,
10 | civis=\E[?25l,
11 | clear=\E[H\E[2J,
12 | cnorm=\E[?12l\E[?25h,
13 | colors#2,
14 | cols#80,
15 | cr=^M,
16 | csr=\E[%i%p1%d;%p2%dr,
17 | cub=\E[%p1%dD,
18 | cub1=^H,
19 | cud1=^J,
20 | cud=\E[%p1%dB,
21 | cuf1=\E[C,
22 | cuf=\E[%p1%dC,
23 | cup=\E[%i%p1%d;%p2%dH,
24 | cuu1=\E[A,
25 | cuu=\E[%p1%dA,
26 | dch=\E[%p1%dP,
27 | dch1=\E[P,
28 | dim=\E[2m,
29 | dl=\E[%p1%dM,
30 | dl1=\E[M,
31 | ech=\E[%p1%dX,
32 | ed=\E[J,
33 | el=\E[K,
34 | el1=\E[1K,
35 | enacs=\E)0,
36 | flash=\E[?5h$<80/>\E[?5l,
37 | fsl=^G,
38 | home=\E[H,
39 | hpa=\E[%i%p1%dG,
40 | hs,
41 | ht=^I,
42 | hts=\EH,
43 | ich=\E[%p1%d@,
44 | il1=\E[L,
45 | il=\E[%p1%dL,
46 | ind=^J,
47 | indn=\E[%p1%dS,
48 | invis=\E[8m,
49 | is2=\E[4l\E>\E[?1034l,
50 | it#8,
51 | kel=\E[1;2F,
52 | ked=\E[1;5F,
53 | ka1=\E[1~,
54 | ka3=\E[5~,
55 | kc1=\E[4~,
56 | kc3=\E[6~,
57 | kbs=\177,
58 | kcbt=\E[Z,
59 | kb2=\EOu,
60 | kcub1=\EOD,
61 | kcud1=\EOB,
62 | kcuf1=\EOC,
63 | kcuu1=\EOA,
64 | kDC=\E[3;2~,
65 | kent=\EOM,
66 | kEND=\E[1;2F,
67 | kIC=\E[2;2~,
68 | kNXT=\E[6;2~,
69 | kPRV=\E[5;2~,
70 | kHOM=\E[1;2H,
71 | kLFT=\E[1;2D,
72 | kRIT=\E[1;2C,
73 | kind=\E[1;2B,
74 | kri=\E[1;2A,
75 | kclr=\E[3;5~,
76 | kdl1=\E[3;2~,
77 | kdch1=\E[3~,
78 | kich1=\E[2~,
79 | kend=\E[4~,
80 | kf1=\EOP,
81 | kf2=\EOQ,
82 | kf3=\EOR,
83 | kf4=\EOS,
84 | kf5=\E[15~,
85 | kf6=\E[17~,
86 | kf7=\E[18~,
87 | kf8=\E[19~,
88 | kf9=\E[20~,
89 | kf10=\E[21~,
90 | kf11=\E[23~,
91 | kf12=\E[24~,
92 | kf13=\E[1;2P,
93 | kf14=\E[1;2Q,
94 | kf15=\E[1;2R,
95 | kf16=\E[1;2S,
96 | kf17=\E[15;2~,
97 | kf18=\E[17;2~,
98 | kf19=\E[18;2~,
99 | kf20=\E[19;2~,
100 | kf21=\E[20;2~,
101 | kf22=\E[21;2~,
102 | kf23=\E[23;2~,
103 | kf24=\E[24;2~,
104 | kf25=\E[1;5P,
105 | kf26=\E[1;5Q,
106 | kf27=\E[1;5R,
107 | kf28=\E[1;5S,
108 | kf29=\E[15;5~,
109 | kf30=\E[17;5~,
110 | kf31=\E[18;5~,
111 | kf32=\E[19;5~,
112 | kf33=\E[20;5~,
113 | kf34=\E[21;5~,
114 | kf35=\E[23;5~,
115 | kf36=\E[24;5~,
116 | kf37=\E[1;6P,
117 | kf38=\E[1;6Q,
118 | kf39=\E[1;6R,
119 | kf40=\E[1;6S,
120 | kf41=\E[15;6~,
121 | kf42=\E[17;6~,
122 | kf43=\E[18;6~,
123 | kf44=\E[19;6~,
124 | kf45=\E[20;6~,
125 | kf46=\E[21;6~,
126 | kf47=\E[23;6~,
127 | kf48=\E[24;6~,
128 | kf49=\E[1;3P,
129 | kf50=\E[1;3Q,
130 | kf51=\E[1;3R,
131 | kf52=\E[1;3S,
132 | kf53=\E[15;3~,
133 | kf54=\E[17;3~,
134 | kf55=\E[18;3~,
135 | kf56=\E[19;3~,
136 | kf57=\E[20;3~,
137 | kf58=\E[21;3~,
138 | kf59=\E[23;3~,
139 | kf60=\E[24;3~,
140 | kf61=\E[1;4P,
141 | kf62=\E[1;4Q,
142 | kf63=\E[1;4R,
143 | khome=\E[1~,
144 | kil1=\E[2;5~,
145 | krmir=\E[2;2~,
146 | knp=\E[6~,
147 | kmous=\E[M,
148 | kpp=\E[5~,
149 | lines#24,
150 | mir,
151 | msgr,
152 | npc,
153 | op=\E[39;49m,
154 | pairs#64,
155 | mc0=\E[i,
156 | mc4=\E[4i,
157 | mc5=\E[5i,
158 | rc=\E8,
159 | rev=\E[7m,
160 | ri=\EM,
161 | rin=\E[%p1%dT,
162 | ritm=\E[23m,
163 | rmacs=\E(B,
164 | rmcup=\E[?1049l,
165 | rmir=\E[4l,
166 | rmkx=\E[?1l\E>,
167 | rmso=\E[27m,
168 | rmul=\E[24m,
169 | rs1=\Ec,
170 | rs2=\E[4l\E>\E[?1034l,
171 | sc=\E7,
172 | sitm=\E[3m,
173 | sgr0=\E[0m,
174 | smacs=\E(0,
175 | smcup=\E[?1049h,
176 | smir=\E[4h,
177 | smkx=\E[?1h\E=,
178 | smso=\E[7m,
179 | smul=\E[4m,
180 | tbc=\E[3g,
181 | tsl=\E]0;,
182 | xenl,
183 | vpa=\E[%i%p1%dd,
184 | # XTerm extensions
185 | rmxx=\E[29m,
186 | smxx=\E[9m,
187 | # disabled rep for now: causes some issues with older ncurses versions.
188 | # rep=%p1%c\E[%p2%{1}%-%db,
189 | # tmux extensions, see TERMINFO EXTENSIONS in tmux(1)
190 | Tc,
191 | Ms=\E]52;%p1%s;%p2%s\007,
192 | Se=\E[2 q,
193 | Ss=\E[%p1%d q,
194 |
195 | st| simpleterm,
196 | use=st-mono,
197 | colors#8,
198 | setab=\E[4%p1%dm,
199 | setaf=\E[3%p1%dm,
200 | setb=\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
201 | setf=\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m,
202 | 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,
203 |
204 | st-256color| simpleterm with 256 colors,
205 | use=st,
206 | ccc,
207 | colors#256,
208 | oc=\E]104\007,
209 | pairs#32767,
210 | # Nicked from xterm-256color
211 | initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
212 | setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
213 | setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
214 |
215 | st-meta| simpleterm with meta key,
216 | use=st,
217 | km,
218 | rmm=\E[?1034l,
219 | smm=\E[?1034h,
220 | rs2=\E[4l\E>\E[?1034h,
221 | is2=\E[4l\E>\E[?1034h,
222 |
223 | st-meta-256color| simpleterm with meta key and 256 colors,
224 | use=st-256color,
225 | km,
226 | rmm=\E[?1034l,
227 | smm=\E[?1034h,
228 | rs2=\E[4l\E>\E[?1034h,
229 | is2=\E[4l\E>\E[?1034h,
230 |
231 | st-bs| simpleterm with backspace as backspace,
232 | use=st,
233 | kbs=\010,
234 | kdch1=\177,
235 |
236 | st-bs-256color| simpleterm with backspace as backspace and 256colors,
237 | use=st-256color,
238 | kbs=\010,
239 | kdch1=\177,
240 |
--------------------------------------------------------------------------------
/st/win.h:
--------------------------------------------------------------------------------
1 | /* See LICENSE for license details. */
2 |
3 | enum win_mode {
4 | MODE_VISIBLE = 1 << 0,
5 | MODE_FOCUSED = 1 << 1,
6 | MODE_APPKEYPAD = 1 << 2,
7 | MODE_MOUSEBTN = 1 << 3,
8 | MODE_MOUSEMOTION = 1 << 4,
9 | MODE_REVERSE = 1 << 5,
10 | MODE_KBDLOCK = 1 << 6,
11 | MODE_HIDE = 1 << 7,
12 | MODE_APPCURSOR = 1 << 8,
13 | MODE_MOUSESGR = 1 << 9,
14 | MODE_8BIT = 1 << 10,
15 | MODE_BLINK = 1 << 11,
16 | MODE_FBLINK = 1 << 12,
17 | MODE_FOCUS = 1 << 13,
18 | MODE_MOUSEX10 = 1 << 14,
19 | MODE_MOUSEMANY = 1 << 15,
20 | MODE_BRCKTPASTE = 1 << 16,
21 | MODE_NUMLOCK = 1 << 17,
22 | MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
23 | |MODE_MOUSEMANY,
24 | };
25 |
26 | void xbell(void);
27 | void xclipcopy(void);
28 | void xdrawcursor(int, int, Glyph, int, int, Glyph, Line, int);
29 | void xdrawline(Line, int, int, int);
30 | void xfinishdraw(void);
31 | void xloadcols(void);
32 | int xsetcolorname(int, const char *);
33 | void xseticontitle(char *);
34 | void xsettitle(char *);
35 | int xsetcursor(int);
36 | void xsetmode(int, unsigned int);
37 | void xsetpointermotion(int);
38 | void xsetsel(char *);
39 | int xstartdraw(void);
40 | void xximspot(int, int);
41 |
--------------------------------------------------------------------------------