@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MAIN_DIR=$PWD
|
||||||
|
|
||||||
|
source $MAIN_DIR/programs/os/debian_install.sh
|
||||||
|
source $MAIN_DIR/programs/os/arch_install.sh
|
||||||
|
source $MAIN_DIR/programs/os/raspberry_install.sh
|
||||||
|
|
||||||
|
sleepTime=0.3
|
||||||
|
|
||||||
|
os_list=(debian arch raspberry)
|
||||||
|
|
||||||
|
common_programs_list=(\
|
||||||
|
htop \
|
||||||
|
tmux \
|
||||||
|
git \
|
||||||
|
fish \
|
||||||
|
mc \
|
||||||
|
wget \
|
||||||
|
sudo \
|
||||||
|
unzip \
|
||||||
|
cmake \
|
||||||
|
make \
|
||||||
|
gcc \
|
||||||
|
exa)
|
||||||
|
|
||||||
|
default_installs_debian=(qutebrowser)
|
||||||
|
default_installs_arch=(qutebrowser)
|
||||||
|
default_installs_raspberry=(chromium)
|
||||||
|
|
||||||
|
os_list_count=${#os_list[@]}
|
||||||
|
|
@ -0,0 +1,870 @@
|
|||||||
|
# Configuration for Alacritty, the GPU enhanced terminal emulator.
|
||||||
|
|
||||||
|
# Any items in the `env` entry below will be added as
|
||||||
|
# environment variables. Some entries may override variables
|
||||||
|
# set by alacritty itself.
|
||||||
|
env:
|
||||||
|
# TERM variable
|
||||||
|
#
|
||||||
|
# This value is used to set the `$TERM` environment variable for
|
||||||
|
# each instance of Alacritty. If it is not present, alacritty will
|
||||||
|
# check the local terminfo database and use `alacritty` if it is
|
||||||
|
# available, otherwise `xterm-256color` is used.
|
||||||
|
TERM: xterm-256color
|
||||||
|
|
||||||
|
window:
|
||||||
|
# Window dimensions (changes require restart)
|
||||||
|
#
|
||||||
|
# Specified in number of columns/lines, not pixels.
|
||||||
|
# If both are `0`, this setting is ignored.
|
||||||
|
#dimensions:
|
||||||
|
# columns: 0
|
||||||
|
# lines: 0
|
||||||
|
|
||||||
|
# Window position (changes require restart)
|
||||||
|
#
|
||||||
|
# Specified in number of pixels.
|
||||||
|
# If the position is not set, the window manager will handle the placement.
|
||||||
|
#position:
|
||||||
|
# x: 0
|
||||||
|
# y: 0
|
||||||
|
|
||||||
|
# Window padding (changes require restart)
|
||||||
|
#
|
||||||
|
# Blank space added around the window in pixels. This padding is scaled
|
||||||
|
# by DPI and the specified value is always added at both opposing sides.
|
||||||
|
padding:
|
||||||
|
x: 6
|
||||||
|
y: 6
|
||||||
|
|
||||||
|
# Spread additional padding evenly around the terminal content.
|
||||||
|
dynamic_padding: false
|
||||||
|
|
||||||
|
# Background opacity
|
||||||
|
#
|
||||||
|
# Window opacity as a floating point number from `0.0` to `1.0`.
|
||||||
|
# The value `0.0` is completely transparent and `1.0` is opaque.
|
||||||
|
opacity: 0.8
|
||||||
|
# opacity: 0.80
|
||||||
|
|
||||||
|
# Window decorations
|
||||||
|
#
|
||||||
|
# Values for `decorations`:
|
||||||
|
# - full: Borders and title bar
|
||||||
|
# - none: Neither borders nor title bar
|
||||||
|
#
|
||||||
|
# Values for `decorations` (macOS only):
|
||||||
|
# - transparent: Title bar, transparent background and title bar buttons
|
||||||
|
# - buttonless: Title bar, transparent background, but no title bar buttons
|
||||||
|
#decorations: full
|
||||||
|
|
||||||
|
# Startup Mode (changes require restart)
|
||||||
|
#
|
||||||
|
# Values for `startup_mode`:
|
||||||
|
# - Windowed
|
||||||
|
# - Maximized
|
||||||
|
# - Fullscreen
|
||||||
|
#
|
||||||
|
# Values for `startup_mode` (macOS only):
|
||||||
|
# - SimpleFullscreen
|
||||||
|
#startup_mode: Windowed
|
||||||
|
|
||||||
|
# Window title
|
||||||
|
title: Alacritty
|
||||||
|
|
||||||
|
# Window class (Linux/BSD only):
|
||||||
|
class:
|
||||||
|
# Application instance name
|
||||||
|
instance: Alacritty
|
||||||
|
# General application class
|
||||||
|
general: Alacritty
|
||||||
|
|
||||||
|
# GTK theme variant (Linux/BSD only)
|
||||||
|
#
|
||||||
|
# Override the variant of the GTK theme. Commonly supported values are `dark` and `light`.
|
||||||
|
# Set this to `None` to use the default theme variant.
|
||||||
|
#gtk_theme_variant: None
|
||||||
|
|
||||||
|
scrolling:
|
||||||
|
# Maximum number of lines in the scrollback buffer.
|
||||||
|
# Specifying '0' will disable scrolling.
|
||||||
|
history: 5000
|
||||||
|
|
||||||
|
# Number of lines the viewport will move for every line scrolled when
|
||||||
|
# scrollback is enabled (history > 0).
|
||||||
|
#multiplier: 3
|
||||||
|
|
||||||
|
# Scroll to the bottom when new text is written to the terminal.
|
||||||
|
#auto_scroll: false
|
||||||
|
|
||||||
|
# Spaces per Tab (changes require restart)
|
||||||
|
#
|
||||||
|
# This setting defines the width of a tab in cells.
|
||||||
|
#
|
||||||
|
# Some applications, like Emacs, rely on knowing about the width of a tab.
|
||||||
|
# To prevent unexpected behavior in these applications, it's also required to
|
||||||
|
# change the `it` value in terminfo when altering this setting.
|
||||||
|
#tabspaces: 8
|
||||||
|
|
||||||
|
# Font configuration
|
||||||
|
font:
|
||||||
|
# Normal (roman) font face
|
||||||
|
normal:
|
||||||
|
# Font family
|
||||||
|
#
|
||||||
|
# Default:
|
||||||
|
# - (macOS) Menlo
|
||||||
|
# - (Linux/BSD) monospace
|
||||||
|
# - (Windows) Consolas
|
||||||
|
family: Source Code Pro
|
||||||
|
# family: CodeNewRoman Nerd Font
|
||||||
|
# family: RobotoMono Nerd Font
|
||||||
|
# family: Hack
|
||||||
|
# family: JetBrains Mono
|
||||||
|
# family: UbuntuMono Nerd Font
|
||||||
|
# family: Monofur Nerd Font
|
||||||
|
# family: TerminessTTF Nerd Font
|
||||||
|
# family: Mononoki Nerd Font
|
||||||
|
|
||||||
|
# The `style` can be specified to pick a specific face.
|
||||||
|
style: Regular
|
||||||
|
|
||||||
|
# Bold font face
|
||||||
|
bold:
|
||||||
|
# Font family
|
||||||
|
#
|
||||||
|
# If the bold family is not specified, it will fall back to the
|
||||||
|
# value specified for the normal font.
|
||||||
|
family: Source Code Pro
|
||||||
|
# family: CodeNewRoman Nerd Font
|
||||||
|
# family: RobotoMono Nerd Font
|
||||||
|
# family: Hack
|
||||||
|
# family: JetBrains Mono
|
||||||
|
# family: UbuntuMono Nerd Font
|
||||||
|
# family: Monofur Nerd Font
|
||||||
|
# family: TerminessTTF Nerd Font
|
||||||
|
# family: Mononoki Nerd Font
|
||||||
|
|
||||||
|
# The `style` can be specified to pick a specific face.
|
||||||
|
style: Bold
|
||||||
|
|
||||||
|
# Italic font face
|
||||||
|
italic:
|
||||||
|
# Font family
|
||||||
|
#
|
||||||
|
# If the italic family is not specified, it will fall back to the
|
||||||
|
# value specified for the normal font.
|
||||||
|
family: Source Code Pro
|
||||||
|
# family: CodeNewRoman Nerd Font
|
||||||
|
# family: RobotoMono Nerd Font
|
||||||
|
# family: Hack
|
||||||
|
# family: JetBrains Mono
|
||||||
|
# family: UbuntuMono Nerd Font
|
||||||
|
# family: Monofuritalic Nerd Font Mono
|
||||||
|
# family: TerminessTTF Nerd Font
|
||||||
|
# family: Mononoki Nerd Font
|
||||||
|
|
||||||
|
# The `style` can be specified to pick a specific face.
|
||||||
|
style: Italic
|
||||||
|
|
||||||
|
# Bold italic font face
|
||||||
|
bold_italic:
|
||||||
|
# Font family
|
||||||
|
#
|
||||||
|
# If the bold italic family is not specified, it will fall back to the
|
||||||
|
# value specified for the normal font.
|
||||||
|
family: Source Code Pro
|
||||||
|
# family: CodeNewRoman Nerd Font
|
||||||
|
# family: RobotoMono Nerd Font
|
||||||
|
# family: Hack
|
||||||
|
# family: JetBrains Mono
|
||||||
|
# family: UbuntuMono Nerd Font
|
||||||
|
# family: Monofuritalic Nerd Font Mono
|
||||||
|
# family: TerminessTTF Nerd Font
|
||||||
|
# family: Mononoki Nerd Font
|
||||||
|
|
||||||
|
# The `style` can be specified to pick a specific face.
|
||||||
|
style: Bold Italic
|
||||||
|
|
||||||
|
# Point size
|
||||||
|
size: 16
|
||||||
|
|
||||||
|
# Offset is the extra space around each character. `offset.y` can be thought of
|
||||||
|
# as modifying the line spacing, and `offset.x` as modifying the letter spacing.
|
||||||
|
offset:
|
||||||
|
x: 0
|
||||||
|
y: 1
|
||||||
|
|
||||||
|
# Glyph offset determines the locations of the glyphs within their cells with
|
||||||
|
# the default being at the bottom. Increasing `x` moves the glyph to the right,
|
||||||
|
# increasing `y` moves the glyph upwards.
|
||||||
|
#glyph_offset:
|
||||||
|
# x: 0
|
||||||
|
# y: 0
|
||||||
|
|
||||||
|
# Thin stroke font rendering (macOS only)
|
||||||
|
#
|
||||||
|
# Thin strokes are suitable for retina displays, but for non-retina screens
|
||||||
|
# it is recommended to set `use_thin_strokes` to `false`
|
||||||
|
#
|
||||||
|
# macOS >= 10.14.x:
|
||||||
|
#
|
||||||
|
# If the font quality on non-retina display looks bad then set
|
||||||
|
# `use_thin_strokes` to `true` and enable font smoothing by running the
|
||||||
|
# following command:
|
||||||
|
# `defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO`
|
||||||
|
#
|
||||||
|
# This is a global setting and will require a log out or restart to take
|
||||||
|
# effect.
|
||||||
|
#use_thin_strokes: true
|
||||||
|
|
||||||
|
# If `true`, bold text is drawn using the bright color variants.
|
||||||
|
draw_bold_text_with_bright_colors: true
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
## START OF COLOR SCHEMES ##
|
||||||
|
#######################################
|
||||||
|
schemes:
|
||||||
|
### Doom One ###
|
||||||
|
DoomOne: &DoomOne
|
||||||
|
primary:
|
||||||
|
background: '#282c34'
|
||||||
|
foreground: '#bbc2cf'
|
||||||
|
cursor:
|
||||||
|
text: CellBackground
|
||||||
|
cursor: '#528bff'
|
||||||
|
selection:
|
||||||
|
text: CellForeground
|
||||||
|
background: '#3e4451'
|
||||||
|
normal:
|
||||||
|
black: '#1c1f24'
|
||||||
|
red: '#ff6c6b'
|
||||||
|
green: '#98be65'
|
||||||
|
yellow: '#da8548'
|
||||||
|
blue: '#51afef'
|
||||||
|
magenta: '#c678dd'
|
||||||
|
cyan: '#5699af'
|
||||||
|
white: '#202328'
|
||||||
|
bright:
|
||||||
|
black: '#5b6268'
|
||||||
|
red: '#da8548'
|
||||||
|
green: '#4db5bd'
|
||||||
|
yellow: '#ecbe7b'
|
||||||
|
blue: '#3071db' # This is 2257a0 in Doom Emacs but I lightened it.
|
||||||
|
magenta: '#a9a1e1'
|
||||||
|
cyan: '#46d9ff'
|
||||||
|
white: '#dfdfdf'
|
||||||
|
|
||||||
|
### Dracula ###
|
||||||
|
Dracula: &Dracula
|
||||||
|
primary:
|
||||||
|
background: '#282a36'
|
||||||
|
foreground: '#f8f8f2'
|
||||||
|
cursor:
|
||||||
|
text: CellBackground
|
||||||
|
cursor: CellForeground
|
||||||
|
vi_mode_cursor:
|
||||||
|
text: CellBackground
|
||||||
|
cursor: CellForeground
|
||||||
|
search:
|
||||||
|
matches:
|
||||||
|
foreground: '#44475a'
|
||||||
|
background: '#50fa7b'
|
||||||
|
focused_match:
|
||||||
|
foreground: '#44475a'
|
||||||
|
background: '#ffb86c'
|
||||||
|
bar:
|
||||||
|
background: '#282a36'
|
||||||
|
foreground: '#f8f8f2'
|
||||||
|
line_indicator:
|
||||||
|
foreground: None
|
||||||
|
background: None
|
||||||
|
selection:
|
||||||
|
text: CellForeground
|
||||||
|
background: '#44475a'
|
||||||
|
normal:
|
||||||
|
black: '#000000'
|
||||||
|
red: '#ff5555'
|
||||||
|
green: '#50fa7b'
|
||||||
|
yellow: '#f1fa8c'
|
||||||
|
blue: '#bd93f9'
|
||||||
|
magenta: '#ff79c6'
|
||||||
|
cyan: '#8be9fd'
|
||||||
|
white: '#bfbfbf'
|
||||||
|
bright:
|
||||||
|
black: '#4d4d4d'
|
||||||
|
red: '#ff6e67'
|
||||||
|
green: '#5af78e'
|
||||||
|
yellow: '#f4f99d'
|
||||||
|
blue: '#caa9fa'
|
||||||
|
magenta: '#ff92d0'
|
||||||
|
cyan: '#9aedfe'
|
||||||
|
white: '#e6e6e6'
|
||||||
|
dim:
|
||||||
|
black: '#14151b'
|
||||||
|
red: '#ff2222'
|
||||||
|
green: '#1ef956'
|
||||||
|
yellow: '#ebf85b'
|
||||||
|
blue: '#4d5b86'
|
||||||
|
magenta: '#ff46b0'
|
||||||
|
cyan: '#59dffc'
|
||||||
|
white: '#e6e6d1'
|
||||||
|
|
||||||
|
### Gruvbox dark ###
|
||||||
|
GruvboxDark: &GruvboxDark
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
# hard contrast: background = '0x1d2021'
|
||||||
|
background: '#282828'
|
||||||
|
# soft contrast: background = '0x32302f'
|
||||||
|
foreground: '#ebdbb2'
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '#282828'
|
||||||
|
red: '#cc241d'
|
||||||
|
green: '#98971a'
|
||||||
|
yellow: '#d79921'
|
||||||
|
blue: '#458588'
|
||||||
|
magenta: '#b16286'
|
||||||
|
cyan: '#689d6a'
|
||||||
|
white: '#a89984'
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '#928374'
|
||||||
|
red: '#fb4934'
|
||||||
|
green: '#b8bb26'
|
||||||
|
yellow: '#fabd2f'
|
||||||
|
blue: '#83a598'
|
||||||
|
magenta: '#d3869b'
|
||||||
|
cyan: '#8ec07c'
|
||||||
|
white: '#ebdbb2'
|
||||||
|
|
||||||
|
### Monokai ###
|
||||||
|
MonokaiPro: &MonokaiPro
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '#2D2A2E'
|
||||||
|
foreground: '#FCFCFA'
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '#403E41'
|
||||||
|
red: '#FF6188'
|
||||||
|
green: '#A9DC76'
|
||||||
|
yellow: '#FFD866'
|
||||||
|
blue: '#FC9867'
|
||||||
|
magenta: '#AB9DF2'
|
||||||
|
cyan: '#78DCE8'
|
||||||
|
white: '#FCFCFA'
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '#727072'
|
||||||
|
red: '#FF6188'
|
||||||
|
green: '#A9DC76'
|
||||||
|
yellow: '#FFD866'
|
||||||
|
blue: '#FC9867'
|
||||||
|
magenta: '#AB9DF2'
|
||||||
|
cyan: '#78DCE8'
|
||||||
|
white: '#FCFCFA'
|
||||||
|
|
||||||
|
### Nord ###
|
||||||
|
Nord: &Nord
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '#2E3440'
|
||||||
|
foreground: '#D8DEE9'
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '#3B4252'
|
||||||
|
red: '#BF616A'
|
||||||
|
green: '#A3BE8C'
|
||||||
|
yellow: '#EBCB8B'
|
||||||
|
blue: '#81A1C1'
|
||||||
|
magenta: '#B48EAD'
|
||||||
|
cyan: '#88C0D0'
|
||||||
|
white: '#E5E9F0'
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '#4C566A'
|
||||||
|
red: '#BF616A'
|
||||||
|
green: '#A3BE8C'
|
||||||
|
yellow: '#EBCB8B'
|
||||||
|
blue: '#81A1C1'
|
||||||
|
magenta: '#B48EAD'
|
||||||
|
cyan: '#8FBCBB'
|
||||||
|
white: '#ECEFF4'
|
||||||
|
|
||||||
|
### Oceanic Next ###
|
||||||
|
OceanicNext: &OceanicNext
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '#1b2b34'
|
||||||
|
foreground: '#d8dee9'
|
||||||
|
|
||||||
|
# Colors the cursor will use if `custom_cursor_colors` is true
|
||||||
|
cursor:
|
||||||
|
text: '#1b2b34'
|
||||||
|
cursor: '#ffffff'
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '#343d46'
|
||||||
|
red: '#EC5f67'
|
||||||
|
green: '#99C794'
|
||||||
|
yellow: '#FAC863'
|
||||||
|
blue: '#6699cc'
|
||||||
|
magenta: '#c594c5'
|
||||||
|
cyan: '#5fb3b3'
|
||||||
|
white: '#d8dee9'
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '#343d46'
|
||||||
|
red: '#EC5f67'
|
||||||
|
green: '#99C794'
|
||||||
|
yellow: '#FAC863'
|
||||||
|
blue: '#6699cc'
|
||||||
|
magenta: '#c594c5'
|
||||||
|
cyan: '#5fb3b3'
|
||||||
|
white: '#d8dee9'
|
||||||
|
|
||||||
|
### Palenight ###
|
||||||
|
Palenight: &Palenight
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '#292d3e'
|
||||||
|
foreground: '#d0d0d0'
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '#292d3e'
|
||||||
|
red: '#f07178'
|
||||||
|
green: '#c3e88d'
|
||||||
|
yellow: '#ffcb6b'
|
||||||
|
blue: '#82aaff'
|
||||||
|
magenta: '#c792ea'
|
||||||
|
cyan: '#89ddff'
|
||||||
|
white: '#d0d0d0'
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '#434758'
|
||||||
|
red: '#ff8b92'
|
||||||
|
green: '#ddffa7'
|
||||||
|
yellow: '#ffe585'
|
||||||
|
blue: '#9cc4ff'
|
||||||
|
magenta: '#e1acff'
|
||||||
|
cyan: '#a3f7ff'
|
||||||
|
white: '#ffffff'
|
||||||
|
|
||||||
|
### Solarized Dark ###
|
||||||
|
SolarizedDark: &SolarizedDark
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '#002b36' # base03
|
||||||
|
foreground: '#839496' # base0
|
||||||
|
|
||||||
|
# Cursor colors
|
||||||
|
cursor:
|
||||||
|
text: '#002b36' # base03
|
||||||
|
cursor: '#839496' # base0
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '#073642' # base02
|
||||||
|
red: '#dc322f' # red
|
||||||
|
green: '#859900' # green
|
||||||
|
yellow: '#b58900' # yellow
|
||||||
|
blue: '#268bd2' # blue
|
||||||
|
magenta: '#d33682' # magenta
|
||||||
|
cyan: '#2aa198' # cyan
|
||||||
|
white: '#eee8d5' # base2
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '#002b36' # base03
|
||||||
|
red: '#cb4b16' # orange
|
||||||
|
green: '#586e75' # base01
|
||||||
|
yellow: '#657b83' # base00
|
||||||
|
blue: '#839496' # base0
|
||||||
|
magenta: '#6c71c4' # violet
|
||||||
|
cyan: '#93a1a1' # base1
|
||||||
|
white: '#fdf6e3' # base3
|
||||||
|
|
||||||
|
### Solarized Light ###
|
||||||
|
SolarizedLight: &SolarizedLight
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '#fdf6e3' # base3
|
||||||
|
foreground: '#657b83' # base00
|
||||||
|
|
||||||
|
# Cursor colors
|
||||||
|
cursor:
|
||||||
|
text: '#fdf6e3' # base3
|
||||||
|
cursor: '#657b83' # base00
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '#073642' # base02
|
||||||
|
red: '#dc322f' # red
|
||||||
|
green: '#859900' # green
|
||||||
|
yellow: '#b58900' # yellow
|
||||||
|
blue: '#268bd2' # blue
|
||||||
|
magenta: '#d33682' # magenta
|
||||||
|
cyan: '#2aa198' # cyan
|
||||||
|
white: '#eee8d5' # base2
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '#002b36' # base03
|
||||||
|
red: '#cb4b16' # orange
|
||||||
|
green: '#586e75' # base01
|
||||||
|
yellow: '#657b83' # base00
|
||||||
|
blue: '#839496' # base0
|
||||||
|
magenta: '#6c71c4' # violet
|
||||||
|
cyan: '#93a1a1' # base1
|
||||||
|
white: '#fdf6e3' # base3
|
||||||
|
|
||||||
|
### Tomorrow Night ###
|
||||||
|
TomorrowNight: &TomorrowNight
|
||||||
|
# Default colors
|
||||||
|
primary:
|
||||||
|
background: '#1d1f21'
|
||||||
|
foreground: '#c5c8c6'
|
||||||
|
|
||||||
|
# Colors the cursor will use if `custom_cursor_colors` is true
|
||||||
|
cursor:
|
||||||
|
text: '#1d1f21'
|
||||||
|
cursor: '#ffffff'
|
||||||
|
|
||||||
|
# Normal colors
|
||||||
|
normal:
|
||||||
|
black: '#1d1f21'
|
||||||
|
red: '#cc6666'
|
||||||
|
green: '#b5bd68'
|
||||||
|
yellow: '#e6c547'
|
||||||
|
blue: '#81a2be'
|
||||||
|
magenta: '#b294bb'
|
||||||
|
cyan: '#70c0ba'
|
||||||
|
white: '#373b41'
|
||||||
|
|
||||||
|
# Bright colors
|
||||||
|
bright:
|
||||||
|
black: '#666666'
|
||||||
|
red: '#ff3334'
|
||||||
|
green: '#9ec400'
|
||||||
|
yellow: '#f0c674'
|
||||||
|
blue: '#81a2be'
|
||||||
|
magenta: '#b77ee0'
|
||||||
|
cyan: '#54ced6'
|
||||||
|
white: '#282a2e'
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
## SET THEME: Choose ONE color scheme from those in the above list. ##
|
||||||
|
## ###################################################################
|
||||||
|
# Available themes are:
|
||||||
|
# *DoomOne
|
||||||
|
# *Dracula
|
||||||
|
# *GruvboxDark
|
||||||
|
# *MonokaiPro
|
||||||
|
# *Nord
|
||||||
|
# *OceanicNext
|
||||||
|
# *Palenight
|
||||||
|
# *SolarizedLight
|
||||||
|
# *SolarizedDark
|
||||||
|
# *TomorrowNight
|
||||||
|
|
||||||
|
colors: *DoomOne
|
||||||
|
|
||||||
|
#######################################
|
||||||
|
## END OF COLOR SCHEMES ##
|
||||||
|
#######################################
|
||||||
|
|
||||||
|
# Visual Bell
|
||||||
|
#
|
||||||
|
# Any time the BEL code is received, Alacritty "rings" the visual bell. Once
|
||||||
|
# rung, the terminal background will be set to white and transition back to the
|
||||||
|
# default background color. You can control the rate of this transition by
|
||||||
|
# setting the `duration` property (represented in milliseconds). You can also
|
||||||
|
# configure the transition function by setting the `animation` property.
|
||||||
|
#
|
||||||
|
# Values for `animation`:
|
||||||
|
# - Ease
|
||||||
|
# - EaseOut
|
||||||
|
# - EaseOutSine
|
||||||
|
# - EaseOutQuad
|
||||||
|
# - EaseOutCubic
|
||||||
|
# - EaseOutQuart
|
||||||
|
# - EaseOutQuint
|
||||||
|
# - EaseOutExpo
|
||||||
|
# - EaseOutCirc
|
||||||
|
# - Linear
|
||||||
|
#
|
||||||
|
# Specifying a `duration` of `0` will disable the visual bell.
|
||||||
|
#visual_bell:
|
||||||
|
# animation: EaseOutExpo
|
||||||
|
# duration: 0
|
||||||
|
# color: '#ffffff'
|
||||||
|
|
||||||
|
#selection:
|
||||||
|
#semantic_escape_chars: ",│`|:\"' ()[]{}<>\t"
|
||||||
|
|
||||||
|
# When set to `true`, selected text will be copied to the primary clipboard.
|
||||||
|
#save_to_clipboard: false
|
||||||
|
|
||||||
|
# Allow terminal applications to change Alacritty's window title.
|
||||||
|
#dynamic_title: true
|
||||||
|
|
||||||
|
#cursor:
|
||||||
|
# Cursor style
|
||||||
|
#
|
||||||
|
# Values for `style`:
|
||||||
|
# - ▇ Block
|
||||||
|
# - _ Underline
|
||||||
|
# - | Beam
|
||||||
|
#style: Block
|
||||||
|
|
||||||
|
# If this is `true`, the cursor will be rendered as a hollow box when the
|
||||||
|
# window is not focused.
|
||||||
|
#unfocused_hollow: true
|
||||||
|
|
||||||
|
# Live config reload (changes require restart)
|
||||||
|
#live_config_reload: true
|
||||||
|
|
||||||
|
# Shell
|
||||||
|
#
|
||||||
|
# You can set `shell.program` to the path of your favorite shell, e.g. `/bin/fish`.
|
||||||
|
# Entries in `shell.args` are passed unmodified as arguments to the shell.
|
||||||
|
#
|
||||||
|
# Default:
|
||||||
|
# - (macOS) /bin/bash --login
|
||||||
|
# - (Linux/BSD) user login shell
|
||||||
|
# - (Windows) powershell
|
||||||
|
#shell:
|
||||||
|
# program: /bin/bash
|
||||||
|
# args:
|
||||||
|
# - --login
|
||||||
|
|
||||||
|
# Startup directory
|
||||||
|
#
|
||||||
|
# Directory the shell is started in. If this is unset, or `None`, the working
|
||||||
|
# directory of the parent process will be used.
|
||||||
|
#working_directory: None
|
||||||
|
|
||||||
|
# WinPTY backend (Windows only)
|
||||||
|
#
|
||||||
|
# Alacritty defaults to using the newer ConPTY backend if it is available,
|
||||||
|
# since it resolves a lot of bugs and is quite a bit faster. If it is not
|
||||||
|
# available, the the WinPTY backend will be used instead.
|
||||||
|
#
|
||||||
|
# Setting this option to `true` makes Alacritty use the legacy WinPTY backend,
|
||||||
|
# even if the ConPTY backend is available.
|
||||||
|
#winpty_backend: false
|
||||||
|
|
||||||
|
# Send ESC (\x1b) before characters when alt is pressed.
|
||||||
|
#alt_send_esc: true
|
||||||
|
|
||||||
|
#debug:
|
||||||
|
# Display the time it takes to redraw each frame.
|
||||||
|
#render_timer: false
|
||||||
|
|
||||||
|
# Keep the log file after quitting Alacritty.
|
||||||
|
#persistent_logging: false
|
||||||
|
|
||||||
|
# Log level
|
||||||
|
#
|
||||||
|
# Values for `log_level`:
|
||||||
|
# - None
|
||||||
|
# - Error
|
||||||
|
# - Warn
|
||||||
|
# - Info
|
||||||
|
# - Debug
|
||||||
|
# - Trace
|
||||||
|
#log_level: Warn
|
||||||
|
|
||||||
|
# Print all received window events.
|
||||||
|
#print_events: false
|
||||||
|
|
||||||
|
# Record all characters and escape sequences as test data.
|
||||||
|
#ref_test: false
|
||||||
|
|
||||||
|
#mouse:
|
||||||
|
# Click settings
|
||||||
|
#
|
||||||
|
# The `double_click` and `triple_click` settings control the time
|
||||||
|
# alacritty should wait for accepting multiple clicks as one double
|
||||||
|
# or triple click.
|
||||||
|
#double_click: { threshold: 300 }
|
||||||
|
#triple_click: { threshold: 300 }
|
||||||
|
|
||||||
|
# If this is `true`, the cursor is temporarily hidden when typing.
|
||||||
|
#hide_when_typing: false
|
||||||
|
|
||||||
|
#url:
|
||||||
|
# URL launcher
|
||||||
|
#
|
||||||
|
# This program is executed when clicking on a text which is recognized as a URL.
|
||||||
|
# The URL is always added to the command as the last parameter.
|
||||||
|
#
|
||||||
|
# When set to `None`, URL launching will be disabled completely.
|
||||||
|
#
|
||||||
|
# Default:
|
||||||
|
# - (macOS) open
|
||||||
|
# - (Linux/BSD) xdg-open
|
||||||
|
# - (Windows) explorer
|
||||||
|
#launcher:
|
||||||
|
# program: xdg-open
|
||||||
|
# args: []
|
||||||
|
|
||||||
|
# URL modifiers
|
||||||
|
#
|
||||||
|
# These are the modifiers that need to be held down for opening URLs when clicking
|
||||||
|
# on them. The available modifiers are documented in the key binding section.
|
||||||
|
#modifiers: None
|
||||||
|
|
||||||
|
# Mouse bindings
|
||||||
|
#
|
||||||
|
# Mouse bindings are specified as a list of objects, much like the key
|
||||||
|
# bindings further below.
|
||||||
|
#
|
||||||
|
# Each mouse binding will specify a:
|
||||||
|
#
|
||||||
|
# - `mouse`:
|
||||||
|
#
|
||||||
|
# - Middle
|
||||||
|
# - Left
|
||||||
|
# - Right
|
||||||
|
# - Numeric identifier such as `5`
|
||||||
|
#
|
||||||
|
# - `action` (see key bindings)
|
||||||
|
#
|
||||||
|
# And optionally:
|
||||||
|
#
|
||||||
|
# - `mods` (see key bindings)
|
||||||
|
#mouse_bindings:
|
||||||
|
# - { mouse: Middle, action: PasteSelection }
|
||||||
|
|
||||||
|
# Key bindings
|
||||||
|
#
|
||||||
|
# Key bindings are specified as a list of objects. For example, this is the
|
||||||
|
# default paste binding:
|
||||||
|
#
|
||||||
|
# `- { key: V, mods: Control|Shift, action: Paste }`
|
||||||
|
#
|
||||||
|
# Each key binding will specify a:
|
||||||
|
#
|
||||||
|
# - `key`: Identifier of the key pressed
|
||||||
|
#
|
||||||
|
# - A-Z
|
||||||
|
# - F1-F24
|
||||||
|
# - Key0-Key9
|
||||||
|
#
|
||||||
|
# A full list with available key codes can be found here:
|
||||||
|
# https://docs.rs/glutin/*/glutin/event/enum.VirtualKeyCode.html#variants
|
||||||
|
#
|
||||||
|
# Instead of using the name of the keys, the `key` field also supports using
|
||||||
|
# the scancode of the desired key. Scancodes have to be specified as a
|
||||||
|
# decimal number. This command will allow you to display the hex scancodes
|
||||||
|
# for certain keys:
|
||||||
|
#
|
||||||
|
# `showkey --scancodes`.
|
||||||
|
#
|
||||||
|
# Then exactly one of:
|
||||||
|
#
|
||||||
|
# - `chars`: Send a byte sequence to the running application
|
||||||
|
#
|
||||||
|
# The `chars` field writes the specified string to the terminal. This makes
|
||||||
|
# it possible to pass escape sequences. To find escape codes for bindings
|
||||||
|
# like `PageUp` (`"\x1b[5~"`), you can run the command `showkey -a` outside
|
||||||
|
# of tmux. Note that applications use terminfo to map escape sequences back
|
||||||
|
# to keys. It is therefore required to update the terminfo when changing an
|
||||||
|
# escape sequence.
|
||||||
|
#
|
||||||
|
# - `action`: Execute a predefined action
|
||||||
|
#
|
||||||
|
# - Copy
|
||||||
|
# - Paste
|
||||||
|
# - PasteSelection
|
||||||
|
# - IncreaseFontSize
|
||||||
|
# - DecreaseFontSize
|
||||||
|
# - ResetFontSize
|
||||||
|
# - ScrollPageUp
|
||||||
|
# - ScrollPageDown
|
||||||
|
# - ScrollLineUp
|
||||||
|
# - ScrollLineDown
|
||||||
|
# - ScrollToTop
|
||||||
|
# - ScrollToBottom
|
||||||
|
# - ClearHistory
|
||||||
|
# - Hide
|
||||||
|
# - Minimize
|
||||||
|
# - Quit
|
||||||
|
# - ToggleFullscreen
|
||||||
|
# - SpawnNewInstance
|
||||||
|
# - ClearLogNotice
|
||||||
|
# - ReceiveChar
|
||||||
|
# - None
|
||||||
|
#
|
||||||
|
# (macOS only):
|
||||||
|
# - ToggleSimpleFullscreen: Enters fullscreen without occupying another space
|
||||||
|
#
|
||||||
|
# - `command`: Fork and execute a specified command plus arguments
|
||||||
|
#
|
||||||
|
# The `command` field must be a map containing a `program` string and an
|
||||||
|
# `args` array of command line parameter strings. For example:
|
||||||
|
# `{ program: "alacritty", args: ["-e", "vttest"] }`
|
||||||
|
#
|
||||||
|
# And optionally:
|
||||||
|
#
|
||||||
|
# - `mods`: Key modifiers to filter binding actions
|
||||||
|
#
|
||||||
|
# - Command
|
||||||
|
# - Control
|
||||||
|
# - Option
|
||||||
|
# - Super
|
||||||
|
# - Shift
|
||||||
|
# - Alt
|
||||||
|
#
|
||||||
|
# Multiple `mods` can be combined using `|` like this:
|
||||||
|
# `mods: Control|Shift`.
|
||||||
|
# Whitespace and capitalization are relevant and must match the example.
|
||||||
|
#
|
||||||
|
# - `mode`: Indicate a binding for only specific terminal reported modes
|
||||||
|
#
|
||||||
|
# This is mainly used to send applications the correct escape sequences
|
||||||
|
# when in different modes.
|
||||||
|
#
|
||||||
|
# - AppCursor
|
||||||
|
# - AppKeypad
|
||||||
|
# - Alt
|
||||||
|
#
|
||||||
|
# A `~` operator can be used before a mode to apply the binding whenever
|
||||||
|
# the mode is *not* active, e.g. `~Alt`.
|
||||||
|
#
|
||||||
|
# Bindings are always filled by default, but will be replaced when a new
|
||||||
|
# binding with the same triggers is defined. To unset a default binding, it can
|
||||||
|
# be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for
|
||||||
|
# a no-op if you do not wish to receive input characters for that binding.
|
||||||
|
key_bindings:
|
||||||
|
# (Windows, Linux, and BSD only)
|
||||||
|
- { key: V, mods: Control|Shift, action: Paste }
|
||||||
|
- { key: C, mods: Control|Shift, action: Copy }
|
||||||
|
- { key: Insert, mods: Shift, action: PasteSelection }
|
||||||
|
- { key: Key0, mods: Control, action: ResetFontSize }
|
||||||
|
- { key: Equals, mods: Control, action: IncreaseFontSize }
|
||||||
|
- { key: Plus, mods: Control, action: IncreaseFontSize }
|
||||||
|
- { key: Minus, mods: Control, action: DecreaseFontSize }
|
||||||
|
- { key: F11, mods: None, action: ToggleFullscreen }
|
||||||
|
- { key: Paste, mods: None, action: Paste }
|
||||||
|
- { key: Copy, mods: None, action: Copy }
|
||||||
|
- { key: L, mods: Control, action: ClearLogNotice }
|
||||||
|
- { key: L, mods: Control, chars: "\x0c" }
|
||||||
|
- { key: PageUp, mods: None, action: ScrollPageUp, mode: ~Alt }
|
||||||
|
- { key: PageDown, mods: None, action: ScrollPageDown, mode: ~Alt }
|
||||||
|
- { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt }
|
||||||
|
- { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt }
|
||||||
|
|
@ -0,0 +1,20 @@
|
|||||||
|
font:
|
||||||
|
normal:
|
||||||
|
family: Source Code Pro
|
||||||
|
style: Regular
|
||||||
|
|
||||||
|
bold:
|
||||||
|
family: Source Code Pro
|
||||||
|
style: Bold
|
||||||
|
|
||||||
|
italic:
|
||||||
|
family: Source Code Pro
|
||||||
|
style: Italic
|
||||||
|
|
||||||
|
bold_italic:
|
||||||
|
family: Source Code Pro
|
||||||
|
style: Bold Italic
|
||||||
|
|
||||||
|
size: 8
|
||||||
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
|||||||
|
if status is-interactive
|
||||||
|
# Commands to run in interactive sessions can go here
|
||||||
|
end
|
||||||
|
|
||||||
|
set fish_greeting # Supresses fish's intro message
|
||||||
|
set TERM "xterm-256color" # Defines th terminal type
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#####################
|
||||||
|
### VISUALS BEGIN ###
|
||||||
|
#####################
|
||||||
|
set fish_color_normal brcyan
|
||||||
|
set fish_color_autosuggestion '#7d7d7d'
|
||||||
|
set fish_color_command brcyan
|
||||||
|
set fish_color_error '#ff6c6b'
|
||||||
|
set fish_color_param brcyan
|
||||||
|
|
||||||
|
#####################
|
||||||
|
### VISUALS END ###
|
||||||
|
#####################
|
||||||
|
|
||||||
|
# Changing "ls" to "exa"
|
||||||
|
alias ls='exa --color=always --group-directories-first' # my preferred listing
|
||||||
|
alias lsl='exa -al --color=always --group-directories-first' # my preferred listing
|
||||||
|
alias la='exa -a --color=always --group-directories-first' # all files and dirs
|
||||||
|
alias ll='exa -l --color=always --group-directories-first' # long format
|
||||||
|
alias lt='exa -aT --color=always --group-directories-first' # tree listing
|
||||||
|
alias l.='exa -a | egrep "^\."'
|
||||||
|
|
||||||
|
# navigation
|
||||||
|
alias ..='cd ..'
|
||||||
|
alias ...='cd ../..'
|
||||||
|
|
||||||
|
#adding flags
|
||||||
|
alias df='df -h' # human-readable sizes
|
||||||
|
alias free='free -m' # show sizes in MB
|
||||||
|
|
||||||
|
#aliseption
|
||||||
|
alias alias_edit='vim ~/.config/fish/config.fish'
|
||||||
|
alias alias_activate='source ~/.config/fish/config.fish'
|
||||||
|
|
||||||
|
#####################
|
||||||
|
### ALIASES END ###
|
||||||
|
#####################
|
@ -0,0 +1,428 @@
|
|||||||
|
#################################
|
||||||
|
# Shadows #
|
||||||
|
#################################
|
||||||
|
|
||||||
|
|
||||||
|
# Enabled client-side shadows on windows. Note desktop windows
|
||||||
|
# (windows with '_NET_WM_WINDOW_TYPE_DESKTOP') never get shadow,
|
||||||
|
# unless explicitly requested using the wintypes option.
|
||||||
|
#
|
||||||
|
# shadow = false
|
||||||
|
shadow = true;
|
||||||
|
|
||||||
|
# The blur radius for shadows, in pixels. (defaults to 12)
|
||||||
|
# shadow-radius = 12
|
||||||
|
shadow-radius = 7;
|
||||||
|
|
||||||
|
# The opacity of shadows. (0.0 - 1.0, defaults to 0.75)
|
||||||
|
# shadow-opacity = .75
|
||||||
|
|
||||||
|
# The left offset for shadows, in pixels. (defaults to -15)
|
||||||
|
# shadow-offset-x = -15
|
||||||
|
shadow-offset-x = -7;
|
||||||
|
|
||||||
|
# The top offset for shadows, in pixels. (defaults to -15)
|
||||||
|
# shadow-offset-y = -15
|
||||||
|
shadow-offset-y = -7;
|
||||||
|
|
||||||
|
# Red color value of shadow (0.0 - 1.0, defaults to 0).
|
||||||
|
# shadow-red = 0
|
||||||
|
|
||||||
|
# Green color value of shadow (0.0 - 1.0, defaults to 0).
|
||||||
|
# shadow-green = 0
|
||||||
|
|
||||||
|
# Blue color value of shadow (0.0 - 1.0, defaults to 0).
|
||||||
|
# shadow-blue = 0
|
||||||
|
|
||||||
|
# Hex string color value of shadow (#000000 - #FFFFFF, defaults to #000000). This option will override options set shadow-(red/green/blue)
|
||||||
|
# shadow-color = "#000000"
|
||||||
|
|
||||||
|
# Specify a list of conditions of windows that should have no shadow.
|
||||||
|
#
|
||||||
|
# examples:
|
||||||
|
# shadow-exclude = "n:e:Notification";
|
||||||
|
#
|
||||||
|
# shadow-exclude = []
|
||||||
|
shadow-exclude = [
|
||||||
|
"name = 'Notification'",
|
||||||
|
"class_g = 'Conky'",
|
||||||
|
"class_g ?= 'Notify-osd'",
|
||||||
|
"class_g = 'Cairo-clock'",
|
||||||
|
"_GTK_FRAME_EXTENTS@:c"
|
||||||
|
];
|
||||||
|
|
||||||
|
# Specify a list of conditions of windows that should have no shadow painted over, such as a dock window.
|
||||||
|
# clip-shadow-above = []
|
||||||
|
|
||||||
|
# Specify a X geometry that describes the region in which shadow should not
|
||||||
|
# be painted in, such as a dock window region. Use
|
||||||
|
# shadow-exclude-reg = "x10+0+0"
|
||||||
|
# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on.
|
||||||
|
#
|
||||||
|
# shadow-exclude-reg = ""
|
||||||
|
|
||||||
|
# Crop shadow of a window fully on a particular Xinerama screen to the screen.
|
||||||
|
# xinerama-shadow-crop = false
|
||||||
|
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Fading #
|
||||||
|
#################################
|
||||||
|
|
||||||
|
|
||||||
|
# Fade windows in/out when opening/closing and when opacity changes,
|
||||||
|
# unless no-fading-openclose is used.
|
||||||
|
# fading = false
|
||||||
|
fading = true;
|
||||||
|
|
||||||
|
# Opacity change between steps while fading in. (0.01 - 1.0, defaults to 0.028)
|
||||||
|
# fade-in-step = 0.028
|
||||||
|
fade-in-step = 0.03;
|
||||||
|
|
||||||
|
# Opacity change between steps while fading out. (0.01 - 1.0, defaults to 0.03)
|
||||||
|
# fade-out-step = 0.03
|
||||||
|
fade-out-step = 0.03;
|
||||||
|
|
||||||
|
# The time between steps in fade step, in milliseconds. (> 0, defaults to 10)
|
||||||
|
# fade-delta = 10
|
||||||
|
|
||||||
|
# Specify a list of conditions of windows that should not be faded.
|
||||||
|
# fade-exclude = []
|
||||||
|
|
||||||
|
# Do not fade on window open/close.
|
||||||
|
# no-fading-openclose = false
|
||||||
|
|
||||||
|
# Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, Fluxbox, etc.
|
||||||
|
# no-fading-destroyed-argb = false
|
||||||
|
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Transparency / Opacity #
|
||||||
|
#################################
|
||||||
|
|
||||||
|
|
||||||
|
# Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0)
|
||||||
|
# inactive-opacity = 1
|
||||||
|
inactive-opacity = 0.95;
|
||||||
|
|
||||||
|
# Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default)
|
||||||
|
# frame-opacity = 1.0
|
||||||
|
frame-opacity = 0.9;
|
||||||
|
|
||||||
|
# Let inactive opacity set by -i override the '_NET_WM_WINDOW_OPACITY' values of windows.
|
||||||
|
# inactive-opacity-override = true
|
||||||
|
inactive-opacity-override = false;
|
||||||
|
|
||||||
|
# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0)
|
||||||
|
# active-opacity = 1.0
|
||||||
|
|
||||||
|
# Dim inactive windows. (0.0 - 1.0, defaults to 0.0)
|
||||||
|
# inactive-dim = 0.0
|
||||||
|
|
||||||
|
# Specify a list of conditions of windows that should never be considered focused.
|
||||||
|
# focus-exclude = []
|
||||||
|
focus-exclude = [ "class_g = 'Cairo-clock'" ];
|
||||||
|
|
||||||
|
# Use fixed inactive dim value, instead of adjusting according to window opacity.
|
||||||
|
# inactive-dim-fixed = 1.0
|
||||||
|
|
||||||
|
# Specify a list of opacity rules, in the format `PERCENT:PATTERN`,
|
||||||
|
# like `50:name *= "Firefox"`. picom-trans is recommended over this.
|
||||||
|
# Note we don't make any guarantee about possible conflicts with other
|
||||||
|
# programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows.
|
||||||
|
# example:
|
||||||
|
# opacity-rule = [ "80:class_g = 'URxvt'" ];
|
||||||
|
#
|
||||||
|
# opacity-rule = []
|
||||||
|
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Corners #
|
||||||
|
#################################
|
||||||
|
|
||||||
|
# Sets the radius of rounded window corners. When > 0, the compositor will
|
||||||
|
# round the corners of windows. Does not interact well with
|
||||||
|
# `transparent-clipping`.
|
||||||
|
corner-radius = 5
|
||||||
|
|
||||||
|
# Exclude conditions for rounded corners.
|
||||||
|
rounded-corners-exclude = [
|
||||||
|
"window_type = 'dock'",
|
||||||
|
"window_type = 'desktop'"
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Background-Blurring #
|
||||||
|
#################################
|
||||||
|
|
||||||
|
|
||||||
|
# Parameters for background blurring, see the *BLUR* section for more information.
|
||||||
|
# blur-method =
|
||||||
|
# blur-size = 12
|
||||||
|
#
|
||||||
|
# blur-deviation = false
|
||||||
|
#
|
||||||
|
blur-strength = 5
|
||||||
|
|
||||||
|
# Blur background of semi-transparent / ARGB windows.
|
||||||
|
# Bad in performance, with driver-dependent behavior.
|
||||||
|
# The name of the switch may change without prior notifications.
|
||||||
|
#
|
||||||
|
# blur-background = false
|
||||||
|
|
||||||
|
# Blur background of windows when the window frame is not opaque.
|
||||||
|
# Implies:
|
||||||
|
# blur-background
|
||||||
|
# Bad in performance, with driver-dependent behavior. The name may change.
|
||||||
|
#
|
||||||
|
# blur-background-frame = false
|
||||||
|
|
||||||
|
|
||||||
|
# Use fixed blur strength rather than adjusting according to window opacity.
|
||||||
|
# blur-background-fixed = false
|
||||||
|
|
||||||
|
|
||||||
|
# Specify the blur convolution kernel, with the following format:
|
||||||
|
# example:
|
||||||
|
# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1";
|
||||||
|
#
|
||||||
|
# blur-kern = ""
|
||||||
|
blur-kern = "3x3box";
|
||||||
|
|
||||||
|
|
||||||
|
# Exclude conditions for background blur.
|
||||||
|
# blur-background-exclude = []
|
||||||
|
blur-background-exclude = [
|
||||||
|
"window_type = 'dock'",
|
||||||
|
"window_type = 'desktop'",
|
||||||
|
"_GTK_FRAME_EXTENTS@:c"
|
||||||
|
];
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# General Settings #
|
||||||
|
#################################
|
||||||
|
|
||||||
|
# Enable remote control via D-Bus. See the man page for more details.
|
||||||
|
# dbus = true
|
||||||
|
|
||||||
|
# Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers.
|
||||||
|
# daemon = false
|
||||||
|
|
||||||
|
# Specify the backend to use: `xrender`, `glx`, or `xr_glx_hybrid`.
|
||||||
|
# `xrender` is the default one.
|
||||||
|
#
|
||||||
|
# backend = "glx"
|
||||||
|
backend = "xrender";
|
||||||
|
|
||||||
|
# Enable/disable VSync.
|
||||||
|
# vsync = false
|
||||||
|
vsync = true;
|
||||||
|
|
||||||
|
# Enable remote control via D-Bus. See the *D-BUS API* section below for more details.
|
||||||
|
# dbus = false
|
||||||
|
|
||||||
|
# Try to detect WM windows (a non-override-redirect window with no
|
||||||
|
# child that has 'WM_STATE') and mark them as active.
|
||||||
|
#
|
||||||
|
# mark-wmwin-focused = false
|
||||||
|
mark-wmwin-focused = true;
|
||||||
|
|
||||||
|
# Mark override-redirect windows that doesn't have a child window with 'WM_STATE' focused.
|
||||||
|
# mark-ovredir-focused = false
|
||||||
|
mark-ovredir-focused = true;
|
||||||
|
|
||||||
|
# Try to detect windows with rounded corners and don't consider them
|
||||||
|
# shaped windows. The accuracy is not very high, unfortunately.
|
||||||
|
#
|
||||||
|
# detect-rounded-corners = false
|
||||||
|
detect-rounded-corners = true;
|
||||||
|
|
||||||
|
# Detect '_NET_WM_WINDOW_OPACITY' on client windows, useful for window managers
|
||||||
|
# not passing '_NET_WM_WINDOW_OPACITY' of client windows to frame windows.
|
||||||
|
#
|
||||||
|
# detect-client-opacity = false
|
||||||
|
detect-client-opacity = true;
|
||||||
|
|
||||||
|
# Use EWMH '_NET_ACTIVE_WINDOW' to determine currently focused window,
|
||||||
|
# rather than listening to 'FocusIn'/'FocusOut' event. Might have more accuracy,
|
||||||
|
# provided that the WM supports it.
|
||||||
|
#
|
||||||
|
# use-ewmh-active-win = false
|
||||||
|
|
||||||
|
# Unredirect all windows if a full-screen opaque window is detected,
|
||||||
|
# to maximize performance for full-screen windows. Known to cause flickering
|
||||||
|
# when redirecting/unredirecting windows.
|
||||||
|
#
|
||||||
|
# unredir-if-possible = false
|
||||||
|
|
||||||
|
# Delay before unredirecting the window, in milliseconds. Defaults to 0.
|
||||||
|
# unredir-if-possible-delay = 0
|
||||||
|
|
||||||
|
# Conditions of windows that shouldn't be considered full-screen for unredirecting screen.
|
||||||
|
# unredir-if-possible-exclude = []
|
||||||
|
|
||||||
|
# Use 'WM_TRANSIENT_FOR' to group windows, and consider windows
|
||||||
|
# in the same group focused at the same time.
|
||||||
|
#
|
||||||
|
# detect-transient = false
|
||||||
|
detect-transient = true;
|
||||||
|
|
||||||
|
# Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same
|
||||||
|
# group focused at the same time. This usually means windows from the same application
|
||||||
|
# will be considered focused or unfocused at the same time.
|
||||||
|
# 'WM_TRANSIENT_FOR' has higher priority if detect-transient is enabled, too.
|
||||||
|
#
|
||||||
|
# detect-client-leader = false
|
||||||
|
|
||||||
|
# Resize damaged region by a specific number of pixels.
|
||||||
|
# A positive value enlarges it while a negative one shrinks it.
|
||||||
|
# If the value is positive, those additional pixels will not be actually painted
|
||||||
|
# to screen, only used in blur calculation, and such. (Due to technical limitations,
|
||||||
|
# with use-damage, those pixels will still be incorrectly painted to screen.)
|
||||||
|
# Primarily used to fix the line corruption issues of blur,
|
||||||
|
# in which case you should use the blur radius value here
|
||||||
|
# (e.g. with a 3x3 kernel, you should use `--resize-damage 1`,
|
||||||
|
# with a 5x5 one you use `--resize-damage 2`, and so on).
|
||||||
|
# May or may not work with *--glx-no-stencil*. Shrinking doesn't function correctly.
|
||||||
|
#
|
||||||
|
# resize-damage = 1
|
||||||
|
|
||||||
|
# Specify a list of conditions of windows that should be painted with inverted color.
|
||||||
|
# Resource-hogging, and is not well tested.
|
||||||
|
#
|
||||||
|
# invert-color-include = []
|
||||||
|
|
||||||
|
# GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer.
|
||||||
|
# Might cause incorrect opacity when rendering transparent content (but never
|
||||||
|
# practically happened) and may not work with blur-background.
|
||||||
|
# My tests show a 15% performance boost. Recommended.
|
||||||
|
#
|
||||||
|
glx-no-stencil = true;
|
||||||
|
|
||||||
|
# GLX backend: Avoid rebinding pixmap on window damage.
|
||||||
|
# Probably could improve performance on rapid window content changes,
|
||||||
|
# but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.).
|
||||||
|
# Recommended if it works.
|
||||||
|
#
|
||||||
|
# glx-no-rebind-pixmap = false
|
||||||
|
|
||||||
|
# Disable the use of damage information.
|
||||||
|
# This cause the whole screen to be redrawn every time, instead of the part of the screen
|
||||||
|
# has actually changed. Potentially degrades the performance, but might fix some artifacts.
|
||||||
|
# The opposing option is use-damage
|
||||||
|
#
|
||||||
|
# no-use-damage = false
|
||||||
|
use-damage = true;
|
||||||
|
|
||||||
|
# Use X Sync fence to sync clients' draw calls, to make sure all draw
|
||||||
|
# calls are finished before picom starts drawing. Needed on nvidia-drivers
|
||||||
|
# with GLX backend for some users.
|
||||||
|
#
|
||||||
|
# xrender-sync-fence = false
|
||||||
|
|
||||||
|
# GLX backend: Use specified GLSL fragment shader for rendering window
|
||||||
|
# contents. Read the man page for a detailed explanation of the interface.
|
||||||
|
#
|
||||||
|
# window-shader-fg = "default"
|
||||||
|
|
||||||
|
# Use rules to set per-window shaders. Syntax is SHADER_PATH:PATTERN, similar
|
||||||
|
# to opacity-rule. SHADER_PATH can be "default". This overrides window-shader-fg.
|
||||||
|
#
|
||||||
|
# window-shader-fg-rule = [
|
||||||
|
# "my_shader.frag:window_type != 'dock'"
|
||||||
|
# ]
|
||||||
|
|
||||||
|
# Force all windows to be painted with blending. Useful if you
|
||||||
|
# have a glx-fshader-win that could turn opaque pixels transparent.
|
||||||
|
#
|
||||||
|
# force-win-blend = false
|
||||||
|
|
||||||
|
# Do not use EWMH to detect fullscreen windows.
|
||||||
|
# Reverts to checking if a window is fullscreen based only on its size and coordinates.
|
||||||
|
#
|
||||||
|
# no-ewmh-fullscreen = false
|
||||||
|
|
||||||
|
# Dimming bright windows so their brightness doesn't exceed this set value.
|
||||||
|
# Brightness of a window is estimated by averaging all pixels in the window,
|
||||||
|
# so this could comes with a performance hit.
|
||||||
|
# Setting this to 1.0 disables this behaviour. Requires --use-damage to be disabled. (default: 1.0)
|
||||||
|
#
|
||||||
|
# max-brightness = 1.0
|
||||||
|
|
||||||
|
# Make transparent windows clip other windows like non-transparent windows do,
|
||||||
|
# instead of blending on top of them.
|
||||||
|
#
|
||||||
|
# transparent-clipping = false
|
||||||
|
|
||||||
|
# Specify a list of conditions of windows that should never have transparent
|
||||||
|
# clipping applied. Useful for screenshot tools, where you need to be able to
|
||||||
|
# see through transparent parts of the window.
|
||||||
|
#
|
||||||
|
# transparent-clipping-exclude = []
|
||||||
|
|
||||||
|
# Set the log level. Possible values are:
|
||||||
|
# "trace", "debug", "info", "warn", "error"
|
||||||
|
# in increasing level of importance. Case doesn't matter.
|
||||||
|
# If using the "TRACE" log level, it's better to log into a file
|
||||||
|
# using *--log-file*, since it can generate a huge stream of logs.
|
||||||
|
#
|
||||||
|
# log-level = "debug"
|
||||||
|
log-level = "warn";
|
||||||
|
|
||||||
|
# Set the log file.
|
||||||
|
# If *--log-file* is never specified, logs will be written to stderr.
|
||||||
|
# Otherwise, logs will to written to the given file, though some of the early
|
||||||
|
# logs might still be written to the stderr.
|
||||||
|
# When setting this option from the config file, it is recommended to use an absolute path.
|
||||||
|
#
|
||||||
|
# log-file = "/path/to/your/log/file"
|
||||||
|
|
||||||
|
# Show all X errors (for debugging)
|
||||||
|
# show-all-xerrors = false
|
||||||
|
|
||||||
|
# Write process ID to a file.
|
||||||
|
# write-pid-path = "/path/to/your/log/file"
|
||||||
|
|
||||||
|
# Window type settings
|
||||||
|
#
|
||||||
|
# 'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard:
|
||||||
|
# "unknown", "desktop", "dock", "toolbar", "menu", "utility",
|
||||||
|
# "splash", "dialog", "normal", "dropdown_menu", "popup_menu",
|
||||||
|
# "tooltip", "notification", "combo", and "dnd".
|
||||||
|
#
|
||||||
|
# Following per window-type options are available: ::
|
||||||
|
#
|
||||||
|
# fade, shadow:::
|
||||||
|
# Controls window-type-specific shadow and fade settings.
|
||||||
|
#
|
||||||
|
# opacity:::
|
||||||
|
# Controls default opacity of the window type.
|
||||||
|
#
|
||||||
|
# focus:::
|
||||||
|
# Controls whether the window of this type is to be always considered focused.
|
||||||
|
# (By default, all window types except "normal" and "dialog" has this on.)
|
||||||
|
#
|
||||||
|
# full-shadow:::
|
||||||
|
# Controls whether shadow is drawn under the parts of the window that you
|
||||||
|
# normally won't be able to see. Useful when the window has parts of it
|
||||||
|
# transparent, and you want shadows in those areas.
|
||||||
|
#
|
||||||
|
# clip-shadow-above:::
|
||||||
|
# Controls whether shadows that would have been drawn above the window should
|
||||||
|
# be clipped. Useful for dock windows that should have no shadow painted on top.
|
||||||
|
#
|
||||||
|
# redir-ignore:::
|
||||||
|
# Controls whether this type of windows should cause screen to become
|
||||||
|
# redirected again after been unredirected. If you have unredir-if-possible
|
||||||
|
# set, and doesn't want certain window to cause unnecessary screen redirection,
|
||||||
|
# you can set this to `true`.
|
||||||
|
#
|
||||||
|
wintypes:
|
||||||
|
{
|
||||||
|
tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; };
|
||||||
|
dock = { shadow = false; clip-shadow-above = true; }
|
||||||
|
dnd = { shadow = false; }
|
||||||
|
popup_menu = { opacity = 0.8; }
|
||||||
|
dropdown_menu = { opacity = 0.8; }
|
||||||
|
};
|
@ -0,0 +1,2 @@
|
|||||||
|
set -g mouse on
|
||||||
|
|
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
echo $(acpi | grep -o -E '[0-9][0-9]?%|100%')
|
@ -0,0 +1,64 @@
|
|||||||
|
-- Xmobar (http://projects.haskell.org/xmobar/)
|
||||||
|
-- This is one of the xmobar configurations for DTOS.
|
||||||
|
-- This config is packaged in the DTOS repo as 'dtos-xmobar'
|
||||||
|
-- Color scheme: Doom One
|
||||||
|
-- Dependencies:
|
||||||
|
-- otf-font-awesome
|
||||||
|
-- ttf-mononoki
|
||||||
|
-- ttf-ubuntu-font-family
|
||||||
|
-- htop
|
||||||
|
-- emacs
|
||||||
|
-- pacman (Arch Linux)
|
||||||
|
-- trayer
|
||||||
|
-- 'dtos-local-bin' (from dtos-core-repo)
|
||||||
|
|
||||||
|
Config { font = "xft:Ubuntu:weight=bold:pixelsize=11:antialias=true:hinting=true"
|
||||||
|
, additionalFonts = [ "xft:Mononoki:pixelsize=11:antialias=true:hinting=true"
|
||||||
|
, "xft:Font Awesome 5 Free Solid:pixelsize=12"
|
||||||
|
, "xft:Font Awesome 5 Brands:pixelsize=12"
|
||||||
|
]
|
||||||
|
, bgColor = "#282c34"
|
||||||
|
, fgColor = "#ff6c6b"
|
||||||
|
-- Position TopSize and BottomSize take 3 arguments:
|
||||||
|
-- an alignment parameter (L/R/C) for Left, Right or Center.
|
||||||
|
-- an integer for the percentage width, so 100 would be 100%.
|
||||||
|
-- an integer for the minimum pixel height for xmobar, so 24 would force a height of at least 24 pixels.
|
||||||
|
-- NOTE: The height should be the same as the trayer (system tray) height.
|
||||||
|
, position = TopSize L 100 24
|
||||||
|
, lowerOnStart = True
|
||||||
|
, hideOnStart = False
|
||||||
|
, allDesktops = True
|
||||||
|
, persistent = True
|
||||||
|
, iconRoot = ".xmonad/xpm/" -- default: "."
|
||||||
|
, commands = [
|
||||||
|
-- Echos a "penguin" icon in front of the kernel output.
|
||||||
|
Run Com "echo" ["<fn=3>\xf17c</fn>"] "penguin" 3600
|
||||||
|
-- Get kernel version (script found in .local/bin)
|
||||||
|
, Run Com ".local/bin/kernel" [] "kernel" 36000
|
||||||
|
-- Cpu usage in percent
|
||||||
|
, Run Cpu ["-t", "<fn=2>\xf108</fn> cpu: (<total>%)","-H","50","--high","red"] 20
|
||||||
|
-- Ram used number and percent
|
||||||
|
, Run Memory ["-t", "<fn=2>\xf233</fn> mem: <used>M (<usedratio>%)"] 20
|
||||||
|
-- Disk space free
|
||||||
|
, Run DiskU [("/", "<fn=2>\xf0c7</fn> hdd: <free> free")] [] 60
|
||||||
|
-- Echos an "up arrow" icon in front of the uptime output.
|
||||||
|
, Run Com "echo" ["<fn=2>\xf0aa</fn>"] "uparrow" 3600
|
||||||
|
-- Uptime
|
||||||
|
, Run Uptime ["-t", "uptime: <days>d <hours>h"] 360
|
||||||
|
-- Echos a "bell" icon in front of the pacman updates.
|
||||||
|
, Run Com "echo" ["<fn=2>\xf0f3</fn>"] "bell" 3600
|
||||||
|
-- Check for pacman updates (script found in .local/bin)
|
||||||
|
, Run Com ".local/bin/pacupdate" [] "pacupdate" 36000
|
||||||
|
-- Echos a "battery" icon in front of the pacman updates.
|
||||||
|
, Run Com "echo" ["<fn=2>\xf242</fn>"] "baticon" 3600
|
||||||
|
-- Battery
|
||||||
|
, Run BatteryP ["BAT0"] ["-t", "<acstatus><watts> (<left>%)"] 360
|
||||||
|
-- Time and date
|
||||||
|
, Run Date "<fn=2>\xf017</fn> %b %d %Y - (%H:%M) " "date" 50
|
||||||
|
-- Prints out the left side items such as workspaces, layout, etc.
|
||||||
|
, Run UnsafeStdinReader
|
||||||
|
]
|
||||||
|
, sepChar = "%"
|
||||||
|
, alignSep = "}{"
|
||||||
|
, template = " }{ <box type=Bottom width=2 mb=2 color=#51afef><fc=#51afef>%penguin% %kernel%</fc></box> <box type=Bottom width=2 mb=2 color=#ecbe7b><fc=#ecbe7b><action=`alacritty -e htop`>%cpu%</action></fc></box> <box type=Bottom width=2 mb=2 color=#ff6c6b><fc=#ff6c6b><action=`alacritty -e htop`>%memory%</action></fc></box> <box type=Bottom width=2 mb=2 color=#a9a1e1><fc=#a9a1e1>%disku%</fc></box> <box type=Bottom width=2 mb=2 color=#98be65><fc=#98be65>%uparrow% %uptime%</fc></box> <box type=Bottom width=2 mb=2 color=#c678dd><fc=#c678dd>%bell% <action=`alacritty -e sudo pacman -Syu`>%pacupdate%</action></fc></box> <box type=Bottom width=2 mb=2 color=#da8548><fc=#da8548>%baticon% %battery%</fc></box> <box type=Bottom width=2 mb=2 color=#46d9ff><fc=#46d9ff><action=`emacsclient -c -a 'emacs' --eval '(doom/window-maximize-buffer(dt/year-calendar))'`>%date%</action></fc></box> %trayerpad%"
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
uname -r | grep -Eo '[[:digit:]]+[.][[:digit:]]+[.]+[[:digit:]]'
|
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
system=$(cat /etc/os-release | sed -n 3p)
|
||||||
|
|
||||||
|
if [[ $system == *"arch"* ]]
|
||||||
|
then
|
||||||
|
ip=$(ip -json route get 8.8.8.8 | jq -r '.[].prefsrc')
|
||||||
|
elif [[ $system == *"debian"* ]]
|
||||||
|
then
|
||||||
|
ip=$(hostname -I | awk '{print $1}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $ip
|
||||||
|
|
@ -0,0 +1,64 @@
|
|||||||
|
Config { font = "xft:Ubuntu:weight=bold:pixelsize=26:antialias=true:hinting=true"
|
||||||
|
, additionalFonts = [ "xft:Mononoki:pixelsize=18:antialias=true:hinting=true"
|
||||||
|
, "xft:Font Awesome 6 Free Solid:pixelsize=30"
|
||||||
|
, "xft:Font Awesome 6 Brands:pixelsize=30"
|
||||||
|
]
|
||||||
|
, bgColor = "#282c34"
|
||||||
|
, fgColor = "#ff6c6b"
|
||||||
|
, alpha = 255
|
||||||
|
, position = TopSize L 100 35
|
||||||
|
, textOffset = -1
|
||||||
|
, iconOffset = -1
|
||||||
|
, lowerOnStart = True
|
||||||
|
, persistent = True
|
||||||
|
, hideOnStart = False
|
||||||
|
, iconRoot = "."
|
||||||
|
, allDesktops = True
|
||||||
|
, overrideRedirect = True
|
||||||
|
, commands = [
|
||||||
|
-- Echos a "penguin" icon in front of the kernel output.
|
||||||
|
Run Com "echo" ["<fn=3>\xf17c</fn>"] "penguin" 36000
|
||||||
|
-- Get kernel version (script found in .local/bin)
|
||||||
|
, Run Com "/home/key/.config/xmobar/get_kernel.sh" [] "kernel" 36000
|
||||||
|
-- Echos a "rj45" icon in front of the ip output.
|
||||||
|
, Run Com "echo" ["<fn=2>\xf796</fn>"] "rj" 36000
|
||||||
|
-- Get the Current IP address
|
||||||
|
, Run Com "/home/key/.config/xmobar/ip.sh" [] "myip" 150
|
||||||
|
|
||||||
|
, Run Com "/home/key/.config/xmobar/battery.sh" [] "battery" 150
|
||||||
|
|
||||||
|
-- Dy Newtoek consumption
|
||||||
|
, Run DynNetwork [ "--template" , "<dev>: <tx>kB/s|<rx>kB/s"
|
||||||
|
, "--Low" , "5000" -- units: kB/s
|
||||||
|
, "--High" , "50000" -- units: kB/s
|
||||||
|
, "--low" , "darkgreen"
|
||||||
|
, "--normal" , "darkorange"
|
||||||
|
, "--high" , "darkred"
|
||||||
|
] 10
|
||||||
|
-- Cpu usage in percent
|
||||||
|
, Run Cpu ["-t", "<fn=2>\xf108</fn> cpu: (<total>%)","-H","50","--high","red"] 20
|
||||||
|
-- Ram used number and percent
|
||||||
|
, Run Memory ["-t", "<fn=2>\xf233</fn> mem: <used>M (<usedratio>%)"] 20
|
||||||
|
-- Disk space free
|
||||||
|
, Run DiskU [("/", "<fn=2>\xf0c7</fn> hdd: <free> free")] [] 60
|
||||||
|
-- Echos an "up arrow" icon in front of the uptime output.
|
||||||
|
, Run Com "echo" ["<fn=2>\xf0aa</fn>"] "uparrow" 3600
|
||||||
|
-- Uptime
|
||||||
|
, Run Uptime ["-t", "uptime: <days>d <hours>h"] 360
|
||||||
|
-- Echos a "bell" icon in front of the pacman updates.
|
||||||
|
, Run Com "echo" ["<fn=2>\xf0f3</fn>"] "bell" 3600
|
||||||
|
-- Check for pacman updates (script found in .local/bin)
|
||||||
|
, Run Com ".local/bin/pacupdate" [] "pacupdate" 36000
|
||||||
|
-- Echos a "battery" icon in front of the pacman updates.
|
||||||
|
, Run Com "echo" ["<fn=2>\xf242</fn>"] "baticon" 3600
|
||||||
|
-- Battery
|
||||||
|
, Run Date "<fn=2>\xf017</fn> %b %d %Y - (%H:%M) " "date" 50
|
||||||
|
-- Prints out the left side items such as workspaces, layout, etc.
|
||||||
|
, Run UnsafeStdinReader
|
||||||
|
]
|
||||||
|
, sepChar = "%"
|
||||||
|
, alignSep = "}{"
|
||||||
|
, template = "<box type=Bottom width=2 mb=2 color=#51afef><fc=#51afef>%penguin% %kernel%</fc></box> <box type=Bottom width=2 mb=2 color=#DA8012><fc=#DA8012> %rj% %dynnetwork% IP:%myip%</fc></box>}<box type=Bottom width=2 mb=2 color=#1259DA><fc=#1259DA>%date%</fc></box>{<box type=Bottom width=2 mb=2 color=#DC143C><fc=#DC143C>%battery% %baticon%</fc></box> <box type=Bottom width=2 mb=2 color=#ecbe7b><fc=#ecbe7b><action=`alacritty -e htop`>%cpu%</action></fc></box> "
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,313 @@
|
|||||||
|
-- KeY Defined : Imports
|
||||||
|
import XMonad
|
||||||
|
import XMonad.Util.EZConfig (additionalKeysP, mkNamedKeymap) -- Vim Style Key defines
|
||||||
|
import XMonad.Util.Dmenu -- Excatly what it says
|
||||||
|
import XMonad.Util.Ungrab -- For screenshots
|
||||||
|
import XMonad.Layout.ThreeColumns -- For big scrrens
|
||||||
|
import XMonad.Hooks.EwmhDesktops
|
||||||
|
import XMonad.Layout.Spacing
|
||||||
|
import XMonad.Layout.LayoutModifier
|
||||||
|
import XMonad.Layout.Gaps
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- Default defined
|
||||||
|
import Data.Monoid
|
||||||
|
import System.Exit
|
||||||
|
import XMonad.Layout.NoBorders
|
||||||
|
import XMonad.Hooks.ManageDocks
|
||||||
|
import XMonad.Hooks.ManageHelpers
|
||||||
|
import XMonad.Util.Run
|
||||||
|
import XMonad.Util.SpawnOnce
|
||||||
|
import XMonad.Actions.Navigation2D
|
||||||
|
import XMonad.Util.NamedActions
|
||||||
|
import Data.Maybe (fromJust)
|
||||||
|
import XMonad.Layout.ShowWName
|
||||||
|
import XMonad.Layout.ThreeColumns
|
||||||
|
import qualified XMonad.StackSet as W
|
||||||
|
import qualified Data.Map as M
|
||||||
|
|
||||||
|
-- KeY Defined : Terminal
|
||||||
|
myTerminal :: String
|
||||||
|
myTerminal = "alacritty"
|
||||||
|
|
||||||
|
-- KeY Defined : Shell interpreter
|
||||||
|
myShell :: String
|
||||||
|
myShell = "fish"
|
||||||
|
|
||||||
|
-- KeY Defined default web browser the sapce at the end is important.
|
||||||
|
myBrowser :: String
|
||||||
|
myBrowser = "qutebrowser "
|
||||||
|
|
||||||
|
-- KeY Defined default App Launcher.
|
||||||
|
myLauncher :: String
|
||||||
|
myLauncher = "dmenu_run "
|
||||||
|
|
||||||
|
-- KeY Defined Whether focus follows the mouse pointer.
|
||||||
|
myFocusFollowsMouse :: Bool
|
||||||
|
myFocusFollowsMouse = True
|
||||||
|
|
||||||
|
-- KeY Defined : Whether clicking on a window to focus also passes the click to the window
|
||||||
|
myClickJustFocuses :: Bool
|
||||||
|
myClickJustFocuses = False
|
||||||
|
|
||||||
|
-- KeY Defined : Width of the window border in pixels.
|
||||||
|
myBorderWidth = 3
|
||||||
|
|
||||||
|
-- KeY Defined : "windows key" = mod4Mask.
|
||||||
|
myModMask = mod4Mask
|
||||||
|
|
||||||
|
-- myWorkspaces = [" 1 ", " 2 ", " 3 ", " 4 ", " 5 ", " 6 ", " 7 ", " 8 ", " 9 "]
|
||||||
|
myWorkspaces = [" dev ", " www ", " sys ", " doc ", " vbox ", " chat ", " mus ", " vid ", " gfx "]
|
||||||
|
myWorkspaceIndices = M.fromList $ zipWith (,) myWorkspaces [1..] -- (,) == \x y -> (x,y)
|
||||||
|
|
||||||
|
clickable ws = "<action=xdotool key super+"++show i++">"++ws++"</action>"
|
||||||
|
where i = fromJust $ M.lookup ws myWorkspaceIndices
|
||||||
|
|
||||||
|
-- KeY Defined : Border colors for unfocused and focused windows, respectively.
|
||||||
|
myNormalBorderColor = "#dddddd" -- White
|
||||||
|
myFocusedBorderColor = "#F000FF" -- Purple
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- Key Defined : Key bindings. Add, modify or remove key bindings here.
|
||||||
|
--
|
||||||
|
myKeys conf@(XConfig {XMonad.modMask = modm}) = M.fromList $
|
||||||
|
|
||||||
|
-- KeY Defined : launch default terminal with the default Shell
|
||||||
|
[ ((modm, xK_Return), spawn $ (myTerminal ++ " -e " ++ myShell))
|
||||||
|
|
||||||
|
-- KeY Defined : Volume Up
|
||||||
|
, ((modm, xK_F3 ), spawn "amixer set Master 2%+")
|
||||||
|
|
||||||
|
-- KeY Defined : Volume Up
|
||||||
|
, ((modm, xK_F2 ), spawn "amixer set Master 2%-")
|
||||||
|
|
||||||
|
-- KeY Defined : Toggle mute
|
||||||
|
, ((modm, xK_F1 ), spawn "amixer -D pulse set Master 1+ toggle")
|
||||||
|
|
||||||
|
-- KeY Defined : Launch (p)rogramms
|
||||||
|
, ((modm, xK_p ), spawn $ (myLauncher))
|
||||||
|
|
||||||
|
-- KeY Defined : Launch (i)nternet Explorer
|
||||||
|
, ((modm, xK_i ), spawn $ (myBrowser))
|
||||||
|
|
||||||
|
-- KeY Defined : (c)lose focused window
|
||||||
|
, ((modm, xK_c ), kill)
|
||||||
|
|
||||||
|
-- KeY Defined : Rotate through the available layout algorithms
|
||||||
|
, ((modm, xK_space ), sendMessage NextLayout)
|
||||||
|
|
||||||
|
-- KeY Defined : Reset the layouts on the current workspace to default
|
||||||
|
, ((modm .|. shiftMask, xK_space ), setLayout $ XMonad.layoutHook conf)
|
||||||
|
|
||||||
|
-- KeY Definded : Take A (S)crenn Shot
|
||||||
|
, ((modm .|. shiftMask, xK_s ), unGrab *> spawn "scrot -s")
|
||||||
|
|
||||||
|
-- Resize viewed windows to the correct size
|
||||||
|
, ((modm, xK_n ), refresh)
|
||||||
|
|
||||||
|
-- Move focus to the next window
|
||||||
|
, ((modm, xK_Tab ), windows W.focusDown)
|
||||||
|
|
||||||
|
-- KeY Defined : Move focus to the next window
|
||||||
|
, ((modm, xK_j ), windows W.focusDown)
|
||||||
|
|
||||||
|
-- KeY Defined : Move focus to the previous window
|
||||||
|
, ((modm, xK_k ), windows W.focusUp )
|
||||||
|
|
||||||
|
-- Move focus to the master window
|
||||||
|
, ((modm, xK_m ), windows W.focusMaster )
|
||||||
|
|
||||||
|
-- Swap the focused window and the master window
|
||||||
|
, ((modm .|. shiftMask, xK_Return), windows W.swapMaster)
|
||||||
|
|
||||||
|
-- KeY Defined : Swap the focused window with the next window
|
||||||
|
, ((modm .|. shiftMask, xK_j ), windows W.swapDown )
|
||||||
|
|
||||||
|
-- KeY Defined : Swap the focused window with the previous window
|
||||||
|
, ((modm .|. shiftMask, xK_k ), windows W.swapUp )
|
||||||
|
|
||||||
|
-- KeY Defined : Shrink the master area
|
||||||
|
, ((modm, xK_h ), sendMessage Shrink)
|
||||||
|
|
||||||
|
-- KeY Defined : Expand the master area
|
||||||
|
, ((modm, xK_l ), sendMessage Expand)
|
||||||
|
|
||||||
|
-- Push window back into tiling
|
||||||
|
, ((modm, xK_t ), withFocused $ windows . W.sink)
|
||||||
|
|
||||||
|
-- Increment the number of windows in the master area
|
||||||
|
, ((modm , xK_comma ), sendMessage (IncMasterN 1))
|
||||||
|
|
||||||
|
-- Deincrement the number of windows in the master area
|
||||||
|
, ((modm , xK_period), sendMessage (IncMasterN (-1)))
|
||||||
|
|
||||||
|
-- KeY Defined : (Q)uit xmonad
|
||||||
|
, ((modm .|. shiftMask, xK_q ), io (exitWith ExitSuccess))
|
||||||
|
|
||||||
|
-- KeY Defined : (q) Restart xmonad
|
||||||
|
, ((modm , xK_q ), spawn "rm -r /home/key/.xmonad ; xmonad --recompile; xmonad --restart; pkill xmobar")
|
||||||
|
|
||||||
|
]
|
||||||
|
++
|
||||||
|
|
||||||
|
--
|
||||||
|
-- mod-[1..9], Switch to workspace N
|
||||||
|
-- mod-shift-[1..9], Move client to workspace N
|
||||||
|
--
|
||||||
|
[((m .|. modm, k), windows $ f i)
|
||||||
|
| (i, k) <- zip (XMonad.workspaces conf) [xK_1 .. xK_9]
|
||||||
|
, (f, m) <- [(W.greedyView, 0), (W.shift, shiftMask)]]
|
||||||
|
++
|
||||||
|
|
||||||
|
--
|
||||||
|
-- mod-{w,e,r}, Switch to physical/Xinerama screens 1, 2, or 3
|
||||||
|
-- mod-shift-{w,e,r}, Move client to screen 1, 2, or 3
|
||||||
|
--
|
||||||
|
[((m .|. modm, key), screenWorkspace sc >>= flip whenJust (windows . f))
|
||||||
|
| (key, sc) <- zip [xK_w, xK_e, xK_r] [0..]
|
||||||
|
, (f, m) <- [(W.view, 0), (W.shift, shiftMask)]]
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- Mouse bindings: default actions bound to mouse events
|
||||||
|
--
|
||||||
|
myMouseBindings (XConfig {XMonad.modMask = modm}) = M.fromList $
|
||||||
|
|
||||||
|
-- mod-button1, Set the window to floating mode and move by dragging
|
||||||
|
[ ((modm, button1), (\w -> focus w >> mouseMoveWindow w
|
||||||
|
>> windows W.shiftMaster))
|
||||||
|
|
||||||
|
-- mod-button2, Raise the window to the top of the stack
|
||||||
|
, ((modm, button2), (\w -> focus w >> windows W.shiftMaster))
|
||||||
|
|
||||||
|
-- mod-button3, Set the window to floating mode and resize by dragging
|
||||||
|
, ((modm, button3), (\w -> focus w >> mouseResizeWindow w
|
||||||
|
>> windows W.shiftMaster))
|
||||||
|
|
||||||
|
-- you may also bind events to the mouse scroll wheel (button4 and button5)
|
||||||
|
]
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- Layouts:
|
||||||
|
|
||||||
|
-- You can specify and transform your layouts by modifying these values.
|
||||||
|
-- If you change layout bindings be sure to use 'mod-shift-space' after
|
||||||
|
-- restarting (with 'mod-q') to reset your layout state to the new
|
||||||
|
-- defaults, as xmonad preserves your old layout settings by default.
|
||||||
|
--
|
||||||
|
-- The available layouts. Note that each layout is separated by |||,
|
||||||
|
-- which denotes layout choice.
|
||||||
|
--
|
||||||
|
myLayout = avoidStruts (tiled ||| Mirror tiled ||| Full)
|
||||||
|
where
|
||||||
|
-- default tiling algorithm partitions the screen into two panes
|
||||||
|
tiled = Tall nmaster delta ratio
|
||||||
|
|
||||||
|
-- The default number of windows in the master pane
|
||||||
|
nmaster = 1
|
||||||
|
|
||||||
|
-- Default proportion of screen occupied by master pane
|
||||||
|
ratio = 1/2
|
||||||
|
|
||||||
|
-- Percent of screen to increment by when resizing panes
|
||||||
|
delta = 3/100
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- Window rules:
|
||||||
|
|
||||||
|
-- Execute arbitrary actions and WindowSet manipulations when managing
|
||||||
|
-- a new window. You can use this to, for example, always float a
|
||||||
|
-- particular program, or have a client always appear on a particular
|
||||||
|
-- workspace.
|
||||||
|
--
|
||||||
|
-- To find the property name associated with a program, use
|
||||||
|
-- > xprop | grep WM_CLASS
|
||||||
|
-- and click on the client you're interested in.
|
||||||
|
--
|
||||||
|
-- To match on the WM_NAME, you can use 'title' in the same way that
|
||||||
|
-- 'className' and 'resource' are used below.
|
||||||
|
--
|
||||||
|
|
||||||
|
-- KeY Defined
|
||||||
|
myManageHook = composeAll
|
||||||
|
[ className =? "MPlayer" --> doFloat
|
||||||
|
, className =? "Gimp" --> doFloat
|
||||||
|
, className =? "Steam" --> doFullFloat
|
||||||
|
, className =? "factorio" --> doFullFloat
|
||||||
|
, className =? "TerraTechLinux64.x86_64" --> doFullFloat
|
||||||
|
, resource =? "desktop_window" --> doIgnore
|
||||||
|
, resource =? "kdesktop" --> doIgnore
|
||||||
|
, manageDocks
|
||||||
|
]
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- Event handling
|
||||||
|
|
||||||
|
-- * EwmhDesktops users should change this to ewmhDesktopsEventHook
|
||||||
|
--
|
||||||
|
-- Defines a custom handler function for X Events. The function should
|
||||||
|
-- return (All True) if the default handler is to be run afterwards. To
|
||||||
|
-- combine event hooks use mappend or mconcat from Data.Monoid.
|
||||||
|
--
|
||||||
|
myEventHook = mempty
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- Status bars and logging
|
||||||
|
|
||||||
|
-- Perform an arbitrary action on each internal state change or X event.
|
||||||
|
-- See the 'XMonad.Hooks.DynamicLog' extension for examples.
|
||||||
|
--
|
||||||
|
myLogHook = mempty
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- Startup hook
|
||||||
|
|
||||||
|
-- Perform an arbitrary action each time xmonad starts or is restarted
|
||||||
|
-- with mod-q. Used by, e.g., XMonad.Layout.PerWorkspace to initialize
|
||||||
|
-- per-workspace layout choices.
|
||||||
|
--
|
||||||
|
-- By default, do nothing.
|
||||||
|
myStartupHook = do
|
||||||
|
spawnOnce "compton &"
|
||||||
|
spawnOnce "feh --bg-fill --randomize $HOME/wallpaper/* &"
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------------------------------------------------
|
||||||
|
-- Now run xmonad with all the defaults we set up.
|
||||||
|
|
||||||
|
-- Run xmonad with the settings you specify. No need to modify this.
|
||||||
|
--
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
xmproc <- spawnPipe ("xmobar $HOME/.config/xmobar/xmobarrc.hs")
|
||||||
|
xmonad $ docks defaults
|
||||||
|
|
||||||
|
|
||||||
|
-- A structure containing your configuration settings, overriding
|
||||||
|
-- fields in the default config. Any you don't override, will
|
||||||
|
-- use the defaults defined in xmonad/XMonad/Config.hs
|
||||||
|
--
|
||||||
|
-- No need to modify this.
|
||||||
|
--
|
||||||
|
defaults = def {
|
||||||
|
-- simple stuff
|
||||||
|
terminal = myTerminal,
|
||||||
|
focusFollowsMouse = myFocusFollowsMouse,
|
||||||
|
clickJustFocuses = myClickJustFocuses,
|
||||||
|
borderWidth = myBorderWidth,
|
||||||
|
modMask = myModMask,
|
||||||
|
workspaces = myWorkspaces,
|
||||||
|
normalBorderColor = myNormalBorderColor,
|
||||||
|
focusedBorderColor = myFocusedBorderColor,
|
||||||
|
|
||||||
|
-- key bindings
|
||||||
|
keys = myKeys,
|
||||||
|
mouseBindings = myMouseBindings,
|
||||||
|
|
||||||
|
-- hooks, layouts
|
||||||
|
layoutHook = spacingRaw True (Border 0 5 5 5) True (Border 5 5 5 5) True $ myLayout,
|
||||||
|
manageHook = myManageHook,
|
||||||
|
handleEventHook = myEventHook,
|
||||||
|
logHook = myLogHook,
|
||||||
|
startupHook = myStartupHook
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
|
||||||
|
sudo $installCMD cmake pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev libxkbcommon-dev
|
||||||
|
git clone https://github.com/alacritty/alacritty.git
|
||||||
|
sudo curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
||||||
|
source $HOME/.cargo/env
|
||||||
|
cd alacritty/
|
||||||
|
cargo build --release -j16
|
||||||
|
sudo cp target/release/alacritty /usr/local/bin
|
||||||
|
sudo cp extra/logo/alacritty-term.svg /usr/share/pixmaps/Alacritty.svg
|
||||||
|
cd ..
|
||||||
|
sudo rm -r alacritty/
|
||||||
|
|
||||||
|
cp -r $main_dir/dotfiles/alacritty /home/$USER/.config/
|
@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source common.sh
|
||||||
|
yay brave-bin
|
@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
version="5.2"
|
||||||
|
|
||||||
|
fontSize=0
|
||||||
|
|
||||||
|
dmenu_set_font_size()
|
||||||
|
{
|
||||||
|
color_start "themeUserINput"
|
||||||
|
read -p "What siez fint would you like (6 to 34): " fontSize
|
||||||
|
color_stop
|
||||||
|
sed -i -e "s/size=../size=$fontSize/g" config.h
|
||||||
|
}
|
||||||
|
|
||||||
|
dmenu_intro()
|
||||||
|
{
|
||||||
|
color_start "themeInstall"
|
||||||
|
echo ""
|
||||||
|
echo "Dmenu verison : $version Will be installed"
|
||||||
|
color_stop
|
||||||
|
color_start "themeIndication"
|
||||||
|
echo "Currently used mods are :"
|
||||||
|
ls | grep -oP '.*diff'
|
||||||
|
color_stop
|
||||||
|
}
|
||||||
|
|
||||||
|
dmenu_outro()
|
||||||
|
{
|
||||||
|
color_start "themeInstall"
|
||||||
|
echo "Dmenu installation complete"
|
||||||
|
echo ""
|
||||||
|
color_stop
|
||||||
|
}
|
||||||
|
|
||||||
|
dmenu_install_debian()
|
||||||
|
{
|
||||||
|
cd $MAIN_DIR/programs/dmenu/dmenu_$version/
|
||||||
|
dmenu_intro
|
||||||
|
dmenu_set_font_size
|
||||||
|
sudo make install
|
||||||
|
dmenu_outro
|
||||||
|
}
|
||||||
|
|
||||||
|
dmenu_install_arch()
|
||||||
|
{
|
||||||
|
cd $MAIN_DIR/programs/dmenu/dmenu_$version/
|
||||||
|
dmenu_intro
|
||||||
|
dmenu_set_font_size
|
||||||
|
echo sudo make install
|
||||||
|
dmenu_outro
|
||||||
|
}
|
||||||
|
|
||||||
|
dmenu_install_raspberry()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,64 @@
|
|||||||
|
# dmenu - dynamic menu
|
||||||
|
# See LICENSE file for copyright and license details.
|
||||||
|
|
||||||
|
include config.mk
|
||||||
|
|
||||||
|
SRC = drw.c dmenu.c stest.c util.c
|
||||||
|
OBJ = $(SRC:.c=.o)
|
||||||
|
|
||||||
|
all: options dmenu stest
|
||||||
|
|
||||||
|
options:
|
||||||
|
@echo dmenu build options:
|
||||||
|
@echo "CFLAGS = $(CFLAGS)"
|
||||||
|
@echo "LDFLAGS = $(LDFLAGS)"
|
||||||
|
@echo "CC = $(CC)"
|
||||||
|
|
||||||
|
.c.o:
|
||||||
|
$(CC) -c $(CFLAGS) $<
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
cp config.def.h $@
|
||||||
|
|
||||||
|
$(OBJ): arg.h config.h config.mk drw.h
|
||||||
|
|
||||||
|
dmenu: dmenu.o drw.o util.o
|
||||||
|
$(CC) -o $@ dmenu.o drw.o util.o $(LDFLAGS)
|
||||||
|
|
||||||
|
stest: stest.o
|
||||||
|
$(CC) -o $@ stest.o $(LDFLAGS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f dmenu stest $(OBJ) dmenu-$(VERSION).tar.gz
|
||||||
|
|
||||||
|
dist: clean
|
||||||
|
mkdir -p dmenu-$(VERSION)
|
||||||
|
cp LICENSE Makefile README arg.h config.def.h config.mk dmenu.1\
|
||||||
|
drw.h util.h dmenu_path dmenu_run stest.1 $(SRC)\
|
||||||
|
dmenu-$(VERSION)
|
||||||
|
tar -cf dmenu-$(VERSION).tar dmenu-$(VERSION)
|
||||||
|
gzip dmenu-$(VERSION).tar
|
||||||
|
rm -rf dmenu-$(VERSION)
|
||||||
|
|
||||||
|
install: all
|
||||||
|
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
||||||
|
cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin
|
||||||
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu
|
||||||
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path
|
||||||
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run
|
||||||
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/stest
|
||||||
|
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
|
||||||
|
sed "s/VERSION/$(VERSION)/g" < dmenu.1 > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
|
||||||
|
sed "s/VERSION/$(VERSION)/g" < stest.1 > $(DESTDIR)$(MANPREFIX)/man1/stest.1
|
||||||
|
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/dmenu.1
|
||||||
|
chmod 644 $(DESTDIR)$(MANPREFIX)/man1/stest.1
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f $(DESTDIR)$(PREFIX)/bin/dmenu\
|
||||||
|
$(DESTDIR)$(PREFIX)/bin/dmenu_path\
|
||||||
|
$(DESTDIR)$(PREFIX)/bin/dmenu_run\
|
||||||
|
$(DESTDIR)$(PREFIX)/bin/stest\
|
||||||
|
$(DESTDIR)$(MANPREFIX)/man1/dmenu.1\
|
||||||
|
$(DESTDIR)$(MANPREFIX)/man1/stest.1
|
||||||
|
|
||||||
|
.PHONY: all options clean dist install uninstall
|
@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copy me if you can.
|
||||||
|
* by 20h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ARG_H__
|
||||||
|
#define ARG_H__
|
||||||
|
|
||||||
|
extern char *argv0;
|
||||||
|
|
||||||
|
/* use main(int argc, char *argv[]) */
|
||||||
|
#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
|
||||||
|
argv[0] && argv[0][0] == '-'\
|
||||||
|
&& argv[0][1];\
|
||||||
|
argc--, argv++) {\
|
||||||
|
char argc_;\
|
||||||
|
char **argv_;\
|
||||||
|
int brk_;\
|
||||||
|
if (argv[0][1] == '-' && argv[0][2] == '\0') {\
|
||||||
|
argv++;\
|
||||||
|
argc--;\
|
||||||
|
break;\
|
||||||
|
}\
|
||||||
|
for (brk_ = 0, argv[0]++, argv_ = argv;\
|
||||||
|
argv[0][0] && !brk_;\
|
||||||
|
argv[0]++) {\
|
||||||
|
if (argv_ != argv)\
|
||||||
|
break;\
|
||||||
|
argc_ = argv[0][0];\
|
||||||
|
switch (argc_)
|
||||||
|
|
||||||
|
#define ARGEND }\
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ARGC() argc_
|
||||||
|
|
||||||
|
#define EARGF(x) ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||||
|
((x), abort(), (char *)0) :\
|
||||||
|
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||||
|
(&argv[0][1]) :\
|
||||||
|
(argc--, argv++, argv[0])))
|
||||||
|
|
||||||
|
#define ARGF() ((argv[0][1] == '\0' && argv[1] == NULL)?\
|
||||||
|
(char *)0 :\
|
||||||
|
(brk_ = 1, (argv[0][1] != '\0')?\
|
||||||
|
(&argv[0][1]) :\
|
||||||
|
(argc--, argv++, argv[0])))
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,40 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
|
static int centered = 0; /* -c option; centers dmenu on screen */
|
||||||
|
static int min_width = 500; /* minimum width when centered */
|
||||||
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
static const char *fonts[] = {
|
||||||
|
"monospace:size=10"
|
||||||
|
};
|
||||||
|
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||||
|
static const char *colors[SchemeLast][2] = {
|
||||||
|
/* fg bg */
|
||||||
|
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||||
|
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||||
|
[SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||||
|
[SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||||
|
[SchemeOut] = { "#000000", "#00ffff" },
|
||||||
|
};
|
||||||
|
|
||||||
|
static const unsigned int alphas[SchemeLast][2] = {
|
||||||
|
[SchemeNorm] = { OPAQUE, alpha },
|
||||||
|
[SchemeSel] = { OPAQUE, alpha },
|
||||||
|
[SchemeOut] = { OPAQUE, alpha },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
static unsigned int lines = 0;
|
||||||
|
/* -h option; minimum height of a menu line */
|
||||||
|
static unsigned int lineheight = 0;
|
||||||
|
static unsigned int min_lineheight = 8;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Characters not considered part of a word while deleting words
|
||||||
|
* for example: " /?\"&[]"
|
||||||
|
*/
|
||||||
|
static const char worddelimiters[] = " ";
|
||||||
|
|
||||||
|
/* Size of the window border */
|
||||||
|
static const unsigned int border_width = 5;
|
@ -0,0 +1,33 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
|
static int centered = 0; /* -c option; centers dmenu on screen */
|
||||||
|
static int min_width = 500; /* minimum width when centered */
|
||||||
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
static const char *fonts[] = {
|
||||||
|
"monospace:size=10"
|
||||||
|
};
|
||||||
|
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||||
|
static const char *colors[SchemeLast][2] = {
|
||||||
|
/* fg bg */
|
||||||
|
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||||
|
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||||
|
[SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||||
|
[SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||||
|
[SchemeOut] = { "#000000", "#00ffff" },
|
||||||
|
};
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
static unsigned int lines = 0;
|
||||||
|
/* -h option; minimum height of a menu line */
|
||||||
|
static unsigned int lineheight = 0;
|
||||||
|
static unsigned int min_lineheight = 8;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Characters not considered part of a word while deleting words
|
||||||
|
* for example: " /?\"&[]"
|
||||||
|
*/
|
||||||
|
static const char worddelimiters[] = " ";
|
||||||
|
|
||||||
|
/* Size of the window border */
|
||||||
|
static const unsigned int border_width = 5;
|
@ -0,0 +1,10 @@
|
|||||||
|
--- config.def.h
|
||||||
|
+++ config.def.h
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
|
+static const unsigned int alpha = 0xf0;
|
||||||
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
static const char *fonts[] = {
|
||||||
|
"monospace:size=10"
|
@ -0,0 +1,41 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
|
static const unsigned int alpha = 0xf0;
|
||||||
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
static const char *fonts[] = {
|
||||||
|
//"monospace:size=24
|
||||||
|
"xft:Ubuntu:weight=bold:pixelsize=24antialias=true:hinting=true"
|
||||||
|
};
|
||||||
|
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||||
|
|
||||||
|
static const unsigned int alphas[SchemeLast][2] = {
|
||||||
|
[SchemeNorm] = { OPAQUE, alpha },
|
||||||
|
[SchemeSel] = { OPAQUE, alpha },
|
||||||
|
[SchemeOut] = { OPAQUE, alpha },
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const char *colors[SchemeLast][2] = {
|
||||||
|
/* fg bg */
|
||||||
|
[SchemeNorm] = { "#F7774C", "#002b36" },
|
||||||
|
[SchemeSel] = { "#F7774C", "#073642"},
|
||||||
|
[SchemeOut] = { "#000000", "#00ffff" },
|
||||||
|
[SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||||
|
[SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||||
|
};
|
||||||
|
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
static unsigned int lines = 20;
|
||||||
|
|
||||||
|
static const unsigned int border_width = 5;
|
||||||
|
static unsigned int lineheight = 32;
|
||||||
|
static unsigned int min_lineheight = 8;
|
||||||
|
static int centered = 1; /* -c option; centers dmenu on screen */
|
||||||
|
static int min_width = 1000;
|
||||||
|
/*
|
||||||
|
* Characters not considered part of a word while deleting words
|
||||||
|
* for example: " /?\"&[]"
|
||||||
|
*/
|
||||||
|
static const char worddelimiters[] = " ";
|
@ -0,0 +1,32 @@
|
|||||||
|
# dmenu version
|
||||||
|
VERSION = 5.2
|
||||||
|
|
||||||
|
# paths
|
||||||
|
PREFIX = /usr/local
|
||||||
|
MANPREFIX = $(PREFIX)/share/man
|
||||||
|
|
||||||
|
X11INC = /usr/X11R6/include
|
||||||
|
X11LIB = /usr/X11R6/lib
|
||||||
|
|
||||||
|
# Xinerama, comment if you don't want it
|
||||||
|
XINERAMALIBS = -lXinerama
|
||||||
|
XINERAMAFLAGS = -DXINERAMA
|
||||||
|
|
||||||
|
# freetype
|
||||||
|
FREETYPELIBS = -lfontconfig -lXft
|
||||||
|
FREETYPEINC = /usr/include/freetype2
|
||||||
|
# OpenBSD (uncomment)
|
||||||
|
#FREETYPEINC = $(X11INC)/freetype2
|
||||||
|
#MANPREFIX = ${PREFIX}/man
|
||||||
|
|
||||||
|
# includes and libs
|
||||||
|
INCS = -I$(X11INC) -I$(FREETYPEINC)
|
||||||
|
LIBS = -L$(X11LIB) -lX11 -lXrender $(XINERAMALIBS) $(FREETYPELIBS)
|
||||||
|
|
||||||
|
# flags
|
||||||
|
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION)\" $(XINERAMAFLAGS)
|
||||||
|
CFLAGS = -std=c99 -pedantic -Wall -Os $(INCS) $(CPPFLAGS)
|
||||||
|
LDFLAGS = $(LIBS)
|
||||||
|
|
||||||
|
# compiler and linker
|
||||||
|
CC = cc
|
@ -0,0 +1,267 @@
|
|||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1edb647..697d511 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
|
+static const unsigned int alpha = 0xf0;
|
||||||
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
static const char *fonts[] = {
|
||||||
|
"monospace:size=10"
|
||||||
|
@@ -13,6 +14,13 @@ static const char *colors[SchemeLast][2] = {
|
||||||
|
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||||
|
[SchemeOut] = { "#000000", "#00ffff" },
|
||||||
|
};
|
||||||
|
+
|
||||||
|
+static const unsigned int alphas[SchemeLast][2] = {
|
||||||
|
+ [SchemeNorm] = { OPAQUE, alpha },
|
||||||
|
+ [SchemeSel] = { OPAQUE, alpha },
|
||||||
|
+ [SchemeOut] = { OPAQUE, alpha },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
static unsigned int lines = 0;
|
||||||
|
|
||||||
|
diff --git a/dmenu.c b/dmenu.c
|
||||||
|
index 65f25ce..3e56e1a 100644
|
||||||
|
--- a/dmenu.c
|
||||||
|
+++ b/dmenu.c
|
||||||
|
@@ -10,6 +10,7 @@
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
+#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#ifdef XINERAMA
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
@@ -25,6 +26,8 @@
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
|
+#define OPAQUE 0xffU
|
||||||
|
+
|
||||||
|
/* enums */
|
||||||
|
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
|
||||||
|
|
||||||
|
@@ -53,10 +56,16 @@ static XIC xic;
|
||||||
|
static Drw *drw;
|
||||||
|
static Clr *scheme[SchemeLast];
|
||||||
|
|
||||||
|
+static int useargb = 0;
|
||||||
|
+static Visual *visual;
|
||||||
|
+static int depth;
|
||||||
|
+static Colormap cmap;
|
||||||
|
+
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||||
|
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||||
|
+static void xinitvisual();
|
||||||
|
|
||||||
|
static void
|
||||||
|
appenditem(struct item *item, struct item **list, struct item **last)
|
||||||
|
@@ -602,7 +611,7 @@ setup(void)
|
||||||
|
#endif
|
||||||
|
/* init appearance */
|
||||||
|
for (j = 0; j < SchemeLast; j++)
|
||||||
|
- scheme[j] = drw_scm_create(drw, colors[j], 2);
|
||||||
|
+ scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2);
|
||||||
|
|
||||||
|
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||||
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
@@ -640,6 +649,7 @@ setup(void)
|
||||||
|
x = info[i].x_org;
|
||||||
|
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||||
|
mw = info[i].width;
|
||||||
|
+
|
||||||
|
XFree(info);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
@@ -657,11 +667,13 @@ setup(void)
|
||||||
|
|
||||||
|
/* create menu window */
|
||||||
|
swa.override_redirect = True;
|
||||||
|
- swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||||
|
+ swa.background_pixel = 0;
|
||||||
|
+ swa.border_pixel = 0;
|
||||||
|
+ swa.colormap = cmap;
|
||||||
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
|
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||||
|
- CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
|
- CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
|
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||||
|
+ depth, CopyFromParent, visual,
|
||||||
|
+ CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa);
|
||||||
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -747,7 +759,8 @@ main(int argc, char *argv[])
|
||||||
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
|
parentwin);
|
||||||
|
- drw = drw_create(dpy, screen, root, wa.width, wa.height);
|
||||||
|
+ xinitvisual();
|
||||||
|
+ drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap);
|
||||||
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||||
|
die("no fonts could be loaded.");
|
||||||
|
lrpad = drw->fonts->h;
|
||||||
|
@@ -769,3 +782,40 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
|
return 1; /* unreachable */
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ void
|
||||||
|
+xinitvisual()
|
||||||
|
+{
|
||||||
|
+ XVisualInfo *infos;
|
||||||
|
+ XRenderPictFormat *fmt;
|
||||||
|
+ int nitems;
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ XVisualInfo tpl = {
|
||||||
|
+ .screen = screen,
|
||||||
|
+ .depth = 32,
|
||||||
|
+ .class = TrueColor
|
||||||
|
+ };
|
||||||
|
+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
|
||||||
|
+
|
||||||
|
+ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
|
||||||
|
+ visual = NULL;
|
||||||
|
+ for(i = 0; i < nitems; i ++) {
|
||||||
|
+ fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
|
||||||
|
+ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
|
||||||
|
+ visual = infos[i].visual;
|
||||||
|
+ depth = infos[i].depth;
|
||||||
|
+ cmap = XCreateColormap(dpy, root, visual, AllocNone);
|
||||||
|
+ useargb = 1;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ XFree(infos);
|
||||||
|
+
|
||||||
|
+ if (! visual) {
|
||||||
|
+ visual = DefaultVisual(dpy, screen);
|
||||||
|
+ depth = DefaultDepth(dpy, screen);
|
||||||
|
+ cmap = DefaultColormap(dpy, screen);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/drw.c b/drw.c
|
||||||
|
index 4cdbcbe..fe3aadd 100644
|
||||||
|
--- a/drw.c
|
||||||
|
+++ b/drw.c
|
||||||
|
@@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen)
|
||||||
|
}
|
||||||
|
|
||||||
|
Drw *
|
||||||
|
-drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||||
|
+drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
|
||||||
|
{
|
||||||
|
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||||
|
|
||||||
|
@@ -70,8 +70,11 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
|
||||||
|
drw->root = root;
|
||||||
|
drw->w = w;
|
||||||
|
drw->h = h;
|
||||||
|
- drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||||
|
- drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||||
|
+ drw->visual = visual;
|
||||||
|
+ drw->depth = depth;
|
||||||
|
+ drw->cmap = cmap;
|
||||||
|
+ drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
|
||||||
|
+ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
|
||||||
|
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
|
|
||||||
|
return drw;
|
||||||
|
@@ -87,7 +90,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||||
|
drw->h = h;
|
||||||
|
if (drw->drawable)
|
||||||
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
|
- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||||
|
+ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -194,21 +197,22 @@ drw_fontset_free(Fnt *font)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
-drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||||
|
+drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha)
|
||||||
|
{
|
||||||
|
if (!drw || !dest || !clrname)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||||
|
- DefaultColormap(drw->dpy, drw->screen),
|
||||||
|
+ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
|
||||||
|
clrname, dest))
|
||||||
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
|
+
|
||||||
|
+ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
|
* returned color scheme when done using it. */
|
||||||
|
Clr *
|
||||||
|
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
|
+drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
Clr *ret;
|
||||||
|
@@ -218,7 +222,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < clrcount; i++)
|
||||||
|
- drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||||
|
+ drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -274,9 +278,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
|
} else {
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
- d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||||
|
- DefaultVisual(drw->dpy, drw->screen),
|
||||||
|
- DefaultColormap(drw->dpy, drw->screen));
|
||||||
|
+ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
|
||||||
|
x += lpad;
|
||||||
|
w -= lpad;
|
||||||
|
}
|
||||||
|
diff --git a/drw.h b/drw.h
|
||||||
|
index 4c67419..f6fa5cd 100644
|
||||||
|
--- a/drw.h
|
||||||
|
+++ b/drw.h
|
||||||
|
@@ -20,6 +20,9 @@ typedef struct {
|
||||||
|
Display *dpy;
|
||||||
|
int screen;
|
||||||
|
Window root;
|
||||||
|
+ Visual *visual;
|
||||||
|
+ unsigned int depth;
|
||||||
|
+ Colormap cmap;
|
||||||
|
Drawable drawable;
|
||||||
|
GC gc;
|
||||||
|
Clr *scheme;
|
||||||
|
@@ -27,7 +30,7 @@ typedef struct {
|
||||||
|
} Drw;
|
||||||
|
|
||||||
|
/* Drawable abstraction */
|
||||||
|
-Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
||||||
|
+Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap);
|
||||||
|
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||||
|
void drw_free(Drw *drw);
|
||||||
|
|
||||||
|
@@ -38,8 +41,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||||
|
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||||
|
|
||||||
|
/* Colorscheme abstraction */
|
||||||
|
-void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
|
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||||
|
+void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
|
||||||
|
+Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount);
|
||||||
|
|
||||||
|
/* Cursor abstraction */
|
||||||
|
Cur *drw_cur_create(Drw *drw, int shape);
|
@ -0,0 +1,267 @@
|
|||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1edb647..697d511 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
|
+static const unsigned int alpha = 0xf0;
|
||||||
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
static const char *fonts[] = {
|
||||||
|
"monospace:size=10"
|
||||||
|
@@ -13,6 +14,13 @@ static const char *colors[SchemeLast][2] = {
|
||||||
|
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||||
|
[SchemeOut] = { "#000000", "#00ffff" },
|
||||||
|
};
|
||||||
|
+
|
||||||
|
+static const unsigned int alphas[SchemeLast][2] = {
|
||||||
|
+ [SchemeNorm] = { OPAQUE, alpha },
|
||||||
|
+ [SchemeSel] = { OPAQUE, alpha },
|
||||||
|
+ [SchemeOut] = { OPAQUE, alpha },
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
static unsigned int lines = 0;
|
||||||
|
|
||||||
|
diff --git a/dmenu.c b/dmenu.c
|
||||||
|
index 65f25ce..3e56e1a 100644
|
||||||
|
--- a/dmenu.c
|
||||||
|
+++ b/dmenu.c
|
||||||
|
@@ -10,6 +10,7 @@
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
+#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#ifdef XINERAMA
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
@@ -25,6 +26,8 @@
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
|
+#define OPAQUE 0xffU
|
||||||
|
+
|
||||||
|
/* enums */
|
||||||
|
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
|
||||||
|
|
||||||
|
@@ -53,10 +56,16 @@ static XIC xic;
|
||||||
|
static Drw *drw;
|
||||||
|
static Clr *scheme[SchemeLast];
|
||||||
|
|
||||||
|
+static int useargb = 0;
|
||||||
|
+static Visual *visual;
|
||||||
|
+static int depth;
|
||||||
|
+static Colormap cmap;
|
||||||
|
+
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||||
|
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||||
|
+static void xinitvisual();
|
||||||
|
|
||||||
|
static void
|
||||||
|
appenditem(struct item *item, struct item **list, struct item **last)
|
||||||
|
@@ -602,7 +611,7 @@ setup(void)
|
||||||
|
#endif
|
||||||
|
/* init appearance */
|
||||||
|
for (j = 0; j < SchemeLast; j++)
|
||||||
|
- scheme[j] = drw_scm_create(drw, colors[j], 2);
|
||||||
|
+ scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2);
|
||||||
|
|
||||||
|
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||||
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
@@ -640,6 +649,7 @@ setup(void)
|
||||||
|
x = info[i].x_org;
|
||||||
|
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||||
|
mw = info[i].width;
|
||||||
|
+
|
||||||
|
XFree(info);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
@@ -657,11 +667,13 @@ setup(void)
|
||||||
|
|
||||||
|
/* create menu window */
|
||||||
|
swa.override_redirect = True;
|
||||||
|
- swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||||
|
+ swa.background_pixel = 0;
|
||||||
|
+ swa.border_pixel = 0;
|
||||||
|
+ swa.colormap = cmap;
|
||||||
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
|
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||||
|
- CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
|
- CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
|
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||||
|
+ depth, CopyFromParent, visual,
|
||||||
|
+ CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa);
|
||||||
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -747,7 +759,8 @@ main(int argc, char *argv[])
|
||||||
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
|
parentwin);
|
||||||
|
- drw = drw_create(dpy, screen, root, wa.width, wa.height);
|
||||||
|
+ xinitvisual();
|
||||||
|
+ drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap);
|
||||||
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||||
|
die("no fonts could be loaded.");
|
||||||
|
lrpad = drw->fonts->h;
|
||||||
|
@@ -769,3 +782,40 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
|
return 1; /* unreachable */
|
||||||
|
}
|
||||||
|
+
|
||||||
|
+ void
|
||||||
|
+xinitvisual()
|
||||||
|
+{
|
||||||
|
+ XVisualInfo *infos;
|
||||||
|
+ XRenderPictFormat *fmt;
|
||||||
|
+ int nitems;
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ XVisualInfo tpl = {
|
||||||
|
+ .screen = screen,
|
||||||
|
+ .depth = 32,
|
||||||
|
+ .class = TrueColor
|
||||||
|
+ };
|
||||||
|
+ long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
|
||||||
|
+
|
||||||
|
+ infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
|
||||||
|
+ visual = NULL;
|
||||||
|
+ for(i = 0; i < nitems; i ++) {
|
||||||
|
+ fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
|
||||||
|
+ if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
|
||||||
|
+ visual = infos[i].visual;
|
||||||
|
+ depth = infos[i].depth;
|
||||||
|
+ cmap = XCreateColormap(dpy, root, visual, AllocNone);
|
||||||
|
+ useargb = 1;
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ XFree(infos);
|
||||||
|
+
|
||||||
|
+ if (! visual) {
|
||||||
|
+ visual = DefaultVisual(dpy, screen);
|
||||||
|
+ depth = DefaultDepth(dpy, screen);
|
||||||
|
+ cmap = DefaultColormap(dpy, screen);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
diff --git a/drw.c b/drw.c
|
||||||
|
index 4cdbcbe..fe3aadd 100644
|
||||||
|
--- a/drw.c
|
||||||
|
+++ b/drw.c
|
||||||
|
@@ -61,7 +61,7 @@ utf8decode(const char *c, long *u, size_t clen)
|
||||||
|
}
|
||||||
|
|
||||||
|
Drw *
|
||||||
|
-drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||||
|
+drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
|
||||||
|
{
|
||||||
|
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||||
|
|
||||||
|
@@ -70,8 +70,11 @@ drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h
|
||||||
|
drw->root = root;
|
||||||
|
drw->w = w;
|
||||||
|
drw->h = h;
|
||||||
|
- drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||||
|
- drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||||
|
+ drw->visual = visual;
|
||||||
|
+ drw->depth = depth;
|
||||||
|
+ drw->cmap = cmap;
|
||||||
|
+ drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
|
||||||
|
+ drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
|
||||||
|
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
|
|
||||||
|
return drw;
|
||||||
|
@@ -87,7 +90,7 @@ drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||||
|
drw->h = h;
|
||||||
|
if (drw->drawable)
|
||||||
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
|
- drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||||
|
+ drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
@@ -194,21 +197,22 @@ drw_fontset_free(Fnt *font)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
-drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||||
|
+drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha)
|
||||||
|
{
|
||||||
|
if (!drw || !dest || !clrname)
|
||||||
|
return;
|
||||||
|
|
||||||
|
- if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||||
|
- DefaultColormap(drw->dpy, drw->screen),
|
||||||
|
+ if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
|
||||||
|
clrname, dest))
|
||||||
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
|
+
|
||||||
|
+ dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
|
* returned color scheme when done using it. */
|
||||||
|
Clr *
|
||||||
|
-drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
|
+drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
Clr *ret;
|
||||||
|
@@ -218,7 +222,7 @@ drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < clrcount; i++)
|
||||||
|
- drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||||
|
+ drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -274,9 +278,7 @@ drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lp
|
||||||
|
} else {
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
- d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||||
|
- DefaultVisual(drw->dpy, drw->screen),
|
||||||
|
- DefaultColormap(drw->dpy, drw->screen));
|
||||||
|
+ d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
|
||||||
|
x += lpad;
|
||||||
|
w -= lpad;
|
||||||
|
}
|
||||||
|
diff --git a/drw.h b/drw.h
|
||||||
|
index 4c67419..f6fa5cd 100644
|
||||||
|
--- a/drw.h
|
||||||
|
+++ b/drw.h
|
||||||
|
@@ -20,6 +20,9 @@ typedef struct {
|
||||||
|
Display *dpy;
|
||||||
|
int screen;
|
||||||
|
Window root;
|
||||||
|
+ Visual *visual;
|
||||||
|
+ unsigned int depth;
|
||||||
|
+ Colormap cmap;
|
||||||
|
Drawable drawable;
|
||||||
|
GC gc;
|
||||||
|
Clr *scheme;
|
||||||
|
@@ -27,7 +30,7 @@ typedef struct {
|
||||||
|
} Drw;
|
||||||
|
|
||||||
|
/* Drawable abstraction */
|
||||||
|
-Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
||||||
|
+Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap);
|
||||||
|
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||||
|
void drw_free(Drw *drw);
|
||||||
|
|
||||||
|
@@ -38,8 +41,8 @@ unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||||
|
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||||
|
|
||||||
|
/* Colorscheme abstraction */
|
||||||
|
-void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
|
-Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||||
|
+void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
|
||||||
|
+Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount);
|
||||||
|
|
||||||
|
/* Cursor abstraction */
|
||||||
|
Cur *drw_cur_create(Drw *drw, int shape);
|
@ -0,0 +1,25 @@
|
|||||||
|
diff -up dmenu-4.9-b/config.def.h dmenu-4.9-a/config.def.h
|
||||||
|
--- dmenu-4.9-b/config.def.h 2019-02-02 13:55:02.000000000 +0100
|
||||||
|
+++ dmenu-4.9-a/config.def.h 2019-05-19 02:10:12.740040403 +0200
|
||||||
|
@@ -21,3 +21,6 @@ static unsigned int lines = 0;
|
||||||
|
* for example: " /?\"&[]"
|
||||||
|
*/
|
||||||
|
static const char worddelimiters[] = " ";
|
||||||
|
+
|
||||||
|
+/* Size of the window border */
|
||||||
|
+static const unsigned int border_width = 5;
|
||||||
|
diff -up dmenu-4.9-b/dmenu.c dmenu-4.9-a/dmenu.c
|
||||||
|
--- dmenu-4.9-b/dmenu.c 2019-02-02 13:55:02.000000000 +0100
|
||||||
|
+++ dmenu-4.9-a/dmenu.c 2019-05-19 02:11:20.966710117 +0200
|
||||||
|
@@ -654,9 +654,10 @@ setup(void)
|
||||||
|
swa.override_redirect = True;
|
||||||
|
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||||
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
|
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||||
|
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||||
|
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
|
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
|
+ XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||||
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
/* open input methods */
|
@ -0,0 +1,104 @@
|
|||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1edb647..88ef264 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -2,6 +2,8 @@
|
||||||
|
/* Default settings; can be overriden by command line. */
|
||||||
|
|
||||||
|
static int topbar = 1; /* -b option; if 0, dmenu appears at bottom */
|
||||||
|
+static int centered = 0; /* -c option; centers dmenu on screen */
|
||||||
|
+static int min_width = 500; /* minimum width when centered */
|
||||||
|
/* -fn option overrides fonts[0]; default X11 font or font set */
|
||||||
|
static const char *fonts[] = {
|
||||||
|
"monospace:size=10"
|
||||||
|
diff --git a/dmenu.1 b/dmenu.1
|
||||||
|
index 323f93c..c036baa 100644
|
||||||
|
--- a/dmenu.1
|
||||||
|
+++ b/dmenu.1
|
||||||
|
@@ -40,6 +40,9 @@ which lists programs in the user's $PATH and runs the result in their $SHELL.
|
||||||
|
.B \-b
|
||||||
|
dmenu appears at the bottom of the screen.
|
||||||
|
.TP
|
||||||
|
+.B \-c
|
||||||
|
+dmenu appears centered on the screen.
|
||||||
|
+.TP
|
||||||
|
.B \-f
|
||||||
|
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
|
||||||
|
is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||||
|
diff --git a/dmenu.c b/dmenu.c
|
||||||
|
index 27b7a30..427fb04 100644
|
||||||
|
--- a/dmenu.c
|
||||||
|
+++ b/dmenu.c
|
||||||
|
@@ -96,6 +96,15 @@ calcoffsets(void)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int
|
||||||
|
+max_textw(void)
|
||||||
|
+{
|
||||||
|
+ int len = 0;
|
||||||
|
+ for (struct item *item = items; item && item->text; item++)
|
||||||
|
+ len = MAX(TEXTW(item->text), len);
|
||||||
|
+ return len;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
cleanup(void)
|
||||||
|
{
|
||||||
|
@@ -636,6 +645,7 @@ setup(void)
|
||||||
|
bh = drw->fonts->h + 2;
|
||||||
|
lines = MAX(lines, 0);
|
||||||
|
mh = (lines + 1) * bh;
|
||||||
|
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
|
#ifdef XINERAMA
|
||||||
|
i = 0;
|
||||||
|
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||||
|
@@ -662,9 +672,16 @@ setup(void)
|
||||||
|
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
- x = info[i].x_org;
|
||||||
|
- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||||
|
- mw = info[i].width;
|
||||||
|
+ if (centered) {
|
||||||
|
+ mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
|
||||||
|
+ x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||||
|
+ y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||||
|
+ } else {
|
||||||
|
+ x = info[i].x_org;
|
||||||
|
+ y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||||
|
+ mw = info[i].width;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
XFree(info);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
@@ -672,9 +689,16 @@ setup(void)
|
||||||
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
|
parentwin);
|
||||||
|
- x = 0;
|
||||||
|
- y = topbar ? 0 : wa.height - mh;
|
||||||
|
- mw = wa.width;
|
||||||
|
+
|
||||||
|
+ if (centered) {
|
||||||
|
+ mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
|
||||||
|
+ x = (wa.width - mw) / 2;
|
||||||
|
+ y = (wa.height - mh) / 2;
|
||||||
|
+ } else {
|
||||||
|
+ x = 0;
|
||||||
|
+ y = topbar ? 0 : wa.height - mh;
|
||||||
|
+ mw = wa.width;
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
|
inputw = mw / 3; /* input width: ~33% of monitor width */
|
||||||
|
@@ -733,6 +757,8 @@ main(int argc, char *argv[])
|
||||||
|
topbar = 0;
|
||||||
|
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
|
||||||
|
fast = 1;
|
||||||
|
+ else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
|
||||||
|
+ centered = 1;
|
||||||
|
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||||
|
fstrncmp = strncasecmp;
|
||||||
|
fstrstr = cistrstr;
|
@ -0,0 +1,27 @@
|
|||||||
|
From f16313b64965d74e6cbb30fa41d53aaf09b9ad49 Mon Sep 17 00:00:00 2001
|
||||||
|
From: David Lima <antdavidlima@gmail.com>
|
||||||
|
Date: Sun, 28 Nov 2021 17:02:43 -0300
|
||||||
|
Subject: [PATCH] apply dracula theme to dmenu
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 4 ++--
|
||||||
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1edb647..e688388 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -9,8 +9,8 @@ static const char *fonts[] = {
|
||||||
|
static const char *prompt = NULL; /* -p option; prompt to the left of input field */
|
||||||
|
static const char *colors[SchemeLast][2] = {
|
||||||
|
/* fg bg */
|
||||||
|
- [SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||||
|
- [SchemeSel] = { "#eeeeee", "#005577" },
|
||||||
|
+ [SchemeNorm] = { "#f8f8f2", "#282a36" },
|
||||||
|
+ [SchemeSel] = { "#f8f8f2", "#6272a4" },
|
||||||
|
[SchemeOut] = { "#000000", "#00ffff" },
|
||||||
|
};
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
--
|
||||||
|
2.34.1
|
||||||
|
|
@ -0,0 +1,94 @@
|
|||||||
|
From a06d0d3d7bbb3c0f5bad44934dbbf1e88e7d9558 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Miles Alan <m@milesalan.com>
|
||||||
|
Date: Sat, 4 Jul 2020 11:49:04 -0500
|
||||||
|
Subject: [PATCH] Highlight matched text in a different color scheme
|
||||||
|
|
||||||
|
---
|
||||||
|
config.def.h | 2 ++
|
||||||
|
dmenu.c | 43 +++++++++++++++++++++++++++++++++++++++++--
|
||||||
|
2 files changed, 43 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1edb647..64eab2a 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -11,6 +11,8 @@ static const char *colors[SchemeLast][2] = {
|
||||||
|
/* fg bg */
|
||||||
|
[SchemeNorm] = { "#bbbbbb", "#222222" },
|
||||||
|
[SchemeSel] = { "#eeeeee", "#005577" },
|
||||||
|
+ [SchemeSelHighlight] = { "#ffc978", "#005577" },
|
||||||
|
+ [SchemeNormHighlight] = { "#ffc978", "#222222" },
|
||||||
|
[SchemeOut] = { "#000000", "#00ffff" },
|
||||||
|
};
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
diff --git a/dmenu.c b/dmenu.c
|
||||||
|
index 6b8f51b..d5e1991 100644
|
||||||
|
--- a/dmenu.c
|
||||||
|
+++ b/dmenu.c
|
||||||
|
@@ -26,7 +26,7 @@
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
-enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
|
||||||
|
+enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeLast }; /* color schemes */
|
||||||
|
|
||||||
|
struct item {
|
||||||
|
char *text;
|
||||||
|
@@ -113,6 +113,43 @@ cistrstr(const char *s, const char *sub)
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void
|
||||||
|
+drawhighlights(struct item *item, int x, int y, int maxw)
|
||||||
|
+{
|
||||||
|
+ char restorechar, tokens[sizeof text], *highlight, *token;
|
||||||
|
+ int indentx, highlightlen;
|
||||||
|
+
|
||||||
|
+ drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : SchemeNormHighlight]);
|
||||||
|
+ strcpy(tokens, text);
|
||||||
|
+ for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) {
|
||||||
|
+ highlight = fstrstr(item->text, token);
|
||||||
|
+ while (highlight) {
|
||||||
|
+ // Move item str end, calc width for highlight indent, & restore
|
||||||
|
+ highlightlen = highlight - item->text;
|
||||||
|
+ restorechar = *highlight;
|
||||||
|
+ item->text[highlightlen] = '\0';
|
||||||
|
+ indentx = TEXTW(item->text);
|
||||||
|
+ item->text[highlightlen] = restorechar;
|
||||||
|
+
|
||||||
|
+ // Move highlight str end, draw highlight, & restore
|
||||||
|
+ restorechar = highlight[strlen(token)];
|
||||||
|
+ highlight[strlen(token)] = '\0';
|
||||||
|
+ if (indentx - (lrpad / 2) - 1 < maxw)
|
||||||
|
+ drw_text(
|
||||||
|
+ drw,
|
||||||
|
+ x + indentx - (lrpad / 2) - 1,
|
||||||
|
+ y,
|
||||||
|
+ MIN(maxw - indentx, TEXTW(highlight) - lrpad),
|
||||||
|
+ bh, 0, highlight, 0
|
||||||
|
+ );
|
||||||
|
+ highlight[strlen(token)] = restorechar;
|
||||||
|
+
|
||||||
|
+ if (strlen(highlight) - strlen(token) < strlen(token)) break;
|
||||||
|
+ highlight = fstrstr(highlight + strlen(token), token);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int
|
||||||
|
drawitem(struct item *item, int x, int y, int w)
|
||||||
|
{
|
||||||
|
@@ -123,7 +160,9 @@ drawitem(struct item *item, int x, int y, int w)
|
||||||
|
else
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
|
||||||
|
- return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||||
|
+ int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||||
|
+ drawhighlights(item, x, y, w);
|
||||||
|
+ return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
--
|
||||||
|
2.23.1
|
||||||
|
|
@ -0,0 +1,106 @@
|
|||||||
|
From ba103e38ea4ab07f9a3ee90627714b9bea17c329 Mon Sep 17 00:00:00 2001
|
||||||
|
From: pskry <peter@skrypalle.dk>
|
||||||
|
Date: Sun, 8 Nov 2020 22:04:22 +0100
|
||||||
|
Subject: [PATCH] Add an option which defines the lineheight
|
||||||
|
|
||||||
|
Despite both the panel and dmenu using the same font (a Terminus 12),
|
||||||
|
dmenu is shorter and the panel is visible from under the dmenu bar.
|
||||||
|
The appearance can be even more distracting when using similar colors
|
||||||
|
for background and selections. With the option added by this patch,
|
||||||
|
dmenu can be launched with a '-h 24', thus completely covering the panel.
|
||||||
|
---
|
||||||
|
config.def.h | 3 +++
|
||||||
|
dmenu.1 | 5 +++++
|
||||||
|
dmenu.c | 11 ++++++++---
|
||||||
|
3 files changed, 16 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index 1edb647..4394dec 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -15,6 +15,9 @@ static const char *colors[SchemeLast][2] = {
|
||||||
|
};
|
||||||
|
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
|
||||||
|
static unsigned int lines = 0;
|
||||||
|
+/* -h option; minimum height of a menu line */
|
||||||
|
+static unsigned int lineheight = 0;
|
||||||
|
+static unsigned int min_lineheight = 8;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Characters not considered part of a word while deleting words
|
||||||
|
diff --git a/dmenu.1 b/dmenu.1
|
||||||
|
index 323f93c..f2a82b4 100644
|
||||||
|
--- a/dmenu.1
|
||||||
|
+++ b/dmenu.1
|
||||||
|
@@ -6,6 +6,8 @@ dmenu \- dynamic menu
|
||||||
|
.RB [ \-bfiv ]
|
||||||
|
.RB [ \-l
|
||||||
|
.IR lines ]
|
||||||
|
+.RB [ \-h
|
||||||
|
+.IR height ]
|
||||||
|
.RB [ \-m
|
||||||
|
.IR monitor ]
|
||||||
|
.RB [ \-p
|
||||||
|
@@ -50,6 +52,9 @@ dmenu matches menu items case insensitively.
|
||||||
|
.BI \-l " lines"
|
||||||
|
dmenu lists items vertically, with the given number of lines.
|
||||||
|
.TP
|
||||||
|
+.BI \-h " height"
|
||||||
|
+dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
|
||||||
|
+.TP
|
||||||
|
.BI \-m " monitor"
|
||||||
|
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
|
||||||
|
from 0.
|
||||||
|
diff --git a/dmenu.c b/dmenu.c
|
||||||
|
index e7be8af..82b204b 100644
|
||||||
|
--- a/dmenu.c
|
||||||
|
+++ b/dmenu.c
|
||||||
|
@@ -148,7 +148,7 @@ drawmenu(void)
|
||||||
|
{
|
||||||
|
unsigned int curpos;
|
||||||
|
struct item *item;
|
||||||
|
- int x = 0, y = 0, w;
|
||||||
|
+ int x = 0, y = 0, fh = drw->fonts->h, w;
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||||
|
@@ -165,7 +165,7 @@ drawmenu(void)
|
||||||
|
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
||||||
|
if ((curpos += lrpad / 2 - 1) < w) {
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
|
||||||
|
+ drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lines > 0) {
|
||||||
|
@@ -630,6 +630,7 @@ setup(void)
|
||||||
|
|
||||||
|
/* calculate menu geometry */
|
||||||
|
bh = drw->fonts->h + 2;
|
||||||
|
+ bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
|
||||||
|
lines = MAX(lines, 0);
|
||||||
|
mh = (lines + 1) * bh;
|
||||||
|
#ifdef XINERAMA
|
||||||
|
@@ -710,7 +711,7 @@ setup(void)
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
- die("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
|
||||||
|
+ die("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
|
||||||
|
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -737,6 +738,10 @@ main(int argc, char *argv[])
|
||||||
|
/* these options take one argument */
|
||||||
|
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
||||||
|
lines = atoi(argv[++i]);
|
||||||
|
+ else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
|
||||||
|
+ lineheight = atoi(argv[++i]);
|
||||||
|
+ lineheight = MAX(lineheight, min_lineheight);
|
||||||
|
+ }
|
||||||
|
else if (!strcmp(argv[i], "-m"))
|
||||||
|
mon = atoi(argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||||
|
--
|
||||||
|
2.38.1
|
||||||
|
|
@ -0,0 +1,89 @@
|
|||||||
|
From c4cd209c2e322563750d09a3b64194d11cc12a10 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ehsan Ghorbannezhad <ehsan@disroot.org>
|
||||||
|
Date: Thu, 12 May 2022 22:32:47 +0430
|
||||||
|
Subject: [PATCH] the numbers patch, updated to fix segfault in some conditions
|
||||||
|
|
||||||
|
---
|
||||||
|
dmenu.c | 27 ++++++++++++++++++++++++---
|
||||||
|
1 file changed, 24 insertions(+), 3 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/dmenu.c b/dmenu.c
|
||||||
|
index 571bc35..70004e7 100644
|
||||||
|
--- a/dmenu.c
|
||||||
|
+++ b/dmenu.c
|
||||||
|
@@ -24,6 +24,8 @@
|
||||||
|
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
+#define NUMBERSMAXDIGITS 100
|
||||||
|
+#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeLast }; /* color schemes */
|
||||||
|
@@ -34,6 +36,7 @@ struct item {
|
||||||
|
int out;
|
||||||
|
};
|
||||||
|
|
||||||
|
+static char numbers[NUMBERSBUFSIZE] = "";
|
||||||
|
static char text[BUFSIZ] = "";
|
||||||
|
static char *embed;
|
||||||
|
static int bh, mw, mh;
|
||||||
|
@@ -86,7 +89,7 @@ calcoffsets(void)
|
||||||
|
if (lines > 0)
|
||||||
|
n = lines * bh;
|
||||||
|
else
|
||||||
|
- n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
|
||||||
|
+ n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">") + TEXTW(numbers));
|
||||||
|
/* calculate which items will begin the next page and previous page */
|
||||||
|
for (i = 0, next = curr; next; next = next->right)
|
||||||
|
if ((i += (lines > 0) ? bh : textw_clamp(next->text, n)) > n)
|
||||||
|
@@ -143,6 +146,21 @@ drawitem(struct item *item, int x, int y, int w)
|
||||||
|
return drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static void
|
||||||
|
+recalculatenumbers()
|
||||||
|
+{
|
||||||
|
+ unsigned int numer = 0, denom = 0;
|
||||||
|
+ struct item *item;
|
||||||
|
+ if (matchend) {
|
||||||
|
+ numer++;
|
||||||
|
+ for (item = matchend; item && item->left; item = item->left)
|
||||||
|
+ numer++;
|
||||||
|
+ }
|
||||||
|
+ for (item = items; item && item->text; item++)
|
||||||
|
+ denom++;
|
||||||
|
+ snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static void
|
||||||
|
drawmenu(void)
|
||||||
|
{
|
||||||
|
@@ -168,6 +186,7 @@ drawmenu(void)
|
||||||
|
drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ recalculatenumbers();
|
||||||
|
if (lines > 0) {
|
||||||
|
/* draw vertical list */
|
||||||
|
for (item = curr; item != next; item = item->right)
|
||||||
|
@@ -182,13 +201,15 @@ drawmenu(void)
|
||||||
|
}
|
||||||
|
x += w;
|
||||||
|
for (item = curr; item != next; item = item->right)
|
||||||
|
- x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">")));
|
||||||
|
+ x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">") - TEXTW(numbers)));
|
||||||
|
if (next) {
|
||||||
|
w = TEXTW(">");
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
- drw_text(drw, mw - w, 0, w, bh, lrpad / 2, ">", 0);
|
||||||
|
+ drw_text(drw, mw - w - TEXTW(numbers), 0, w, bh, lrpad / 2, ">", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
+ drw_text(drw, mw - TEXTW(numbers), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0);
|
||||||
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.36.1
|
@ -0,0 +1,202 @@
|
|||||||
|
.TH DMENU 1 dmenu\-VERSION
|
||||||
|
.SH NAME
|
||||||
|
dmenu \- dynamic menu
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B dmenu
|
||||||
|
.RB [ \-bfiv ]
|
||||||
|
.RB [ \-l
|
||||||
|
.IR lines ]
|
||||||
|
.RB [ \-h
|
||||||
|
.IR height ]
|
||||||
|
.RB [ \-m
|
||||||
|
.IR monitor ]
|
||||||
|
.RB [ \-p
|
||||||
|
.IR prompt ]
|
||||||
|
.RB [ \-fn
|
||||||
|
.IR font ]
|
||||||
|
.RB [ \-nb
|
||||||
|
.IR color ]
|
||||||
|
.RB [ \-nf
|
||||||
|
.IR color ]
|
||||||
|
.RB [ \-sb
|
||||||
|
.IR color ]
|
||||||
|
.RB [ \-sf
|
||||||
|
.IR color ]
|
||||||
|
.RB [ \-w
|
||||||
|
.IR windowid ]
|
||||||
|
.P
|
||||||
|
.BR dmenu_run " ..."
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B dmenu
|
||||||
|
is a dynamic menu for X, which reads a list of newline\-separated items from
|
||||||
|
stdin. When the user selects an item and presses Return, their choice is printed
|
||||||
|
to stdout and dmenu terminates. Entering text will narrow the items to those
|
||||||
|
matching the tokens in the input.
|
||||||
|
.P
|
||||||
|
.B dmenu_run
|
||||||
|
is a script used by
|
||||||
|
.IR dwm (1)
|
||||||
|
which lists programs in the user's $PATH and runs the result in their $SHELL.
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-b
|
||||||
|
dmenu appears at the bottom of the screen.
|
||||||
|
.TP
|
||||||
|
.B \-c
|
||||||
|
dmenu appears centered on the screen.
|
||||||
|
.TP
|
||||||
|
.B \-f
|
||||||
|
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
|
||||||
|
is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||||
|
.TP
|
||||||
|
.B \-i
|
||||||
|
dmenu matches menu items case insensitively.
|
||||||
|
.TP
|
||||||
|
.BI \-l " lines"
|
||||||
|
dmenu lists items vertically, with the given number of lines.
|
||||||
|
.TP
|
||||||
|
.BI \-h " height"
|
||||||
|
dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
|
||||||
|
.TP
|
||||||
|
.BI \-m " monitor"
|
||||||
|
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
|
||||||
|
from 0.
|
||||||
|
.TP
|
||||||
|
.BI \-p " prompt"
|
||||||
|
defines the prompt to be displayed to the left of the input field.
|
||||||
|
.TP
|
||||||
|
.BI \-fn " font"
|
||||||
|
defines the font or font set used.
|
||||||
|
.TP
|
||||||
|
.BI \-nb " color"
|
||||||
|
defines the normal background color.
|
||||||
|
.IR #RGB ,
|
||||||
|
.IR #RRGGBB ,
|
||||||
|
and X color names are supported.
|
||||||
|
.TP
|
||||||
|
.BI \-nf " color"
|
||||||
|
defines the normal foreground color.
|
||||||
|
.TP
|
||||||
|
.BI \-sb " color"
|
||||||
|
defines the selected background color.
|
||||||
|
.TP
|
||||||
|
.BI \-sf " color"
|
||||||
|
defines the selected foreground color.
|
||||||
|
.TP
|
||||||
|
.B \-v
|
||||||
|
prints version information to stdout, then exits.
|
||||||
|
.TP
|
||||||
|
.BI \-w " windowid"
|
||||||
|
embed into windowid.
|
||||||
|
.SH USAGE
|
||||||
|
dmenu is completely controlled by the keyboard. Items are selected using the
|
||||||
|
arrow keys, page up, page down, home, and end.
|
||||||
|
.TP
|
||||||
|
.B Tab
|
||||||
|
Copy the selected item to the input field.
|
||||||
|
.TP
|
||||||
|
.B Return
|
||||||
|
Confirm selection. Prints the selected item to stdout and exits, returning
|
||||||
|
success.
|
||||||
|
.TP
|
||||||
|
.B Ctrl-Return
|
||||||
|
Confirm selection. Prints the selected item to stdout and continues.
|
||||||
|
.TP
|
||||||
|
.B Shift\-Return
|
||||||
|
Confirm input. Prints the input text to stdout and exits, returning success.
|
||||||
|
.TP
|
||||||
|
.B Escape
|
||||||
|
Exit without selecting an item, returning failure.
|
||||||
|
.TP
|
||||||
|
.B Ctrl-Left
|
||||||
|
Move cursor to the start of the current word
|
||||||
|
.TP
|
||||||
|
.B Ctrl-Right
|
||||||
|
Move cursor to the end of the current word
|
||||||
|
.TP
|
||||||
|
.B C\-a
|
||||||
|
Home
|
||||||
|
.TP
|
||||||
|
.B C\-b
|
||||||
|
Left
|
||||||
|
.TP
|
||||||
|
.B C\-c
|
||||||
|
Escape
|
||||||
|
.TP
|
||||||
|
.B C\-d
|
||||||
|
Delete
|
||||||
|
.TP
|
||||||
|
.B C\-e
|
||||||
|
End
|
||||||
|
.TP
|
||||||
|
.B C\-f
|
||||||
|
Right
|
||||||
|
.TP
|
||||||
|
.B C\-g
|
||||||
|
Escape
|
||||||
|
.TP
|
||||||
|
.B C\-h
|
||||||
|
Backspace
|
||||||
|
.TP
|
||||||
|
.B C\-i
|
||||||
|
Tab
|
||||||
|
.TP
|
||||||
|
.B C\-j
|
||||||
|
Return
|
||||||
|
.TP
|
||||||
|
.B C\-J
|
||||||
|
Shift-Return
|
||||||
|
.TP
|
||||||
|
.B C\-k
|
||||||
|
Delete line right
|
||||||
|
.TP
|
||||||
|
.B C\-m
|
||||||
|
Return
|
||||||
|
.TP
|
||||||
|
.B C\-M
|
||||||
|
Shift-Return
|
||||||
|
.TP
|
||||||
|
.B C\-n
|
||||||
|
Down
|
||||||
|
.TP
|
||||||
|
.B C\-p
|
||||||
|
Up
|
||||||
|
.TP
|
||||||
|
.B C\-u
|
||||||
|
Delete line left
|
||||||
|
.TP
|
||||||
|
.B C\-w
|
||||||
|
Delete word left
|
||||||
|
.TP
|
||||||
|
.B C\-y
|
||||||
|
Paste from primary X selection
|
||||||
|
.TP
|
||||||
|
.B C\-Y
|
||||||
|
Paste from X clipboard
|
||||||
|
.TP
|
||||||
|
.B M\-b
|
||||||
|
Move cursor to the start of the current word
|
||||||
|
.TP
|
||||||
|
.B M\-f
|
||||||
|
Move cursor to the end of the current word
|
||||||
|
.TP
|
||||||
|
.B M\-g
|
||||||
|
Home
|
||||||
|
.TP
|
||||||
|
.B M\-G
|
||||||
|
End
|
||||||
|
.TP
|
||||||
|
.B M\-h
|
||||||
|
Up
|
||||||
|
.TP
|
||||||
|
.B M\-j
|
||||||
|
Page down
|
||||||
|
.TP
|
||||||
|
.B M\-k
|
||||||
|
Page up
|
||||||
|
.TP
|
||||||
|
.B M\-l
|
||||||
|
Down
|
||||||
|
.SH SEE ALSO
|
||||||
|
.IR dwm (1),
|
||||||
|
.IR stest (1)
|
@ -0,0 +1,197 @@
|
|||||||
|
.TH DMENU 1 dmenu\-VERSION
|
||||||
|
.SH NAME
|
||||||
|
dmenu \- dynamic menu
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B dmenu
|
||||||
|
.RB [ \-bfiv ]
|
||||||
|
.RB [ \-l
|
||||||
|
.IR lines ]
|
||||||
|
.RB [ \-m
|
||||||
|
.IR monitor ]
|
||||||
|
.RB [ \-p
|
||||||
|
.IR prompt ]
|
||||||
|
.RB [ \-fn
|
||||||
|
.IR font ]
|
||||||
|
.RB [ \-nb
|
||||||
|
.IR color ]
|
||||||
|
.RB [ \-nf
|
||||||
|
.IR color ]
|
||||||
|
.RB [ \-sb
|
||||||
|
.IR color ]
|
||||||
|
.RB [ \-sf
|
||||||
|
.IR color ]
|
||||||
|
.RB [ \-w
|
||||||
|
.IR windowid ]
|
||||||
|
.P
|
||||||
|
.BR dmenu_run " ..."
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B dmenu
|
||||||
|
is a dynamic menu for X, which reads a list of newline\-separated items from
|
||||||
|
stdin. When the user selects an item and presses Return, their choice is printed
|
||||||
|
to stdout and dmenu terminates. Entering text will narrow the items to those
|
||||||
|
matching the tokens in the input.
|
||||||
|
.P
|
||||||
|
.B dmenu_run
|
||||||
|
is a script used by
|
||||||
|
.IR dwm (1)
|
||||||
|
which lists programs in the user's $PATH and runs the result in their $SHELL.
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-b
|
||||||
|
dmenu appears at the bottom of the screen.
|
||||||
|
.TP
|
||||||
|
.B \-c
|
||||||
|
dmenu appears centered on the screen.
|
||||||
|
.TP
|
||||||
|
.B \-f
|
||||||
|
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
|
||||||
|
is faster, but will lock up X until stdin reaches end\-of\-file.
|
||||||
|
.TP
|
||||||
|
.B \-i
|
||||||
|
dmenu matches menu items case insensitively.
|
||||||
|
.TP
|
||||||
|
.BI \-l " lines"
|
||||||
|
dmenu lists items vertically, with the given number of lines.
|
||||||
|
.TP
|
||||||
|
.BI \-m " monitor"
|
||||||
|
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
|
||||||
|
from 0.
|
||||||
|
.TP
|
||||||
|
.BI \-p " prompt"
|
||||||
|
defines the prompt to be displayed to the left of the input field.
|
||||||
|
.TP
|
||||||
|
.BI \-fn " font"
|
||||||
|
defines the font or font set used.
|
||||||
|
.TP
|
||||||
|
.BI \-nb " color"
|
||||||
|
defines the normal background color.
|
||||||
|
.IR #RGB ,
|
||||||
|
.IR #RRGGBB ,
|
||||||
|
and X color names are supported.
|
||||||
|
.TP
|
||||||
|
.BI \-nf " color"
|
||||||
|
defines the normal foreground color.
|
||||||
|
.TP
|
||||||
|
.BI \-sb " color"
|
||||||
|
defines the selected background color.
|
||||||
|
.TP
|
||||||
|
.BI \-sf " color"
|
||||||
|
defines the selected foreground color.
|
||||||
|
.TP
|
||||||
|
.B \-v
|
||||||
|
prints version information to stdout, then exits.
|
||||||
|
.TP
|
||||||
|
.BI \-w " windowid"
|
||||||
|
embed into windowid.
|
||||||
|
.SH USAGE
|
||||||
|
dmenu is completely controlled by the keyboard. Items are selected using the
|
||||||
|
arrow keys, page up, page down, home, and end.
|
||||||
|
.TP
|
||||||
|
.B Tab
|
||||||
|
Copy the selected item to the input field.
|
||||||
|
.TP
|
||||||
|
.B Return
|
||||||
|
Confirm selection. Prints the selected item to stdout and exits, returning
|
||||||
|
success.
|
||||||
|
.TP
|
||||||
|
.B Ctrl-Return
|
||||||
|
Confirm selection. Prints the selected item to stdout and continues.
|
||||||
|
.TP
|
||||||
|
.B Shift\-Return
|
||||||
|
Confirm input. Prints the input text to stdout and exits, returning success.
|
||||||
|
.TP
|
||||||
|
.B Escape
|
||||||
|
Exit without selecting an item, returning failure.
|
||||||
|
.TP
|
||||||
|
.B Ctrl-Left
|
||||||
|
Move cursor to the start of the current word
|
||||||
|
.TP
|
||||||
|
.B Ctrl-Right
|
||||||
|
Move cursor to the end of the current word
|
||||||
|
.TP
|
||||||
|
.B C\-a
|
||||||
|
Home
|
||||||
|
.TP
|
||||||
|
.B C\-b
|
||||||
|
Left
|
||||||
|
.TP
|
||||||
|
.B C\-c
|
||||||
|
Escape
|
||||||
|
.TP
|
||||||
|
.B C\-d
|
||||||
|
Delete
|
||||||
|
.TP
|
||||||
|
.B C\-e
|
||||||
|
End
|
||||||
|
.TP
|
||||||
|
.B C\-f
|
||||||
|
Right
|
||||||
|
.TP
|
||||||
|
.B C\-g
|
||||||
|
Escape
|
||||||
|
.TP
|
||||||
|
.B C\-h
|
||||||
|
Backspace
|
||||||
|
.TP
|
||||||
|
.B C\-i
|
||||||
|
Tab
|
||||||
|
.TP
|
||||||
|
.B C\-j
|
||||||
|
Return
|
||||||
|
.TP
|
||||||
|
.B C\-J
|
||||||
|
Shift-Return
|
||||||
|
.TP
|
||||||
|
.B C\-k
|
||||||
|
Delete line right
|
||||||
|
.TP
|
||||||
|
.B C\-m
|
||||||
|
Return
|
||||||
|
.TP
|
||||||
|
.B C\-M
|
||||||
|
Shift-Return
|
||||||
|
.TP
|
||||||
|
.B C\-n
|
||||||
|
Down
|
||||||
|
.TP
|
||||||
|
.B C\-p
|
||||||
|
Up
|
||||||
|
.TP
|
||||||
|
.B C\-u
|
||||||
|
Delete line left
|
||||||
|
.TP
|
||||||
|
.B C\-w
|
||||||
|
Delete word left
|
||||||
|
.TP
|
||||||
|
.B C\-y
|
||||||
|
Paste from primary X selection
|
||||||
|
.TP
|
||||||
|
.B C\-Y
|
||||||
|
Paste from X clipboard
|
||||||
|
.TP
|
||||||
|
.B M\-b
|
||||||
|
Move cursor to the start of the current word
|
||||||
|
.TP
|
||||||
|
.B M\-f
|
||||||
|
Move cursor to the end of the current word
|
||||||
|
.TP
|
||||||
|
.B M\-g
|
||||||
|
Home
|
||||||
|
.TP
|
||||||
|
.B M\-G
|
||||||
|
End
|
||||||
|
.TP
|
||||||
|
.B M\-h
|
||||||
|
Up
|
||||||
|
.TP
|
||||||
|
.B M\-j
|
||||||
|
Page down
|
||||||
|
.TP
|
||||||
|
.B M\-k
|
||||||
|
Page up
|
||||||
|
.TP
|
||||||
|
.B M\-l
|
||||||
|
Down
|
||||||
|
.SH SEE ALSO
|
||||||
|
.IR dwm (1),
|
||||||
|
.IR stest (1)
|
@ -0,0 +1,939 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xproto.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#ifdef XINERAMA
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
#endif
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
|
#include "drw.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
/* macros */
|
||||||
|
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
|
||||||
|
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
#define NUMBERSMAXDIGITS 100
|
||||||
|
#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1
|
||||||
|
|
||||||
|
#define OPAQUE 0xffU
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeLast }; /* color schemes */
|
||||||
|
|
||||||
|
struct item {
|
||||||
|
char *text;
|
||||||
|
struct item *left, *right;
|
||||||
|
int out;
|
||||||
|
};
|
||||||
|
|
||||||
|
static char numbers[NUMBERSBUFSIZE] = "";
|
||||||
|
static char text[BUFSIZ] = "";
|
||||||
|
static char *embed;
|
||||||
|
static int bh, mw, mh;
|
||||||
|
static int inputw = 0, promptw;
|
||||||
|
static int lrpad; /* sum of left and right padding */
|
||||||
|
static size_t cursor;
|
||||||
|
static struct item *items = NULL;
|
||||||
|
static struct item *matches, *matchend;
|
||||||
|
static struct item *prev, *curr, *next, *sel;
|
||||||
|
static int mon = -1, screen;
|
||||||
|
|
||||||
|
static Atom clip, utf8;
|
||||||
|
static Display *dpy;
|
||||||
|
static Window root, parentwin, win;
|
||||||
|
static XIC xic;
|
||||||
|
|
||||||
|
static Drw *drw;
|
||||||
|
static Clr *scheme[SchemeLast];
|
||||||
|
|
||||||
|
static int useargb = 0;
|
||||||
|
static Visual *visual;
|
||||||
|
static int depth;
|
||||||
|
static Colormap cmap;
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||||
|
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||||
|
static void xinitvisual();
|
||||||
|
|
||||||
|
static unsigned int
|
||||||
|
textw_clamp(const char *str, unsigned int n)
|
||||||
|
{
|
||||||
|
unsigned int w = drw_fontset_getwidth_clamp(drw, str, n) + lrpad;
|
||||||
|
return MIN(w, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
appenditem(struct item *item, struct item **list, struct item **last)
|
||||||
|
{
|
||||||
|
if (*last)
|
||||||
|
(*last)->right = item;
|
||||||
|
else
|
||||||
|
*list = item;
|
||||||
|
|
||||||
|
item->left = *last;
|
||||||
|
item->right = NULL;
|
||||||
|
*last = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
calcoffsets(void)
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
if (lines > 0)
|
||||||
|
n = lines * bh;
|
||||||
|
else
|
||||||
|
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">") + TEXTW(numbers));
|
||||||
|
/* calculate which items will begin the next page and previous page */
|
||||||
|
for (i = 0, next = curr; next; next = next->right)
|
||||||
|
if ((i += (lines > 0) ? bh : textw_clamp(next->text, n)) > n)
|
||||||
|
break;
|
||||||
|
for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
|
||||||
|
if ((i += (lines > 0) ? bh : textw_clamp(prev->left->text, n)) > n)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
max_textw(void)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
for (struct item *item = items; item && item->text; item++)
|
||||||
|
len = MAX(TEXTW(item->text), len);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanup(void)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||||
|
for (i = 0; i < SchemeLast; i++)
|
||||||
|
free(scheme[i]);
|
||||||
|
for (i = 0; items && items[i].text; ++i)
|
||||||
|
free(items[i].text);
|
||||||
|
free(items);
|
||||||
|
drw_free(drw);
|
||||||
|
XSync(dpy, False);
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
cistrstr(const char *h, const char *n)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!n[0])
|
||||||
|
return (char *)h;
|
||||||
|
|
||||||
|
for (; *h; ++h) {
|
||||||
|
for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
|
||||||
|
tolower((unsigned char)h[i]); ++i)
|
||||||
|
;
|
||||||
|
if (n[i] == '\0')
|
||||||
|
return (char *)h;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
drawhighlights(struct item *item, int x, int y, int maxw)
|
||||||
|
{
|
||||||
|
char restorechar, tokens[sizeof text], *highlight, *token;
|
||||||
|
int indentx, highlightlen;
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : SchemeNormHighlight]);
|
||||||
|
strcpy(tokens, text);
|
||||||
|
for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) {
|
||||||
|
highlight = fstrstr(item->text, token);
|
||||||
|
while (highlight) {
|
||||||
|
// Move item str end, calc width for highlight indent, & restore
|
||||||
|
highlightlen = highlight - item->text;
|
||||||
|
restorechar = *highlight;
|
||||||
|
item->text[highlightlen] = '\0';
|
||||||
|
indentx = TEXTW(item->text);
|
||||||
|
item->text[highlightlen] = restorechar;
|
||||||
|
|
||||||
|
// Move highlight str end, draw highlight, & restore
|
||||||
|
restorechar = highlight[strlen(token)];
|
||||||
|
highlight[strlen(token)] = '\0';
|
||||||
|
if (indentx - (lrpad / 2) - 1 < maxw)
|
||||||
|
drw_text(
|
||||||
|
drw,
|
||||||
|
x + indentx - (lrpad / 2) - 1,
|
||||||
|
y,
|
||||||
|
MIN(maxw - indentx, TEXTW(highlight) - lrpad),
|
||||||
|
bh, 0, highlight, 0
|
||||||
|
);
|
||||||
|
highlight[strlen(token)] = restorechar;
|
||||||
|
|
||||||
|
if (strlen(highlight) - strlen(token) < strlen(token)) break;
|
||||||
|
highlight = fstrstr(highlight + strlen(token), token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
drawitem(struct item *item, int x, int y, int w)
|
||||||
|
{
|
||||||
|
if (item == sel)
|
||||||
|
drw_setscheme(drw, scheme[SchemeSel]);
|
||||||
|
else if (item->out)
|
||||||
|
drw_setscheme(drw, scheme[SchemeOut]);
|
||||||
|
else
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
|
||||||
|
int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||||
|
drawhighlights(item, x, y, w);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
recalculatenumbers()
|
||||||
|
{
|
||||||
|
unsigned int numer = 0, denom = 0;
|
||||||
|
struct item *item;
|
||||||
|
if (matchend) {
|
||||||
|
numer++;
|
||||||
|
for (item = matchend; item && item->left; item = item->left)
|
||||||
|
numer++;
|
||||||
|
}
|
||||||
|
for (item = items; item && item->text; item++)
|
||||||
|
denom++;
|
||||||
|
snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
drawmenu(void)
|
||||||
|
{
|
||||||
|
unsigned int curpos;
|
||||||
|
struct item *item;
|
||||||
|
int x = 0, y = 0, fh = drw->fonts->h, w;
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||||
|
|
||||||
|
if (prompt && *prompt) {
|
||||||
|
drw_setscheme(drw, scheme[SchemeSel]);
|
||||||
|
x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0);
|
||||||
|
}
|
||||||
|
/* draw input field */
|
||||||
|
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
|
||||||
|
|
||||||
|
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
||||||
|
if ((curpos += lrpad / 2 - 1) < w) {
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
recalculatenumbers();
|
||||||
|
if (lines > 0) {
|
||||||
|
/* draw vertical list */
|
||||||
|
for (item = curr; item != next; item = item->right)
|
||||||
|
drawitem(item, x, y += bh, mw - x);
|
||||||
|
} else if (matches) {
|
||||||
|
/* draw horizontal list */
|
||||||
|
x += inputw;
|
||||||
|
w = TEXTW("<");
|
||||||
|
if (curr->left) {
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0);
|
||||||
|
}
|
||||||
|
x += w;
|
||||||
|
for (item = curr; item != next; item = item->right)
|
||||||
|
x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">") - TEXTW(numbers)));
|
||||||
|
if (next) {
|
||||||
|
w = TEXTW(">");
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, mw - w - TEXTW(numbers), 0, w, bh, lrpad / 2, ">", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, mw - TEXTW(numbers), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0);
|
||||||
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
grabfocus(void)
|
||||||
|
{
|
||||||
|
struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
|
||||||
|
Window focuswin;
|
||||||
|
int i, revertwin;
|
||||||
|
|
||||||
|
for (i = 0; i < 100; ++i) {
|
||||||
|
XGetInputFocus(dpy, &focuswin, &revertwin);
|
||||||
|
if (focuswin == win)
|
||||||
|
return;
|
||||||
|
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
}
|
||||||
|
die("cannot grab focus");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
grabkeyboard(void)
|
||||||
|
{
|
||||||
|
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (embed)
|
||||||
|
return;
|
||||||
|
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
||||||
|
for (i = 0; i < 1000; i++) {
|
||||||
|
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync,
|
||||||
|
GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||||
|
return;
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
}
|
||||||
|
die("cannot grab keyboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
match(void)
|
||||||
|
{
|
||||||
|
static char **tokv = NULL;
|
||||||
|
static int tokn = 0;
|
||||||
|
|
||||||
|
char buf[sizeof text], *s;
|
||||||
|
int i, tokc = 0;
|
||||||
|
size_t len, textsize;
|
||||||
|
struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
|
||||||
|
|
||||||
|
strcpy(buf, text);
|
||||||
|
/* separate input text into tokens to be matched individually */
|
||||||
|
for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " "))
|
||||||
|
if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv)))
|
||||||
|
die("cannot realloc %zu bytes:", tokn * sizeof *tokv);
|
||||||
|
len = tokc ? strlen(tokv[0]) : 0;
|
||||||
|
|
||||||
|
matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
|
||||||
|
textsize = strlen(text) + 1;
|
||||||
|
for (item = items; item && item->text; item++) {
|
||||||
|
for (i = 0; i < tokc; i++)
|
||||||
|
if (!fstrstr(item->text, tokv[i]))
|
||||||
|
break;
|
||||||
|
if (i != tokc) /* not all tokens match */
|
||||||
|
continue;
|
||||||
|
/* exact matches go first, then prefixes, then substrings */
|
||||||
|
if (!tokc || !fstrncmp(text, item->text, textsize))
|
||||||
|
appenditem(item, &matches, &matchend);
|
||||||
|
else if (!fstrncmp(tokv[0], item->text, len))
|
||||||
|
appenditem(item, &lprefix, &prefixend);
|
||||||
|
else
|
||||||
|
appenditem(item, &lsubstr, &substrend);
|
||||||
|
}
|
||||||
|
if (lprefix) {
|
||||||
|
if (matches) {
|
||||||
|
matchend->right = lprefix;
|
||||||
|
lprefix->left = matchend;
|
||||||
|
} else
|
||||||
|
matches = lprefix;
|
||||||
|
matchend = prefixend;
|
||||||
|
}
|
||||||
|
if (lsubstr) {
|
||||||
|
if (matches) {
|
||||||
|
matchend->right = lsubstr;
|
||||||
|
lsubstr->left = matchend;
|
||||||
|
} else
|
||||||
|
matches = lsubstr;
|
||||||
|
matchend = substrend;
|
||||||
|
}
|
||||||
|
curr = sel = matches;
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
insert(const char *str, ssize_t n)
|
||||||
|
{
|
||||||
|
if (strlen(text) + n > sizeof text - 1)
|
||||||
|
return;
|
||||||
|
/* move existing text out of the way, insert new text, and update cursor */
|
||||||
|
memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0));
|
||||||
|
if (n > 0)
|
||||||
|
memcpy(&text[cursor], str, n);
|
||||||
|
cursor += n;
|
||||||
|
match();
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
nextrune(int inc)
|
||||||
|
{
|
||||||
|
ssize_t n;
|
||||||
|
|
||||||
|
/* return location of next utf8 rune in the given direction (+1 or -1) */
|
||||||
|
for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc)
|
||||||
|
;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
movewordedge(int dir)
|
||||||
|
{
|
||||||
|
if (dir < 0) { /* move cursor to the start of the word*/
|
||||||
|
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
cursor = nextrune(-1);
|
||||||
|
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
cursor = nextrune(-1);
|
||||||
|
} else { /* move cursor to the end of the word */
|
||||||
|
while (text[cursor] && strchr(worddelimiters, text[cursor]))
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
while (text[cursor] && !strchr(worddelimiters, text[cursor]))
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
keypress(XKeyEvent *ev)
|
||||||
|
{
|
||||||
|
char buf[64];
|
||||||
|
int len;
|
||||||
|
KeySym ksym = NoSymbol;
|
||||||
|
Status status;
|
||||||
|
|
||||||
|
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
|
||||||
|
switch (status) {
|
||||||
|
default: /* XLookupNone, XBufferOverflow */
|
||||||
|
return;
|
||||||
|
case XLookupChars: /* composed string from input method */
|
||||||
|
goto insert;
|
||||||
|
case XLookupKeySym:
|
||||||
|
case XLookupBoth: /* a KeySym and a string are returned: use keysym */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev->state & ControlMask) {
|
||||||
|
switch(ksym) {
|
||||||
|
case XK_a: ksym = XK_Home; break;
|
||||||
|
case XK_b: ksym = XK_Left; break;
|
||||||
|
case XK_c: ksym = XK_Escape; break;
|
||||||
|
case XK_d: ksym = XK_Delete; break;
|
||||||
|
case XK_e: ksym = XK_End; break;
|
||||||
|
case XK_f: ksym = XK_Right; break;
|
||||||
|
case XK_g: ksym = XK_Escape; break;
|
||||||
|
case XK_h: ksym = XK_BackSpace; break;
|
||||||
|
case XK_i: ksym = XK_Tab; break;
|
||||||
|
case XK_j: /* fallthrough */
|
||||||
|
case XK_J: /* fallthrough */
|
||||||
|
case XK_m: /* fallthrough */
|
||||||
|
case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break;
|
||||||
|
case XK_n: ksym = XK_Down; break;
|
||||||
|
case XK_p: ksym = XK_Up; break;
|
||||||
|
|
||||||
|
case XK_k: /* delete right */
|
||||||
|
text[cursor] = '\0';
|
||||||
|
match();
|
||||||
|
break;
|
||||||
|
case XK_u: /* delete left */
|
||||||
|
insert(NULL, 0 - cursor);
|
||||||
|
break;
|
||||||
|
case XK_w: /* delete word */
|
||||||
|
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
insert(NULL, nextrune(-1) - cursor);
|
||||||
|
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
insert(NULL, nextrune(-1) - cursor);
|
||||||
|
break;
|
||||||
|
case XK_y: /* paste selection */
|
||||||
|
case XK_Y:
|
||||||
|
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
|
||||||
|
utf8, utf8, win, CurrentTime);
|
||||||
|
return;
|
||||||
|
case XK_Left:
|
||||||
|
case XK_KP_Left:
|
||||||
|
movewordedge(-1);
|
||||||
|
goto draw;
|
||||||
|
case XK_Right:
|
||||||
|
case XK_KP_Right:
|
||||||
|
movewordedge(+1);
|
||||||
|
goto draw;
|
||||||
|
case XK_Return:
|
||||||
|
case XK_KP_Enter:
|
||||||
|
break;
|
||||||
|
case XK_bracketleft:
|
||||||
|
cleanup();
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (ev->state & Mod1Mask) {
|
||||||
|
switch(ksym) {
|
||||||
|
case XK_b:
|
||||||
|
movewordedge(-1);
|
||||||
|
goto draw;
|
||||||
|
case XK_f:
|
||||||
|
movewordedge(+1);
|
||||||
|
goto draw;
|
||||||
|
case XK_g: ksym = XK_Home; break;
|
||||||
|
case XK_G: ksym = XK_End; break;
|
||||||
|
case XK_h: ksym = XK_Up; break;
|
||||||
|
case XK_j: ksym = XK_Next; break;
|
||||||
|
case XK_k: ksym = XK_Prior; break;
|
||||||
|
case XK_l: ksym = XK_Down; break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(ksym) {
|
||||||
|
default:
|
||||||
|
insert:
|
||||||
|
if (!iscntrl((unsigned char)*buf))
|
||||||
|
insert(buf, len);
|
||||||
|
break;
|
||||||
|
case XK_Delete:
|
||||||
|
case XK_KP_Delete:
|
||||||
|
if (text[cursor] == '\0')
|
||||||
|
return;
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
/* fallthrough */
|
||||||
|
case XK_BackSpace:
|
||||||
|
if (cursor == 0)
|
||||||
|
return;
|
||||||
|
insert(NULL, nextrune(-1) - cursor);
|
||||||
|
break;
|
||||||
|
case XK_End:
|
||||||
|
case XK_KP_End:
|
||||||
|
if (text[cursor] != '\0') {
|
||||||
|
cursor = strlen(text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (next) {
|
||||||
|
/* jump to end of list and position items in reverse */
|
||||||
|
curr = matchend;
|
||||||
|
calcoffsets();
|
||||||
|
curr = prev;
|
||||||
|
calcoffsets();
|
||||||
|
while (next && (curr = curr->right))
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
sel = matchend;
|
||||||
|
break;
|
||||||
|
case XK_Escape:
|
||||||
|
cleanup();
|
||||||
|
exit(1);
|
||||||
|
case XK_Home:
|
||||||
|
case XK_KP_Home:
|
||||||
|
if (sel == matches) {
|
||||||
|
cursor = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sel = curr = matches;
|
||||||
|
calcoffsets();
|
||||||
|
break;
|
||||||
|
case XK_Left:
|
||||||
|
case XK_KP_Left:
|
||||||
|
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
|
||||||
|
cursor = nextrune(-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (lines > 0)
|
||||||
|
return;
|
||||||
|
/* fallthrough */
|
||||||
|
case XK_Up:
|
||||||
|
case XK_KP_Up:
|
||||||
|
if (sel && sel->left && (sel = sel->left)->right == curr) {
|
||||||
|
curr = prev;
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XK_Next:
|
||||||
|
case XK_KP_Next:
|
||||||
|
if (!next)
|
||||||
|
return;
|
||||||
|
sel = curr = next;
|
||||||
|
calcoffsets();
|
||||||
|
break;
|
||||||
|
case XK_Prior:
|
||||||
|
case XK_KP_Prior:
|
||||||
|
if (!prev)
|
||||||
|
return;
|
||||||
|
sel = curr = prev;
|
||||||
|
calcoffsets();
|
||||||
|
break;
|
||||||
|
case XK_Return:
|
||||||
|
case XK_KP_Enter:
|
||||||
|
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
|
||||||
|
if (!(ev->state & ControlMask)) {
|
||||||
|
cleanup();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
if (sel)
|
||||||
|
sel->out = 1;
|
||||||
|
break;
|
||||||
|
case XK_Right:
|
||||||
|
case XK_KP_Right:
|
||||||
|
if (text[cursor] != '\0') {
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (lines > 0)
|
||||||
|
return;
|
||||||
|
/* fallthrough */
|
||||||
|
case XK_Down:
|
||||||
|
case XK_KP_Down:
|
||||||
|
if (sel && sel->right && (sel = sel->right) == next) {
|
||||||
|
curr = next;
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XK_Tab:
|
||||||
|
if (!sel)
|
||||||
|
return;
|
||||||
|
cursor = strnlen(sel->text, sizeof text - 1);
|
||||||
|
memcpy(text, sel->text, cursor);
|
||||||
|
text[cursor] = '\0';
|
||||||
|
match();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw:
|
||||||
|
drawmenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
paste(void)
|
||||||
|
{
|
||||||
|
char *p, *q;
|
||||||
|
int di;
|
||||||
|
unsigned long dl;
|
||||||
|
Atom da;
|
||||||
|
|
||||||
|
/* we have been given the current selection, now insert it into input */
|
||||||
|
if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
|
||||||
|
utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
|
||||||
|
== Success && p) {
|
||||||
|
insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
|
||||||
|
XFree(p);
|
||||||
|
}
|
||||||
|
drawmenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
readstdin(void)
|
||||||
|
{
|
||||||
|
char *line = NULL;
|
||||||
|
size_t i, junk, itemsiz = 0;
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
/* read each line from stdin and add it to the item list */
|
||||||
|
for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++) {
|
||||||
|
if (i + 1 >= itemsiz) {
|
||||||
|
itemsiz += 256;
|
||||||
|
if (!(items = realloc(items, itemsiz * sizeof(*items))))
|
||||||
|
die("cannot realloc %zu bytes:", itemsiz * sizeof(*items));
|
||||||
|
}
|
||||||
|
if (line[len - 1] == '\n')
|
||||||
|
line[len - 1] = '\0';
|
||||||
|
items[i].text = line;
|
||||||
|
items[i].out = 0;
|
||||||
|
line = NULL; /* next call of getline() allocates a new line */
|
||||||
|
}
|
||||||
|
free(line);
|
||||||
|
if (items)
|
||||||
|
items[i].text = NULL;
|
||||||
|
lines = MIN(lines, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run(void)
|
||||||
|
{
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
while (!XNextEvent(dpy, &ev)) {
|
||||||
|
if (XFilterEvent(&ev, win))
|
||||||
|
continue;
|
||||||
|
switch(ev.type) {
|
||||||
|
case DestroyNotify:
|
||||||
|
if (ev.xdestroywindow.window != win)
|
||||||
|
break;
|
||||||
|
cleanup();
|
||||||
|
exit(1);
|
||||||
|
case Expose:
|
||||||
|
if (ev.xexpose.count == 0)
|
||||||
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
|
break;
|
||||||
|
case FocusIn:
|
||||||
|
/* regrab focus from parent window */
|
||||||
|
if (ev.xfocus.window != win)
|
||||||
|
grabfocus();
|
||||||
|
break;
|
||||||
|
case KeyPress:
|
||||||
|
keypress(&ev.xkey);
|
||||||
|
break;
|
||||||
|
case SelectionNotify:
|
||||||
|
if (ev.xselection.property == utf8)
|
||||||
|
paste();
|
||||||
|
break;
|
||||||
|
case VisibilityNotify:
|
||||||
|
if (ev.xvisibility.state != VisibilityUnobscured)
|
||||||
|
XRaiseWindow(dpy, win);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup(void)
|
||||||
|
{
|
||||||
|
int x, y, i, j;
|
||||||
|
unsigned int du;
|
||||||
|
XSetWindowAttributes swa;
|
||||||
|
XIM xim;
|
||||||
|
Window w, dw, *dws;
|
||||||
|
XWindowAttributes wa;
|
||||||
|
XClassHint ch = {"dmenu", "dmenu"};
|
||||||
|
#ifdef XINERAMA
|
||||||
|
XineramaScreenInfo *info;
|
||||||
|
Window pw;
|
||||||
|
int a, di, n, area = 0;
|
||||||
|
#endif
|
||||||
|
/* init appearance */
|
||||||
|
for (j = 0; j < SchemeLast; j++)
|
||||||
|
scheme[j] = drw_scm_create(drw, colors[j], alphas[i], 2);
|
||||||
|
|
||||||
|
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||||
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
|
||||||
|
/* calculate menu geometry */
|
||||||
|
bh = drw->fonts->h + 2;
|
||||||
|
bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
|
||||||
|
lines = MAX(lines, 0);
|
||||||
|
mh = (lines + 1) * bh;
|
||||||
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
|
#ifdef XINERAMA
|
||||||
|
i = 0;
|
||||||
|
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||||
|
XGetInputFocus(dpy, &w, &di);
|
||||||
|
if (mon >= 0 && mon < n)
|
||||||
|
i = mon;
|
||||||
|
else if (w != root && w != PointerRoot && w != None) {
|
||||||
|
/* find top-level window containing current input focus */
|
||||||
|
do {
|
||||||
|
if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws)
|
||||||
|
XFree(dws);
|
||||||
|
} while (w != root && w != pw);
|
||||||
|
/* find xinerama screen with which the window intersects most */
|
||||||
|
if (XGetWindowAttributes(dpy, pw, &wa))
|
||||||
|
for (j = 0; j < n; j++)
|
||||||
|
if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {
|
||||||
|
area = a;
|
||||||
|
i = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* no focused window is on screen, so use pointer location instead */
|
||||||
|
if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (centered) {
|
||||||
|
mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
|
||||||
|
x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||||
|
y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||||
|
} else {
|
||||||
|
x = info[i].x_org;
|
||||||
|
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||||
|
mw = info[i].width;
|
||||||
|
}
|
||||||
|
|
||||||
|
XFree(info);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
|
parentwin);
|
||||||
|
|
||||||
|
if (centered) {
|
||||||
|
mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
|
||||||
|
x = (wa.width - mw) / 2;
|
||||||
|
y = (wa.height - mh) / 2;
|
||||||
|
} else {
|
||||||
|
x = 0;
|
||||||
|
y = topbar ? 0 : wa.height - mh;
|
||||||
|
mw = wa.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
|
inputw = mw / 3; /* input width: ~33% of monitor width */
|
||||||
|
match();
|
||||||
|
|
||||||
|
/* create menu window */
|
||||||
|
swa.override_redirect = True;
|
||||||
|
swa.background_pixel = 0;
|
||||||
|
swa.border_pixel = 0;
|
||||||
|
swa.colormap = cmap;
|
||||||
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
|
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||||
|
depth, CopyFromParent, visual,
|
||||||
|
CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap |
|
||||||
|
CWEventMask, &swa);
|
||||||
|
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||||
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
|
||||||
|
/* input methods */
|
||||||
|
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
|
||||||
|
die("XOpenIM failed: could not open input device");
|
||||||
|
|
||||||
|
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||||
|
XNClientWindow, win, XNFocusWindow, win, NULL);
|
||||||
|
|
||||||
|
XMapRaised(dpy, win);
|
||||||
|
if (embed) {
|
||||||
|
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
||||||
|
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
||||||
|
for (i = 0; i < du && dws[i] != win; ++i)
|
||||||
|
XSelectInput(dpy, dws[i], FocusChangeMask);
|
||||||
|
XFree(dws);
|
||||||
|
}
|
||||||
|
grabfocus();
|
||||||
|
}
|
||||||
|
drw_resize(drw, mw, mh);
|
||||||
|
drawmenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
die("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
|
||||||
|
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
XWindowAttributes wa;
|
||||||
|
int i, fast = 0;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
/* these options take no arguments */
|
||||||
|
if (!strcmp(argv[i], "-v")) { /* prints version information */
|
||||||
|
puts("dmenu-"VERSION);
|
||||||
|
exit(0);
|
||||||
|
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
|
||||||
|
topbar = 0;
|
||||||
|
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
|
||||||
|
fast = 1;
|
||||||
|
else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
|
||||||
|
centered = 1;
|
||||||
|
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||||
|
fstrncmp = strncasecmp;
|
||||||
|
fstrstr = cistrstr;
|
||||||
|
} else if (i + 1 == argc)
|
||||||
|
usage();
|
||||||
|
/* these options take one argument */
|
||||||
|
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
||||||
|
lines = atoi(argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
|
||||||
|
lineheight = atoi(argv[++i]);
|
||||||
|
lineheight = MAX(lineheight, min_lineheight);
|
||||||
|
}
|
||||||
|
else if (!strcmp(argv[i], "-m"))
|
||||||
|
mon = atoi(argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||||
|
prompt = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-fn")) /* font or font set */
|
||||||
|
fonts[0] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-nb")) /* normal background color */
|
||||||
|
colors[SchemeNorm][ColBg] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
|
||||||
|
colors[SchemeNorm][ColFg] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-sb")) /* selected background color */
|
||||||
|
colors[SchemeSel][ColBg] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
|
||||||
|
colors[SchemeSel][ColFg] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||||
|
embed = argv[++i];
|
||||||
|
else
|
||||||
|
usage();
|
||||||
|
|
||||||
|
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||||
|
fputs("warning: no locale support\n", stderr);
|
||||||
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
|
die("cannot open display");
|
||||||
|
screen = DefaultScreen(dpy);
|
||||||
|
root = RootWindow(dpy, screen);
|
||||||
|
if (!embed || !(parentwin = strtol(embed, NULL, 0)))
|
||||||
|
parentwin = root;
|
||||||
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
|
parentwin);
|
||||||
|
xinitvisual();
|
||||||
|
|
||||||
|
xinitvisual();
|
||||||
|
drw = drw_create(dpy, screen, root, wa.width, wa.height, visual, depth, cmap);
|
||||||
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||||
|
die("no fonts could be loaded.");
|
||||||
|
lrpad = drw->fonts->h;
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
if (pledge("stdio rpath", NULL) == -1)
|
||||||
|
die("pledge");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fast && !isatty(0)) {
|
||||||
|
grabkeyboard();
|
||||||
|
readstdin();
|
||||||
|
} else {
|
||||||
|
readstdin();
|
||||||
|
grabkeyboard();
|
||||||
|
}
|
||||||
|
setup();
|
||||||
|
run();
|
||||||
|
|
||||||
|
return 1; /* unreachable */
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
xinitvisual()
|
||||||
|
{
|
||||||
|
XVisualInfo *infos;
|
||||||
|
XRenderPictFormat *fmt;
|
||||||
|
int nitems;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
XVisualInfo tpl = {
|
||||||
|
.screen = screen,
|
||||||
|
.depth = 32,
|
||||||
|
.class = TrueColor
|
||||||
|
};
|
||||||
|
long masks = VisualScreenMask | VisualDepthMask | VisualClassMask;
|
||||||
|
|
||||||
|
infos = XGetVisualInfo(dpy, masks, &tpl, &nitems);
|
||||||
|
visual = NULL;
|
||||||
|
for(i = 0; i < nitems; i ++) {
|
||||||
|
fmt = XRenderFindVisualFormat(dpy, infos[i].visual);
|
||||||
|
if (fmt->type == PictTypeDirect && fmt->direct.alphaMask) {
|
||||||
|
visual = infos[i].visual;
|
||||||
|
depth = infos[i].depth;
|
||||||
|
cmap = XCreateColormap(dpy, root, visual, AllocNone);
|
||||||
|
useargb = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XFree(infos);
|
||||||
|
|
||||||
|
if (! visual) {
|
||||||
|
visual = DefaultVisual(dpy, screen);
|
||||||
|
depth = DefaultDepth(dpy, screen);
|
||||||
|
cmap = DefaultColormap(dpy, screen);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,887 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#include <X11/Xutil.h>
|
||||||
|
#ifdef XINERAMA
|
||||||
|
#include <X11/extensions/Xinerama.h>
|
||||||
|
#endif
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
|
#include "drw.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
/* macros */
|
||||||
|
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
|
||||||
|
* MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org)))
|
||||||
|
#define LENGTH(X) (sizeof X / sizeof X[0])
|
||||||
|
#define TEXTW(X) (drw_fontset_getwidth(drw, (X)) + lrpad)
|
||||||
|
#define NUMBERSMAXDIGITS 100
|
||||||
|
#define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1
|
||||||
|
|
||||||
|
/* enums */
|
||||||
|
enum { SchemeNorm, SchemeSel, SchemeOut, SchemeNormHighlight, SchemeSelHighlight, SchemeLast }; /* color schemes */
|
||||||
|
|
||||||
|
struct item {
|
||||||
|
char *text;
|
||||||
|
struct item *left, *right;
|
||||||
|
int out;
|
||||||
|
};
|
||||||
|
|
||||||
|
static char numbers[NUMBERSBUFSIZE] = "";
|
||||||
|
static char text[BUFSIZ] = "";
|
||||||
|
static char *embed;
|
||||||
|
static int bh, mw, mh;
|
||||||
|
static int inputw = 0, promptw;
|
||||||
|
static int lrpad; /* sum of left and right padding */
|
||||||
|
static size_t cursor;
|
||||||
|
static struct item *items = NULL;
|
||||||
|
static struct item *matches, *matchend;
|
||||||
|
static struct item *prev, *curr, *next, *sel;
|
||||||
|
static int mon = -1, screen;
|
||||||
|
|
||||||
|
static Atom clip, utf8;
|
||||||
|
static Display *dpy;
|
||||||
|
static Window root, parentwin, win;
|
||||||
|
static XIC xic;
|
||||||
|
|
||||||
|
static Drw *drw;
|
||||||
|
static Clr *scheme[SchemeLast];
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
|
||||||
|
static char *(*fstrstr)(const char *, const char *) = strstr;
|
||||||
|
|
||||||
|
static unsigned int
|
||||||
|
textw_clamp(const char *str, unsigned int n)
|
||||||
|
{
|
||||||
|
unsigned int w = drw_fontset_getwidth_clamp(drw, str, n) + lrpad;
|
||||||
|
return MIN(w, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
appenditem(struct item *item, struct item **list, struct item **last)
|
||||||
|
{
|
||||||
|
if (*last)
|
||||||
|
(*last)->right = item;
|
||||||
|
else
|
||||||
|
*list = item;
|
||||||
|
|
||||||
|
item->left = *last;
|
||||||
|
item->right = NULL;
|
||||||
|
*last = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
calcoffsets(void)
|
||||||
|
{
|
||||||
|
int i, n;
|
||||||
|
|
||||||
|
if (lines > 0)
|
||||||
|
n = lines * bh;
|
||||||
|
else
|
||||||
|
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">") + TEXTW(numbers));
|
||||||
|
/* calculate which items will begin the next page and previous page */
|
||||||
|
for (i = 0, next = curr; next; next = next->right)
|
||||||
|
if ((i += (lines > 0) ? bh : textw_clamp(next->text, n)) > n)
|
||||||
|
break;
|
||||||
|
for (i = 0, prev = curr; prev && prev->left; prev = prev->left)
|
||||||
|
if ((i += (lines > 0) ? bh : textw_clamp(prev->left->text, n)) > n)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
max_textw(void)
|
||||||
|
{
|
||||||
|
int len = 0;
|
||||||
|
for (struct item *item = items; item && item->text; item++)
|
||||||
|
len = MAX(TEXTW(item->text), len);
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
cleanup(void)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
XUngrabKey(dpy, AnyKey, AnyModifier, root);
|
||||||
|
for (i = 0; i < SchemeLast; i++)
|
||||||
|
free(scheme[i]);
|
||||||
|
for (i = 0; items && items[i].text; ++i)
|
||||||
|
free(items[i].text);
|
||||||
|
free(items);
|
||||||
|
drw_free(drw);
|
||||||
|
XSync(dpy, False);
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
cistrstr(const char *h, const char *n)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!n[0])
|
||||||
|
return (char *)h;
|
||||||
|
|
||||||
|
for (; *h; ++h) {
|
||||||
|
for (i = 0; n[i] && tolower((unsigned char)n[i]) ==
|
||||||
|
tolower((unsigned char)h[i]); ++i)
|
||||||
|
;
|
||||||
|
if (n[i] == '\0')
|
||||||
|
return (char *)h;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
drawhighlights(struct item *item, int x, int y, int maxw)
|
||||||
|
{
|
||||||
|
char restorechar, tokens[sizeof text], *highlight, *token;
|
||||||
|
int indentx, highlightlen;
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[item == sel ? SchemeSelHighlight : SchemeNormHighlight]);
|
||||||
|
strcpy(tokens, text);
|
||||||
|
for (token = strtok(tokens, " "); token; token = strtok(NULL, " ")) {
|
||||||
|
highlight = fstrstr(item->text, token);
|
||||||
|
while (highlight) {
|
||||||
|
// Move item str end, calc width for highlight indent, & restore
|
||||||
|
highlightlen = highlight - item->text;
|
||||||
|
restorechar = *highlight;
|
||||||
|
item->text[highlightlen] = '\0';
|
||||||
|
indentx = TEXTW(item->text);
|
||||||
|
item->text[highlightlen] = restorechar;
|
||||||
|
|
||||||
|
// Move highlight str end, draw highlight, & restore
|
||||||
|
restorechar = highlight[strlen(token)];
|
||||||
|
highlight[strlen(token)] = '\0';
|
||||||
|
if (indentx - (lrpad / 2) - 1 < maxw)
|
||||||
|
drw_text(
|
||||||
|
drw,
|
||||||
|
x + indentx - (lrpad / 2) - 1,
|
||||||
|
y,
|
||||||
|
MIN(maxw - indentx, TEXTW(highlight) - lrpad),
|
||||||
|
bh, 0, highlight, 0
|
||||||
|
);
|
||||||
|
highlight[strlen(token)] = restorechar;
|
||||||
|
|
||||||
|
if (strlen(highlight) - strlen(token) < strlen(token)) break;
|
||||||
|
highlight = fstrstr(highlight + strlen(token), token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
drawitem(struct item *item, int x, int y, int w)
|
||||||
|
{
|
||||||
|
if (item == sel)
|
||||||
|
drw_setscheme(drw, scheme[SchemeSel]);
|
||||||
|
else if (item->out)
|
||||||
|
drw_setscheme(drw, scheme[SchemeOut]);
|
||||||
|
else
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
|
||||||
|
int r = drw_text(drw, x, y, w, bh, lrpad / 2, item->text, 0);
|
||||||
|
drawhighlights(item, x, y, w);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
recalculatenumbers()
|
||||||
|
{
|
||||||
|
unsigned int numer = 0, denom = 0;
|
||||||
|
struct item *item;
|
||||||
|
if (matchend) {
|
||||||
|
numer++;
|
||||||
|
for (item = matchend; item && item->left; item = item->left)
|
||||||
|
numer++;
|
||||||
|
}
|
||||||
|
for (item = items; item && item->text; item++)
|
||||||
|
denom++;
|
||||||
|
snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
drawmenu(void)
|
||||||
|
{
|
||||||
|
unsigned int curpos;
|
||||||
|
struct item *item;
|
||||||
|
int x = 0, y = 0, fh = drw->fonts->h, w;
|
||||||
|
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_rect(drw, 0, 0, mw, mh, 1, 1);
|
||||||
|
|
||||||
|
if (prompt && *prompt) {
|
||||||
|
drw_setscheme(drw, scheme[SchemeSel]);
|
||||||
|
x = drw_text(drw, x, 0, promptw, bh, lrpad / 2, prompt, 0);
|
||||||
|
}
|
||||||
|
/* draw input field */
|
||||||
|
w = (lines > 0 || !matches) ? mw - x : inputw;
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, x, 0, w, bh, lrpad / 2, text, 0);
|
||||||
|
|
||||||
|
curpos = TEXTW(text) - TEXTW(&text[cursor]);
|
||||||
|
if ((curpos += lrpad / 2 - 1) < w) {
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_rect(drw, x + curpos, 2 + (bh - fh) / 2, 2, fh - 4, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
recalculatenumbers();
|
||||||
|
if (lines > 0) {
|
||||||
|
/* draw vertical list */
|
||||||
|
for (item = curr; item != next; item = item->right)
|
||||||
|
drawitem(item, x, y += bh, mw - x);
|
||||||
|
} else if (matches) {
|
||||||
|
/* draw horizontal list */
|
||||||
|
x += inputw;
|
||||||
|
w = TEXTW("<");
|
||||||
|
if (curr->left) {
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, x, 0, w, bh, lrpad / 2, "<", 0);
|
||||||
|
}
|
||||||
|
x += w;
|
||||||
|
for (item = curr; item != next; item = item->right)
|
||||||
|
x = drawitem(item, x, 0, textw_clamp(item->text, mw - x - TEXTW(">") - TEXTW(numbers)));
|
||||||
|
if (next) {
|
||||||
|
w = TEXTW(">");
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, mw - w - TEXTW(numbers), 0, w, bh, lrpad / 2, ">", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drw_setscheme(drw, scheme[SchemeNorm]);
|
||||||
|
drw_text(drw, mw - TEXTW(numbers), 0, TEXTW(numbers), bh, lrpad / 2, numbers, 0);
|
||||||
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
grabfocus(void)
|
||||||
|
{
|
||||||
|
struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
|
||||||
|
Window focuswin;
|
||||||
|
int i, revertwin;
|
||||||
|
|
||||||
|
for (i = 0; i < 100; ++i) {
|
||||||
|
XGetInputFocus(dpy, &focuswin, &revertwin);
|
||||||
|
if (focuswin == win)
|
||||||
|
return;
|
||||||
|
XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
}
|
||||||
|
die("cannot grab focus");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
grabkeyboard(void)
|
||||||
|
{
|
||||||
|
struct timespec ts = { .tv_sec = 0, .tv_nsec = 1000000 };
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (embed)
|
||||||
|
return;
|
||||||
|
/* try to grab keyboard, we may have to wait for another process to ungrab */
|
||||||
|
for (i = 0; i < 1000; i++) {
|
||||||
|
if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True, GrabModeAsync,
|
||||||
|
GrabModeAsync, CurrentTime) == GrabSuccess)
|
||||||
|
return;
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
}
|
||||||
|
die("cannot grab keyboard");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
match(void)
|
||||||
|
{
|
||||||
|
static char **tokv = NULL;
|
||||||
|
static int tokn = 0;
|
||||||
|
|
||||||
|
char buf[sizeof text], *s;
|
||||||
|
int i, tokc = 0;
|
||||||
|
size_t len, textsize;
|
||||||
|
struct item *item, *lprefix, *lsubstr, *prefixend, *substrend;
|
||||||
|
|
||||||
|
strcpy(buf, text);
|
||||||
|
/* separate input text into tokens to be matched individually */
|
||||||
|
for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " "))
|
||||||
|
if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv)))
|
||||||
|
die("cannot realloc %zu bytes:", tokn * sizeof *tokv);
|
||||||
|
len = tokc ? strlen(tokv[0]) : 0;
|
||||||
|
|
||||||
|
matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL;
|
||||||
|
textsize = strlen(text) + 1;
|
||||||
|
for (item = items; item && item->text; item++) {
|
||||||
|
for (i = 0; i < tokc; i++)
|
||||||
|
if (!fstrstr(item->text, tokv[i]))
|
||||||
|
break;
|
||||||
|
if (i != tokc) /* not all tokens match */
|
||||||
|
continue;
|
||||||
|
/* exact matches go first, then prefixes, then substrings */
|
||||||
|
if (!tokc || !fstrncmp(text, item->text, textsize))
|
||||||
|
appenditem(item, &matches, &matchend);
|
||||||
|
else if (!fstrncmp(tokv[0], item->text, len))
|
||||||
|
appenditem(item, &lprefix, &prefixend);
|
||||||
|
else
|
||||||
|
appenditem(item, &lsubstr, &substrend);
|
||||||
|
}
|
||||||
|
if (lprefix) {
|
||||||
|
if (matches) {
|
||||||
|
matchend->right = lprefix;
|
||||||
|
lprefix->left = matchend;
|
||||||
|
} else
|
||||||
|
matches = lprefix;
|
||||||
|
matchend = prefixend;
|
||||||
|
}
|
||||||
|
if (lsubstr) {
|
||||||
|
if (matches) {
|
||||||
|
matchend->right = lsubstr;
|
||||||
|
lsubstr->left = matchend;
|
||||||
|
} else
|
||||||
|
matches = lsubstr;
|
||||||
|
matchend = substrend;
|
||||||
|
}
|
||||||
|
curr = sel = matches;
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
insert(const char *str, ssize_t n)
|
||||||
|
{
|
||||||
|
if (strlen(text) + n > sizeof text - 1)
|
||||||
|
return;
|
||||||
|
/* move existing text out of the way, insert new text, and update cursor */
|
||||||
|
memmove(&text[cursor + n], &text[cursor], sizeof text - cursor - MAX(n, 0));
|
||||||
|
if (n > 0)
|
||||||
|
memcpy(&text[cursor], str, n);
|
||||||
|
cursor += n;
|
||||||
|
match();
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
nextrune(int inc)
|
||||||
|
{
|
||||||
|
ssize_t n;
|
||||||
|
|
||||||
|
/* return location of next utf8 rune in the given direction (+1 or -1) */
|
||||||
|
for (n = cursor + inc; n + inc >= 0 && (text[n] & 0xc0) == 0x80; n += inc)
|
||||||
|
;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
movewordedge(int dir)
|
||||||
|
{
|
||||||
|
if (dir < 0) { /* move cursor to the start of the word*/
|
||||||
|
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
cursor = nextrune(-1);
|
||||||
|
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
cursor = nextrune(-1);
|
||||||
|
} else { /* move cursor to the end of the word */
|
||||||
|
while (text[cursor] && strchr(worddelimiters, text[cursor]))
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
while (text[cursor] && !strchr(worddelimiters, text[cursor]))
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
keypress(XKeyEvent *ev)
|
||||||
|
{
|
||||||
|
char buf[64];
|
||||||
|
int len;
|
||||||
|
KeySym ksym = NoSymbol;
|
||||||
|
Status status;
|
||||||
|
|
||||||
|
len = XmbLookupString(xic, ev, buf, sizeof buf, &ksym, &status);
|
||||||
|
switch (status) {
|
||||||
|
default: /* XLookupNone, XBufferOverflow */
|
||||||
|
return;
|
||||||
|
case XLookupChars: /* composed string from input method */
|
||||||
|
goto insert;
|
||||||
|
case XLookupKeySym:
|
||||||
|
case XLookupBoth: /* a KeySym and a string are returned: use keysym */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ev->state & ControlMask) {
|
||||||
|
switch(ksym) {
|
||||||
|
case XK_a: ksym = XK_Home; break;
|
||||||
|
case XK_b: ksym = XK_Left; break;
|
||||||
|
case XK_c: ksym = XK_Escape; break;
|
||||||
|
case XK_d: ksym = XK_Delete; break;
|
||||||
|
case XK_e: ksym = XK_End; break;
|
||||||
|
case XK_f: ksym = XK_Right; break;
|
||||||
|
case XK_g: ksym = XK_Escape; break;
|
||||||
|
case XK_h: ksym = XK_BackSpace; break;
|
||||||
|
case XK_i: ksym = XK_Tab; break;
|
||||||
|
case XK_j: /* fallthrough */
|
||||||
|
case XK_J: /* fallthrough */
|
||||||
|
case XK_m: /* fallthrough */
|
||||||
|
case XK_M: ksym = XK_Return; ev->state &= ~ControlMask; break;
|
||||||
|
case XK_n: ksym = XK_Down; break;
|
||||||
|
case XK_p: ksym = XK_Up; break;
|
||||||
|
|
||||||
|
case XK_k: /* delete right */
|
||||||
|
text[cursor] = '\0';
|
||||||
|
match();
|
||||||
|
break;
|
||||||
|
case XK_u: /* delete left */
|
||||||
|
insert(NULL, 0 - cursor);
|
||||||
|
break;
|
||||||
|
case XK_w: /* delete word */
|
||||||
|
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
insert(NULL, nextrune(-1) - cursor);
|
||||||
|
while (cursor > 0 && !strchr(worddelimiters, text[nextrune(-1)]))
|
||||||
|
insert(NULL, nextrune(-1) - cursor);
|
||||||
|
break;
|
||||||
|
case XK_y: /* paste selection */
|
||||||
|
case XK_Y:
|
||||||
|
XConvertSelection(dpy, (ev->state & ShiftMask) ? clip : XA_PRIMARY,
|
||||||
|
utf8, utf8, win, CurrentTime);
|
||||||
|
return;
|
||||||
|
case XK_Left:
|
||||||
|
case XK_KP_Left:
|
||||||
|
movewordedge(-1);
|
||||||
|
goto draw;
|
||||||
|
case XK_Right:
|
||||||
|
case XK_KP_Right:
|
||||||
|
movewordedge(+1);
|
||||||
|
goto draw;
|
||||||
|
case XK_Return:
|
||||||
|
case XK_KP_Enter:
|
||||||
|
break;
|
||||||
|
case XK_bracketleft:
|
||||||
|
cleanup();
|
||||||
|
exit(1);
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (ev->state & Mod1Mask) {
|
||||||
|
switch(ksym) {
|
||||||
|
case XK_b:
|
||||||
|
movewordedge(-1);
|
||||||
|
goto draw;
|
||||||
|
case XK_f:
|
||||||
|
movewordedge(+1);
|
||||||
|
goto draw;
|
||||||
|
case XK_g: ksym = XK_Home; break;
|
||||||
|
case XK_G: ksym = XK_End; break;
|
||||||
|
case XK_h: ksym = XK_Up; break;
|
||||||
|
case XK_j: ksym = XK_Next; break;
|
||||||
|
case XK_k: ksym = XK_Prior; break;
|
||||||
|
case XK_l: ksym = XK_Down; break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(ksym) {
|
||||||
|
default:
|
||||||
|
insert:
|
||||||
|
if (!iscntrl((unsigned char)*buf))
|
||||||
|
insert(buf, len);
|
||||||
|
break;
|
||||||
|
case XK_Delete:
|
||||||
|
case XK_KP_Delete:
|
||||||
|
if (text[cursor] == '\0')
|
||||||
|
return;
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
/* fallthrough */
|
||||||
|
case XK_BackSpace:
|
||||||
|
if (cursor == 0)
|
||||||
|
return;
|
||||||
|
insert(NULL, nextrune(-1) - cursor);
|
||||||
|
break;
|
||||||
|
case XK_End:
|
||||||
|
case XK_KP_End:
|
||||||
|
if (text[cursor] != '\0') {
|
||||||
|
cursor = strlen(text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (next) {
|
||||||
|
/* jump to end of list and position items in reverse */
|
||||||
|
curr = matchend;
|
||||||
|
calcoffsets();
|
||||||
|
curr = prev;
|
||||||
|
calcoffsets();
|
||||||
|
while (next && (curr = curr->right))
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
sel = matchend;
|
||||||
|
break;
|
||||||
|
case XK_Escape:
|
||||||
|
cleanup();
|
||||||
|
exit(1);
|
||||||
|
case XK_Home:
|
||||||
|
case XK_KP_Home:
|
||||||
|
if (sel == matches) {
|
||||||
|
cursor = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sel = curr = matches;
|
||||||
|
calcoffsets();
|
||||||
|
break;
|
||||||
|
case XK_Left:
|
||||||
|
case XK_KP_Left:
|
||||||
|
if (cursor > 0 && (!sel || !sel->left || lines > 0)) {
|
||||||
|
cursor = nextrune(-1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (lines > 0)
|
||||||
|
return;
|
||||||
|
/* fallthrough */
|
||||||
|
case XK_Up:
|
||||||
|
case XK_KP_Up:
|
||||||
|
if (sel && sel->left && (sel = sel->left)->right == curr) {
|
||||||
|
curr = prev;
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XK_Next:
|
||||||
|
case XK_KP_Next:
|
||||||
|
if (!next)
|
||||||
|
return;
|
||||||
|
sel = curr = next;
|
||||||
|
calcoffsets();
|
||||||
|
break;
|
||||||
|
case XK_Prior:
|
||||||
|
case XK_KP_Prior:
|
||||||
|
if (!prev)
|
||||||
|
return;
|
||||||
|
sel = curr = prev;
|
||||||
|
calcoffsets();
|
||||||
|
break;
|
||||||
|
case XK_Return:
|
||||||
|
case XK_KP_Enter:
|
||||||
|
puts((sel && !(ev->state & ShiftMask)) ? sel->text : text);
|
||||||
|
if (!(ev->state & ControlMask)) {
|
||||||
|
cleanup();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
if (sel)
|
||||||
|
sel->out = 1;
|
||||||
|
break;
|
||||||
|
case XK_Right:
|
||||||
|
case XK_KP_Right:
|
||||||
|
if (text[cursor] != '\0') {
|
||||||
|
cursor = nextrune(+1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (lines > 0)
|
||||||
|
return;
|
||||||
|
/* fallthrough */
|
||||||
|
case XK_Down:
|
||||||
|
case XK_KP_Down:
|
||||||
|
if (sel && sel->right && (sel = sel->right) == next) {
|
||||||
|
curr = next;
|
||||||
|
calcoffsets();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case XK_Tab:
|
||||||
|
if (!sel)
|
||||||
|
return;
|
||||||
|
cursor = strnlen(sel->text, sizeof text - 1);
|
||||||
|
memcpy(text, sel->text, cursor);
|
||||||
|
text[cursor] = '\0';
|
||||||
|
match();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
draw:
|
||||||
|
drawmenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
paste(void)
|
||||||
|
{
|
||||||
|
char *p, *q;
|
||||||
|
int di;
|
||||||
|
unsigned long dl;
|
||||||
|
Atom da;
|
||||||
|
|
||||||
|
/* we have been given the current selection, now insert it into input */
|
||||||
|
if (XGetWindowProperty(dpy, win, utf8, 0, (sizeof text / 4) + 1, False,
|
||||||
|
utf8, &da, &di, &dl, &dl, (unsigned char **)&p)
|
||||||
|
== Success && p) {
|
||||||
|
insert(p, (q = strchr(p, '\n')) ? q - p : (ssize_t)strlen(p));
|
||||||
|
XFree(p);
|
||||||
|
}
|
||||||
|
drawmenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
readstdin(void)
|
||||||
|
{
|
||||||
|
char *line = NULL;
|
||||||
|
size_t i, junk, itemsiz = 0;
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
/* read each line from stdin and add it to the item list */
|
||||||
|
for (i = 0; (len = getline(&line, &junk, stdin)) != -1; i++) {
|
||||||
|
if (i + 1 >= itemsiz) {
|
||||||
|
itemsiz += 256;
|
||||||
|
if (!(items = realloc(items, itemsiz * sizeof(*items))))
|
||||||
|
die("cannot realloc %zu bytes:", itemsiz * sizeof(*items));
|
||||||
|
}
|
||||||
|
if (line[len - 1] == '\n')
|
||||||
|
line[len - 1] = '\0';
|
||||||
|
items[i].text = line;
|
||||||
|
items[i].out = 0;
|
||||||
|
line = NULL; /* next call of getline() allocates a new line */
|
||||||
|
}
|
||||||
|
free(line);
|
||||||
|
if (items)
|
||||||
|
items[i].text = NULL;
|
||||||
|
lines = MIN(lines, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
run(void)
|
||||||
|
{
|
||||||
|
XEvent ev;
|
||||||
|
|
||||||
|
while (!XNextEvent(dpy, &ev)) {
|
||||||
|
if (XFilterEvent(&ev, win))
|
||||||
|
continue;
|
||||||
|
switch(ev.type) {
|
||||||
|
case DestroyNotify:
|
||||||
|
if (ev.xdestroywindow.window != win)
|
||||||
|
break;
|
||||||
|
cleanup();
|
||||||
|
exit(1);
|
||||||
|
case Expose:
|
||||||
|
if (ev.xexpose.count == 0)
|
||||||
|
drw_map(drw, win, 0, 0, mw, mh);
|
||||||
|
break;
|
||||||
|
case FocusIn:
|
||||||
|
/* regrab focus from parent window */
|
||||||
|
if (ev.xfocus.window != win)
|
||||||
|
grabfocus();
|
||||||
|
break;
|
||||||
|
case KeyPress:
|
||||||
|
keypress(&ev.xkey);
|
||||||
|
break;
|
||||||
|
case SelectionNotify:
|
||||||
|
if (ev.xselection.property == utf8)
|
||||||
|
paste();
|
||||||
|
break;
|
||||||
|
case VisibilityNotify:
|
||||||
|
if (ev.xvisibility.state != VisibilityUnobscured)
|
||||||
|
XRaiseWindow(dpy, win);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
setup(void)
|
||||||
|
{
|
||||||
|
int x, y, i, j;
|
||||||
|
unsigned int du;
|
||||||
|
XSetWindowAttributes swa;
|
||||||
|
XIM xim;
|
||||||
|
Window w, dw, *dws;
|
||||||
|
XWindowAttributes wa;
|
||||||
|
XClassHint ch = {"dmenu", "dmenu"};
|
||||||
|
#ifdef XINERAMA
|
||||||
|
XineramaScreenInfo *info;
|
||||||
|
Window pw;
|
||||||
|
int a, di, n, area = 0;
|
||||||
|
#endif
|
||||||
|
/* init appearance */
|
||||||
|
for (j = 0; j < SchemeLast; j++)
|
||||||
|
scheme[j] = drw_scm_create(drw, colors[j], 2);
|
||||||
|
|
||||||
|
clip = XInternAtom(dpy, "CLIPBOARD", False);
|
||||||
|
utf8 = XInternAtom(dpy, "UTF8_STRING", False);
|
||||||
|
|
||||||
|
/* calculate menu geometry */
|
||||||
|
bh = drw->fonts->h + 2;
|
||||||
|
bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
|
||||||
|
lines = MAX(lines, 0);
|
||||||
|
mh = (lines + 1) * bh;
|
||||||
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
|
#ifdef XINERAMA
|
||||||
|
i = 0;
|
||||||
|
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
|
||||||
|
XGetInputFocus(dpy, &w, &di);
|
||||||
|
if (mon >= 0 && mon < n)
|
||||||
|
i = mon;
|
||||||
|
else if (w != root && w != PointerRoot && w != None) {
|
||||||
|
/* find top-level window containing current input focus */
|
||||||
|
do {
|
||||||
|
if (XQueryTree(dpy, (pw = w), &dw, &w, &dws, &du) && dws)
|
||||||
|
XFree(dws);
|
||||||
|
} while (w != root && w != pw);
|
||||||
|
/* find xinerama screen with which the window intersects most */
|
||||||
|
if (XGetWindowAttributes(dpy, pw, &wa))
|
||||||
|
for (j = 0; j < n; j++)
|
||||||
|
if ((a = INTERSECT(wa.x, wa.y, wa.width, wa.height, info[j])) > area) {
|
||||||
|
area = a;
|
||||||
|
i = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* no focused window is on screen, so use pointer location instead */
|
||||||
|
if (mon < 0 && !area && XQueryPointer(dpy, root, &dw, &dw, &x, &y, &di, &di, &du))
|
||||||
|
for (i = 0; i < n; i++)
|
||||||
|
if (INTERSECT(x, y, 1, 1, info[i]) != 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (centered) {
|
||||||
|
mw = MIN(MAX(max_textw() + promptw, min_width), info[i].width);
|
||||||
|
x = info[i].x_org + ((info[i].width - mw) / 2);
|
||||||
|
y = info[i].y_org + ((info[i].height - mh) / 2);
|
||||||
|
} else {
|
||||||
|
x = info[i].x_org;
|
||||||
|
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||||
|
mw = info[i].width;
|
||||||
|
}
|
||||||
|
|
||||||
|
XFree(info);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
|
parentwin);
|
||||||
|
|
||||||
|
if (centered) {
|
||||||
|
mw = MIN(MAX(max_textw() + promptw, min_width), wa.width);
|
||||||
|
x = (wa.width - mw) / 2;
|
||||||
|
y = (wa.height - mh) / 2;
|
||||||
|
} else {
|
||||||
|
x = 0;
|
||||||
|
y = topbar ? 0 : wa.height - mh;
|
||||||
|
mw = wa.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
|
||||||
|
inputw = mw / 3; /* input width: ~33% of monitor width */
|
||||||
|
match();
|
||||||
|
|
||||||
|
/* create menu window */
|
||||||
|
swa.override_redirect = True;
|
||||||
|
swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||||
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
|
win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||||
|
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
|
CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
|
XSetWindowBorder(dpy, win, scheme[SchemeSel][ColBg].pixel);
|
||||||
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
|
||||||
|
/* input methods */
|
||||||
|
if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
|
||||||
|
die("XOpenIM failed: could not open input device");
|
||||||
|
|
||||||
|
xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
|
||||||
|
XNClientWindow, win, XNFocusWindow, win, NULL);
|
||||||
|
|
||||||
|
XMapRaised(dpy, win);
|
||||||
|
if (embed) {
|
||||||
|
XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
|
||||||
|
if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
|
||||||
|
for (i = 0; i < du && dws[i] != win; ++i)
|
||||||
|
XSelectInput(dpy, dws[i], FocusChangeMask);
|
||||||
|
XFree(dws);
|
||||||
|
}
|
||||||
|
grabfocus();
|
||||||
|
}
|
||||||
|
drw_resize(drw, mw, mh);
|
||||||
|
drawmenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
die("usage: dmenu [-bfiv] [-l lines] [-h height] [-p prompt] [-fn font] [-m monitor]\n"
|
||||||
|
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
XWindowAttributes wa;
|
||||||
|
int i, fast = 0;
|
||||||
|
|
||||||
|
for (i = 1; i < argc; i++)
|
||||||
|
/* these options take no arguments */
|
||||||
|
if (!strcmp(argv[i], "-v")) { /* prints version information */
|
||||||
|
puts("dmenu-"VERSION);
|
||||||
|
exit(0);
|
||||||
|
} else if (!strcmp(argv[i], "-b")) /* appears at the bottom of the screen */
|
||||||
|
topbar = 0;
|
||||||
|
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
|
||||||
|
fast = 1;
|
||||||
|
else if (!strcmp(argv[i], "-c")) /* centers dmenu on screen */
|
||||||
|
centered = 1;
|
||||||
|
else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
|
||||||
|
fstrncmp = strncasecmp;
|
||||||
|
fstrstr = cistrstr;
|
||||||
|
} else if (i + 1 == argc)
|
||||||
|
usage();
|
||||||
|
/* these options take one argument */
|
||||||
|
else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
|
||||||
|
lines = atoi(argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
|
||||||
|
lineheight = atoi(argv[++i]);
|
||||||
|
lineheight = MAX(lineheight, min_lineheight);
|
||||||
|
}
|
||||||
|
else if (!strcmp(argv[i], "-m"))
|
||||||
|
mon = atoi(argv[++i]);
|
||||||
|
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
|
||||||
|
prompt = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-fn")) /* font or font set */
|
||||||
|
fonts[0] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-nb")) /* normal background color */
|
||||||
|
colors[SchemeNorm][ColBg] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
|
||||||
|
colors[SchemeNorm][ColFg] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-sb")) /* selected background color */
|
||||||
|
colors[SchemeSel][ColBg] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-sf")) /* selected foreground color */
|
||||||
|
colors[SchemeSel][ColFg] = argv[++i];
|
||||||
|
else if (!strcmp(argv[i], "-w")) /* embedding window id */
|
||||||
|
embed = argv[++i];
|
||||||
|
else
|
||||||
|
usage();
|
||||||
|
|
||||||
|
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||||
|
fputs("warning: no locale support\n", stderr);
|
||||||
|
if (!(dpy = XOpenDisplay(NULL)))
|
||||||
|
die("cannot open display");
|
||||||
|
screen = DefaultScreen(dpy);
|
||||||
|
root = RootWindow(dpy, screen);
|
||||||
|
if (!embed || !(parentwin = strtol(embed, NULL, 0)))
|
||||||
|
parentwin = root;
|
||||||
|
if (!XGetWindowAttributes(dpy, parentwin, &wa))
|
||||||
|
die("could not get embedding window attributes: 0x%lx",
|
||||||
|
parentwin);
|
||||||
|
drw = drw_create(dpy, screen, root, wa.width, wa.height);
|
||||||
|
if (!drw_fontset_create(drw, fonts, LENGTH(fonts)))
|
||||||
|
die("no fonts could be loaded.");
|
||||||
|
lrpad = drw->fonts->h;
|
||||||
|
|
||||||
|
#ifdef __OpenBSD__
|
||||||
|
if (pledge("stdio rpath", NULL) == -1)
|
||||||
|
die("pledge");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fast && !isatty(0)) {
|
||||||
|
grabkeyboard();
|
||||||
|
readstdin();
|
||||||
|
} else {
|
||||||
|
readstdin();
|
||||||
|
grabkeyboard();
|
||||||
|
}
|
||||||
|
setup();
|
||||||
|
run();
|
||||||
|
|
||||||
|
return 1; /* unreachable */
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
--- dmenu.c
|
||||||
|
+++ dmenu.c
|
||||||
|
@@ -649,6 +658,7 @@ setup(void)
|
||||||
|
x = info[i].x_org;
|
||||||
|
y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
|
||||||
|
mw = info[i].width;
|
||||||
|
+
|
||||||
|
XFree(info);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
@@ -666,11 +676,13 @@ setup(void)
|
||||||
|
|
||||||
|
/* create menu window */
|
||||||
|
swa.override_redirect = True;
|
||||||
|
- swa.background_pixel = scheme[SchemeNorm][ColBg].pixel;
|
||||||
|
+ swa.background_pixel = 0;
|
||||||
|
+ swa.border_pixel = 0;
|
||||||
|
+ swa.colormap = cmap;
|
||||||
|
swa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
|
||||||
|
- win = XCreateWindow(dpy, parentwin, x, y, mw, mh, 0,
|
||||||
|
- CopyFromParent, CopyFromParent, CopyFromParent,
|
||||||
|
- CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
|
||||||
|
+ win = XCreateWindow(dpy, parentwin, x, y, mw, mh, border_width,
|
||||||
|
+ depth, CopyFromParent, visual,
|
||||||
|
+ CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap | CWEventMask, &swa);
|
||||||
|
XSetClassHint(dpy, win, &ch);
|
||||||
|
|
||||||
|
|
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cachedir="${XDG_CACHE_HOME:-"$HOME/.cache"}"
|
||||||
|
cache="$cachedir/dmenu_run"
|
||||||
|
|
||||||
|
[ ! -e "$cachedir" ] && mkdir -p "$cachedir"
|
||||||
|
|
||||||
|
IFS=:
|
||||||
|
if stest -dqr -n "$cache" $PATH; then
|
||||||
|
stest -flx $PATH | sort -u | tee "$cache"
|
||||||
|
else
|
||||||
|
cat "$cache"
|
||||||
|
fi
|
@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
dmenu_path | dmenu "$@" | ${SHELL:-"/bin/sh"} &
|
@ -0,0 +1,452 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
|
#include "drw.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#define UTF_INVALID 0xFFFD
|
||||||
|
#define UTF_SIZ 4
|
||||||
|
|
||||||
|
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||||
|
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||||
|
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||||
|
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||||
|
|
||||||
|
static long
|
||||||
|
utf8decodebyte(const char c, size_t *i)
|
||||||
|
{
|
||||||
|
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||||
|
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||||
|
return (unsigned char)c & ~utfmask[*i];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
utf8validate(long *u, size_t i)
|
||||||
|
{
|
||||||
|
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||||
|
*u = UTF_INVALID;
|
||||||
|
for (i = 1; *u > utfmax[i]; ++i)
|
||||||
|
;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
utf8decode(const char *c, long *u, size_t clen)
|
||||||
|
{
|
||||||
|
size_t i, j, len, type;
|
||||||
|
long udecoded;
|
||||||
|
|
||||||
|
*u = UTF_INVALID;
|
||||||
|
if (!clen)
|
||||||
|
return 0;
|
||||||
|
udecoded = utf8decodebyte(c[0], &len);
|
||||||
|
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||||
|
return 1;
|
||||||
|
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||||
|
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||||
|
if (type)
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
if (j < len)
|
||||||
|
return 0;
|
||||||
|
*u = udecoded;
|
||||||
|
utf8validate(u, len);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
Drw *
|
||||||
|
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h, Visual *visual, unsigned int depth, Colormap cmap)
|
||||||
|
{
|
||||||
|
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||||
|
|
||||||
|
drw->dpy = dpy;
|
||||||
|
drw->screen = screen;
|
||||||
|
drw->root = root;
|
||||||
|
drw->w = w;
|
||||||
|
drw->h = h;
|
||||||
|
drw->visual = visual;
|
||||||
|
drw->depth = depth;
|
||||||
|
drw->cmap = cmap;
|
||||||
|
drw->drawable = XCreatePixmap(dpy, root, w, h, depth);
|
||||||
|
drw->gc = XCreateGC(dpy, drw->drawable, 0, NULL);
|
||||||
|
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
|
|
||||||
|
return drw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||||
|
{
|
||||||
|
if (!drw)
|
||||||
|
return;
|
||||||
|
|
||||||
|
drw->w = w;
|
||||||
|
drw->h = h;
|
||||||
|
if (drw->drawable)
|
||||||
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
|
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, drw->depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_free(Drw *drw)
|
||||||
|
{
|
||||||
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
|
XFreeGC(drw->dpy, drw->gc);
|
||||||
|
drw_fontset_free(drw->fonts);
|
||||||
|
free(drw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function is an implementation detail. Library users should use
|
||||||
|
* drw_fontset_create instead.
|
||||||
|
*/
|
||||||
|
static Fnt *
|
||||||
|
xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||||
|
{
|
||||||
|
Fnt *font;
|
||||||
|
XftFont *xfont = NULL;
|
||||||
|
FcPattern *pattern = NULL;
|
||||||
|
|
||||||
|
if (fontname) {
|
||||||
|
/* Using the pattern found at font->xfont->pattern does not yield the
|
||||||
|
* same substitution results as using the pattern returned by
|
||||||
|
* FcNameParse; using the latter results in the desired fallback
|
||||||
|
* behaviour whereas the former just results in missing-character
|
||||||
|
* rectangles being drawn, at least with some fonts. */
|
||||||
|
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||||
|
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||||
|
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
|
||||||
|
XftFontClose(drw->dpy, xfont);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else if (fontpattern) {
|
||||||
|
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||||
|
fprintf(stderr, "error, cannot load font from pattern.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
die("no font specified.");
|
||||||
|
}
|
||||||
|
|
||||||
|
font = ecalloc(1, sizeof(Fnt));
|
||||||
|
font->xfont = xfont;
|
||||||
|
font->pattern = pattern;
|
||||||
|
font->h = xfont->ascent + xfont->descent;
|
||||||
|
font->dpy = drw->dpy;
|
||||||
|
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xfont_free(Fnt *font)
|
||||||
|
{
|
||||||
|
if (!font)
|
||||||
|
return;
|
||||||
|
if (font->pattern)
|
||||||
|
FcPatternDestroy(font->pattern);
|
||||||
|
XftFontClose(font->dpy, font->xfont);
|
||||||
|
free(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
Fnt*
|
||||||
|
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||||
|
{
|
||||||
|
Fnt *cur, *ret = NULL;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!drw || !fonts)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 1; i <= fontcount; i++) {
|
||||||
|
if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
|
||||||
|
cur->next = ret;
|
||||||
|
ret = cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (drw->fonts = ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_fontset_free(Fnt *font)
|
||||||
|
{
|
||||||
|
if (font) {
|
||||||
|
drw_fontset_free(font->next);
|
||||||
|
xfont_free(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha)
|
||||||
|
{
|
||||||
|
if (!drw || !dest || !clrname)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!XftColorAllocName(drw->dpy, drw->visual, drw->cmap,
|
||||||
|
clrname, dest))
|
||||||
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
|
|
||||||
|
dest->pixel = (dest->pixel & 0x00ffffffU) | (alpha << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
|
* returned color scheme when done using it. */
|
||||||
|
Clr *
|
||||||
|
drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
Clr *ret;
|
||||||
|
|
||||||
|
/* need at least two colors for a scheme */
|
||||||
|
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < clrcount; i++)
|
||||||
|
drw_clr_create(drw, &ret[i], clrnames[i], alphas[i]);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_setfontset(Drw *drw, Fnt *set)
|
||||||
|
{
|
||||||
|
if (drw)
|
||||||
|
drw->fonts = set;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_setscheme(Drw *drw, Clr *scm)
|
||||||
|
{
|
||||||
|
if (drw)
|
||||||
|
drw->scheme = scm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||||
|
{
|
||||||
|
if (!drw || !drw->scheme)
|
||||||
|
return;
|
||||||
|
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
|
||||||
|
if (filled)
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
else
|
||||||
|
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||||
|
{
|
||||||
|
int i, ty, ellipsis_x = 0;
|
||||||
|
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
||||||
|
XftDraw *d = NULL;
|
||||||
|
Fnt *usedfont, *curfont, *nextfont;
|
||||||
|
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||||
|
long utf8codepoint = 0;
|
||||||
|
const char *utf8str;
|
||||||
|
FcCharSet *fccharset;
|
||||||
|
FcPattern *fcpattern;
|
||||||
|
FcPattern *match;
|
||||||
|
XftResult result;
|
||||||
|
int charexists = 0, overflow = 0;
|
||||||
|
/* keep track of a couple codepoints for which we have no match. */
|
||||||
|
enum { nomatches_len = 64 };
|
||||||
|
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
||||||
|
static unsigned int ellipsis_width = 0;
|
||||||
|
|
||||||
|
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!render) {
|
||||||
|
w = invert ? invert : ~invert;
|
||||||
|
} else {
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
d = XftDrawCreate(drw->dpy, drw->drawable, drw->visual, drw->cmap);
|
||||||
|
x += lpad;
|
||||||
|
w -= lpad;
|
||||||
|
}
|
||||||
|
|
||||||
|
usedfont = drw->fonts;
|
||||||
|
if (!ellipsis_width && render)
|
||||||
|
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||||
|
while (1) {
|
||||||
|
ew = ellipsis_len = utf8strlen = 0;
|
||||||
|
utf8str = text;
|
||||||
|
nextfont = NULL;
|
||||||
|
while (*text) {
|
||||||
|
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||||
|
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||||
|
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||||
|
if (charexists) {
|
||||||
|
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
|
||||||
|
if (ew + ellipsis_width <= w) {
|
||||||
|
/* keep track where the ellipsis still fits */
|
||||||
|
ellipsis_x = x + ew;
|
||||||
|
ellipsis_w = w - ew;
|
||||||
|
ellipsis_len = utf8strlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ew + tmpw > w) {
|
||||||
|
overflow = 1;
|
||||||
|
/* called from drw_fontset_getwidth_clamp():
|
||||||
|
* it wants the width AFTER the overflow
|
||||||
|
*/
|
||||||
|
if (!render)
|
||||||
|
x += tmpw;
|
||||||
|
else
|
||||||
|
utf8strlen = ellipsis_len;
|
||||||
|
} else if (curfont == usedfont) {
|
||||||
|
utf8strlen += utf8charlen;
|
||||||
|
text += utf8charlen;
|
||||||
|
ew += tmpw;
|
||||||
|
} else {
|
||||||
|
nextfont = curfont;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overflow || !charexists || nextfont)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
charexists = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utf8strlen) {
|
||||||
|
if (render) {
|
||||||
|
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||||
|
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||||
|
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
|
||||||
|
}
|
||||||
|
x += ew;
|
||||||
|
w -= ew;
|
||||||
|
}
|
||||||
|
if (render && overflow)
|
||||||
|
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||||
|
|
||||||
|
if (!*text || overflow) {
|
||||||
|
break;
|
||||||
|
} else if (nextfont) {
|
||||||
|
charexists = 0;
|
||||||
|
usedfont = nextfont;
|
||||||
|
} else {
|
||||||
|
/* Regardless of whether or not a fallback font is found, the
|
||||||
|
* character must be drawn. */
|
||||||
|
charexists = 1;
|
||||||
|
|
||||||
|
for (i = 0; i < nomatches_len; ++i) {
|
||||||
|
/* avoid calling XftFontMatch if we know we won't find a match */
|
||||||
|
if (utf8codepoint == nomatches.codepoint[i])
|
||||||
|
goto no_match;
|
||||||
|
}
|
||||||
|
|
||||||
|
fccharset = FcCharSetCreate();
|
||||||
|
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||||
|
|
||||||
|
if (!drw->fonts->pattern) {
|
||||||
|
/* Refer to the comment in xfont_create for more information. */
|
||||||
|
die("the first font in the cache must be loaded from a font string.");
|
||||||
|
}
|
||||||
|
|
||||||
|
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||||
|
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||||
|
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||||
|
|
||||||
|
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||||
|
FcDefaultSubstitute(fcpattern);
|
||||||
|
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
|
||||||
|
|
||||||
|
FcCharSetDestroy(fccharset);
|
||||||
|
FcPatternDestroy(fcpattern);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
usedfont = xfont_create(drw, NULL, match);
|
||||||
|
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
|
||||||
|
for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
|
||||||
|
; /* NOP */
|
||||||
|
curfont->next = usedfont;
|
||||||
|
} else {
|
||||||
|
xfont_free(usedfont);
|
||||||
|
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
||||||
|
no_match:
|
||||||
|
usedfont = drw->fonts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (d)
|
||||||
|
XftDrawDestroy(d);
|
||||||
|
|
||||||
|
return x + (render ? w : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||||
|
{
|
||||||
|
if (!drw)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||||
|
XSync(drw->dpy, False);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
drw_fontset_getwidth(Drw *drw, const char *text)
|
||||||
|
{
|
||||||
|
if (!drw || !drw->fonts || !text)
|
||||||
|
return 0;
|
||||||
|
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
|
||||||
|
{
|
||||||
|
unsigned int tmp = 0;
|
||||||
|
if (drw && drw->fonts && text && n)
|
||||||
|
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
|
||||||
|
return MIN(n, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||||
|
{
|
||||||
|
XGlyphInfo ext;
|
||||||
|
|
||||||
|
if (!font || !text)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||||
|
if (w)
|
||||||
|
*w = ext.xOff;
|
||||||
|
if (h)
|
||||||
|
*h = font->h;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cur *
|
||||||
|
drw_cur_create(Drw *drw, int shape)
|
||||||
|
{
|
||||||
|
Cur *cur;
|
||||||
|
|
||||||
|
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||||
|
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_cur_free(Drw *drw, Cur *cursor)
|
||||||
|
{
|
||||||
|
if (!cursor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XFreeCursor(drw->dpy, cursor->cursor);
|
||||||
|
free(cursor);
|
||||||
|
}
|
@ -0,0 +1,450 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
|
||||||
|
#include "drw.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
#define UTF_INVALID 0xFFFD
|
||||||
|
#define UTF_SIZ 4
|
||||||
|
|
||||||
|
static const unsigned char utfbyte[UTF_SIZ + 1] = {0x80, 0, 0xC0, 0xE0, 0xF0};
|
||||||
|
static const unsigned char utfmask[UTF_SIZ + 1] = {0xC0, 0x80, 0xE0, 0xF0, 0xF8};
|
||||||
|
static const long utfmin[UTF_SIZ + 1] = { 0, 0, 0x80, 0x800, 0x10000};
|
||||||
|
static const long utfmax[UTF_SIZ + 1] = {0x10FFFF, 0x7F, 0x7FF, 0xFFFF, 0x10FFFF};
|
||||||
|
|
||||||
|
static long
|
||||||
|
utf8decodebyte(const char c, size_t *i)
|
||||||
|
{
|
||||||
|
for (*i = 0; *i < (UTF_SIZ + 1); ++(*i))
|
||||||
|
if (((unsigned char)c & utfmask[*i]) == utfbyte[*i])
|
||||||
|
return (unsigned char)c & ~utfmask[*i];
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
utf8validate(long *u, size_t i)
|
||||||
|
{
|
||||||
|
if (!BETWEEN(*u, utfmin[i], utfmax[i]) || BETWEEN(*u, 0xD800, 0xDFFF))
|
||||||
|
*u = UTF_INVALID;
|
||||||
|
for (i = 1; *u > utfmax[i]; ++i)
|
||||||
|
;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
static size_t
|
||||||
|
utf8decode(const char *c, long *u, size_t clen)
|
||||||
|
{
|
||||||
|
size_t i, j, len, type;
|
||||||
|
long udecoded;
|
||||||
|
|
||||||
|
*u = UTF_INVALID;
|
||||||
|
if (!clen)
|
||||||
|
return 0;
|
||||||
|
udecoded = utf8decodebyte(c[0], &len);
|
||||||
|
if (!BETWEEN(len, 1, UTF_SIZ))
|
||||||
|
return 1;
|
||||||
|
for (i = 1, j = 1; i < clen && j < len; ++i, ++j) {
|
||||||
|
udecoded = (udecoded << 6) | utf8decodebyte(c[i], &type);
|
||||||
|
if (type)
|
||||||
|
return j;
|
||||||
|
}
|
||||||
|
if (j < len)
|
||||||
|
return 0;
|
||||||
|
*u = udecoded;
|
||||||
|
utf8validate(u, len);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
Drw *
|
||||||
|
drw_create(Display *dpy, int screen, Window root, unsigned int w, unsigned int h)
|
||||||
|
{
|
||||||
|
Drw *drw = ecalloc(1, sizeof(Drw));
|
||||||
|
|
||||||
|
drw->dpy = dpy;
|
||||||
|
drw->screen = screen;
|
||||||
|
drw->root = root;
|
||||||
|
drw->w = w;
|
||||||
|
drw->h = h;
|
||||||
|
drw->drawable = XCreatePixmap(dpy, root, w, h, DefaultDepth(dpy, screen));
|
||||||
|
drw->gc = XCreateGC(dpy, root, 0, NULL);
|
||||||
|
XSetLineAttributes(dpy, drw->gc, 1, LineSolid, CapButt, JoinMiter);
|
||||||
|
|
||||||
|
return drw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_resize(Drw *drw, unsigned int w, unsigned int h)
|
||||||
|
{
|
||||||
|
if (!drw)
|
||||||
|
return;
|
||||||
|
|
||||||
|
drw->w = w;
|
||||||
|
drw->h = h;
|
||||||
|
if (drw->drawable)
|
||||||
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
|
drw->drawable = XCreatePixmap(drw->dpy, drw->root, w, h, DefaultDepth(drw->dpy, drw->screen));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_free(Drw *drw)
|
||||||
|
{
|
||||||
|
XFreePixmap(drw->dpy, drw->drawable);
|
||||||
|
XFreeGC(drw->dpy, drw->gc);
|
||||||
|
drw_fontset_free(drw->fonts);
|
||||||
|
free(drw);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This function is an implementation detail. Library users should use
|
||||||
|
* drw_fontset_create instead.
|
||||||
|
*/
|
||||||
|
static Fnt *
|
||||||
|
xfont_create(Drw *drw, const char *fontname, FcPattern *fontpattern)
|
||||||
|
{
|
||||||
|
Fnt *font;
|
||||||
|
XftFont *xfont = NULL;
|
||||||
|
FcPattern *pattern = NULL;
|
||||||
|
|
||||||
|
if (fontname) {
|
||||||
|
/* Using the pattern found at font->xfont->pattern does not yield the
|
||||||
|
* same substitution results as using the pattern returned by
|
||||||
|
* FcNameParse; using the latter results in the desired fallback
|
||||||
|
* behaviour whereas the former just results in missing-character
|
||||||
|
* rectangles being drawn, at least with some fonts. */
|
||||||
|
if (!(xfont = XftFontOpenName(drw->dpy, drw->screen, fontname))) {
|
||||||
|
fprintf(stderr, "error, cannot load font from name: '%s'\n", fontname);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (!(pattern = FcNameParse((FcChar8 *) fontname))) {
|
||||||
|
fprintf(stderr, "error, cannot parse font name to pattern: '%s'\n", fontname);
|
||||||
|
XftFontClose(drw->dpy, xfont);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else if (fontpattern) {
|
||||||
|
if (!(xfont = XftFontOpenPattern(drw->dpy, fontpattern))) {
|
||||||
|
fprintf(stderr, "error, cannot load font from pattern.\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
die("no font specified.");
|
||||||
|
}
|
||||||
|
|
||||||
|
font = ecalloc(1, sizeof(Fnt));
|
||||||
|
font->xfont = xfont;
|
||||||
|
font->pattern = pattern;
|
||||||
|
font->h = xfont->ascent + xfont->descent;
|
||||||
|
font->dpy = drw->dpy;
|
||||||
|
|
||||||
|
return font;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xfont_free(Fnt *font)
|
||||||
|
{
|
||||||
|
if (!font)
|
||||||
|
return;
|
||||||
|
if (font->pattern)
|
||||||
|
FcPatternDestroy(font->pattern);
|
||||||
|
XftFontClose(font->dpy, font->xfont);
|
||||||
|
free(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
Fnt*
|
||||||
|
drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount)
|
||||||
|
{
|
||||||
|
Fnt *cur, *ret = NULL;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!drw || !fonts)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 1; i <= fontcount; i++) {
|
||||||
|
if ((cur = xfont_create(drw, fonts[fontcount - i], NULL))) {
|
||||||
|
cur->next = ret;
|
||||||
|
ret = cur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (drw->fonts = ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_fontset_free(Fnt *font)
|
||||||
|
{
|
||||||
|
if (font) {
|
||||||
|
drw_fontset_free(font->next);
|
||||||
|
xfont_free(font);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_clr_create(Drw *drw, Clr *dest, const char *clrname)
|
||||||
|
{
|
||||||
|
if (!drw || !dest || !clrname)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!XftColorAllocName(drw->dpy, DefaultVisual(drw->dpy, drw->screen),
|
||||||
|
DefaultColormap(drw->dpy, drw->screen),
|
||||||
|
clrname, dest))
|
||||||
|
die("error, cannot allocate color '%s'", clrname);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wrapper to create color schemes. The caller has to call free(3) on the
|
||||||
|
* returned color scheme when done using it. */
|
||||||
|
Clr *
|
||||||
|
drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount)
|
||||||
|
{
|
||||||
|
size_t i;
|
||||||
|
Clr *ret;
|
||||||
|
|
||||||
|
/* need at least two colors for a scheme */
|
||||||
|
if (!drw || !clrnames || clrcount < 2 || !(ret = ecalloc(clrcount, sizeof(XftColor))))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < clrcount; i++)
|
||||||
|
drw_clr_create(drw, &ret[i], clrnames[i]);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_setfontset(Drw *drw, Fnt *set)
|
||||||
|
{
|
||||||
|
if (drw)
|
||||||
|
drw->fonts = set;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_setscheme(Drw *drw, Clr *scm)
|
||||||
|
{
|
||||||
|
if (drw)
|
||||||
|
drw->scheme = scm;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert)
|
||||||
|
{
|
||||||
|
if (!drw || !drw->scheme)
|
||||||
|
return;
|
||||||
|
XSetForeground(drw->dpy, drw->gc, invert ? drw->scheme[ColBg].pixel : drw->scheme[ColFg].pixel);
|
||||||
|
if (filled)
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
else
|
||||||
|
XDrawRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w - 1, h - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert)
|
||||||
|
{
|
||||||
|
int i, ty, ellipsis_x = 0;
|
||||||
|
unsigned int tmpw, ew, ellipsis_w = 0, ellipsis_len;
|
||||||
|
XftDraw *d = NULL;
|
||||||
|
Fnt *usedfont, *curfont, *nextfont;
|
||||||
|
int utf8strlen, utf8charlen, render = x || y || w || h;
|
||||||
|
long utf8codepoint = 0;
|
||||||
|
const char *utf8str;
|
||||||
|
FcCharSet *fccharset;
|
||||||
|
FcPattern *fcpattern;
|
||||||
|
FcPattern *match;
|
||||||
|
XftResult result;
|
||||||
|
int charexists = 0, overflow = 0;
|
||||||
|
/* keep track of a couple codepoints for which we have no match. */
|
||||||
|
enum { nomatches_len = 64 };
|
||||||
|
static struct { long codepoint[nomatches_len]; unsigned int idx; } nomatches;
|
||||||
|
static unsigned int ellipsis_width = 0;
|
||||||
|
|
||||||
|
if (!drw || (render && (!drw->scheme || !w)) || !text || !drw->fonts)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!render) {
|
||||||
|
w = invert ? invert : ~invert;
|
||||||
|
} else {
|
||||||
|
XSetForeground(drw->dpy, drw->gc, drw->scheme[invert ? ColFg : ColBg].pixel);
|
||||||
|
XFillRectangle(drw->dpy, drw->drawable, drw->gc, x, y, w, h);
|
||||||
|
d = XftDrawCreate(drw->dpy, drw->drawable,
|
||||||
|
DefaultVisual(drw->dpy, drw->screen),
|
||||||
|
DefaultColormap(drw->dpy, drw->screen));
|
||||||
|
x += lpad;
|
||||||
|
w -= lpad;
|
||||||
|
}
|
||||||
|
|
||||||
|
usedfont = drw->fonts;
|
||||||
|
if (!ellipsis_width && render)
|
||||||
|
ellipsis_width = drw_fontset_getwidth(drw, "...");
|
||||||
|
while (1) {
|
||||||
|
ew = ellipsis_len = utf8strlen = 0;
|
||||||
|
utf8str = text;
|
||||||
|
nextfont = NULL;
|
||||||
|
while (*text) {
|
||||||
|
utf8charlen = utf8decode(text, &utf8codepoint, UTF_SIZ);
|
||||||
|
for (curfont = drw->fonts; curfont; curfont = curfont->next) {
|
||||||
|
charexists = charexists || XftCharExists(drw->dpy, curfont->xfont, utf8codepoint);
|
||||||
|
if (charexists) {
|
||||||
|
drw_font_getexts(curfont, text, utf8charlen, &tmpw, NULL);
|
||||||
|
if (ew + ellipsis_width <= w) {
|
||||||
|
/* keep track where the ellipsis still fits */
|
||||||
|
ellipsis_x = x + ew;
|
||||||
|
ellipsis_w = w - ew;
|
||||||
|
ellipsis_len = utf8strlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ew + tmpw > w) {
|
||||||
|
overflow = 1;
|
||||||
|
/* called from drw_fontset_getwidth_clamp():
|
||||||
|
* it wants the width AFTER the overflow
|
||||||
|
*/
|
||||||
|
if (!render)
|
||||||
|
x += tmpw;
|
||||||
|
else
|
||||||
|
utf8strlen = ellipsis_len;
|
||||||
|
} else if (curfont == usedfont) {
|
||||||
|
utf8strlen += utf8charlen;
|
||||||
|
text += utf8charlen;
|
||||||
|
ew += tmpw;
|
||||||
|
} else {
|
||||||
|
nextfont = curfont;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overflow || !charexists || nextfont)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
charexists = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (utf8strlen) {
|
||||||
|
if (render) {
|
||||||
|
ty = y + (h - usedfont->h) / 2 + usedfont->xfont->ascent;
|
||||||
|
XftDrawStringUtf8(d, &drw->scheme[invert ? ColBg : ColFg],
|
||||||
|
usedfont->xfont, x, ty, (XftChar8 *)utf8str, utf8strlen);
|
||||||
|
}
|
||||||
|
x += ew;
|
||||||
|
w -= ew;
|
||||||
|
}
|
||||||
|
if (render && overflow)
|
||||||
|
drw_text(drw, ellipsis_x, y, ellipsis_w, h, 0, "...", invert);
|
||||||
|
|
||||||
|
if (!*text || overflow) {
|
||||||
|
break;
|
||||||
|
} else if (nextfont) {
|
||||||
|
charexists = 0;
|
||||||
|
usedfont = nextfont;
|
||||||
|
} else {
|
||||||
|
/* Regardless of whether or not a fallback font is found, the
|
||||||
|
* character must be drawn. */
|
||||||
|
charexists = 1;
|
||||||
|
|
||||||
|
for (i = 0; i < nomatches_len; ++i) {
|
||||||
|
/* avoid calling XftFontMatch if we know we won't find a match */
|
||||||
|
if (utf8codepoint == nomatches.codepoint[i])
|
||||||
|
goto no_match;
|
||||||
|
}
|
||||||
|
|
||||||
|
fccharset = FcCharSetCreate();
|
||||||
|
FcCharSetAddChar(fccharset, utf8codepoint);
|
||||||
|
|
||||||
|
if (!drw->fonts->pattern) {
|
||||||
|
/* Refer to the comment in xfont_create for more information. */
|
||||||
|
die("the first font in the cache must be loaded from a font string.");
|
||||||
|
}
|
||||||
|
|
||||||
|
fcpattern = FcPatternDuplicate(drw->fonts->pattern);
|
||||||
|
FcPatternAddCharSet(fcpattern, FC_CHARSET, fccharset);
|
||||||
|
FcPatternAddBool(fcpattern, FC_SCALABLE, FcTrue);
|
||||||
|
|
||||||
|
FcConfigSubstitute(NULL, fcpattern, FcMatchPattern);
|
||||||
|
FcDefaultSubstitute(fcpattern);
|
||||||
|
match = XftFontMatch(drw->dpy, drw->screen, fcpattern, &result);
|
||||||
|
|
||||||
|
FcCharSetDestroy(fccharset);
|
||||||
|
FcPatternDestroy(fcpattern);
|
||||||
|
|
||||||
|
if (match) {
|
||||||
|
usedfont = xfont_create(drw, NULL, match);
|
||||||
|
if (usedfont && XftCharExists(drw->dpy, usedfont->xfont, utf8codepoint)) {
|
||||||
|
for (curfont = drw->fonts; curfont->next; curfont = curfont->next)
|
||||||
|
; /* NOP */
|
||||||
|
curfont->next = usedfont;
|
||||||
|
} else {
|
||||||
|
xfont_free(usedfont);
|
||||||
|
nomatches.codepoint[++nomatches.idx % nomatches_len] = utf8codepoint;
|
||||||
|
no_match:
|
||||||
|
usedfont = drw->fonts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (d)
|
||||||
|
XftDrawDestroy(d);
|
||||||
|
|
||||||
|
return x + (render ? w : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h)
|
||||||
|
{
|
||||||
|
if (!drw)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XCopyArea(drw->dpy, drw->drawable, win, drw->gc, x, y, w, h, x, y);
|
||||||
|
XSync(drw->dpy, False);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
drw_fontset_getwidth(Drw *drw, const char *text)
|
||||||
|
{
|
||||||
|
if (!drw || !drw->fonts || !text)
|
||||||
|
return 0;
|
||||||
|
return drw_text(drw, 0, 0, 0, 0, 0, text, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n)
|
||||||
|
{
|
||||||
|
unsigned int tmp = 0;
|
||||||
|
if (drw && drw->fonts && text && n)
|
||||||
|
tmp = drw_text(drw, 0, 0, 0, 0, 0, text, n);
|
||||||
|
return MIN(n, tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h)
|
||||||
|
{
|
||||||
|
XGlyphInfo ext;
|
||||||
|
|
||||||
|
if (!font || !text)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XftTextExtentsUtf8(font->dpy, font->xfont, (XftChar8 *)text, len, &ext);
|
||||||
|
if (w)
|
||||||
|
*w = ext.xOff;
|
||||||
|
if (h)
|
||||||
|
*h = font->h;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cur *
|
||||||
|
drw_cur_create(Drw *drw, int shape)
|
||||||
|
{
|
||||||
|
Cur *cur;
|
||||||
|
|
||||||
|
if (!drw || !(cur = ecalloc(1, sizeof(Cur))))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cur->cursor = XCreateFontCursor(drw->dpy, shape);
|
||||||
|
|
||||||
|
return cur;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drw_cur_free(Drw *drw, Cur *cursor)
|
||||||
|
{
|
||||||
|
if (!cursor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
XFreeCursor(drw->dpy, cursor->cursor);
|
||||||
|
free(cursor);
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Cursor cursor;
|
||||||
|
} Cur;
|
||||||
|
|
||||||
|
typedef struct Fnt {
|
||||||
|
Display *dpy;
|
||||||
|
unsigned int h;
|
||||||
|
XftFont *xfont;
|
||||||
|
FcPattern *pattern;
|
||||||
|
struct Fnt *next;
|
||||||
|
} Fnt;
|
||||||
|
|
||||||
|
enum { ColFg, ColBg }; /* Clr scheme index */
|
||||||
|
typedef XftColor Clr;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int w, h;
|
||||||
|
Display *dpy;
|
||||||
|
int screen;
|
||||||
|
Window root;
|
||||||
|
Visual *visual;
|
||||||
|
unsigned int depth;
|
||||||
|
Colormap cmap;
|
||||||
|
Drawable drawable;
|
||||||
|
GC gc;
|
||||||
|
Clr *scheme;
|
||||||
|
Fnt *fonts;
|
||||||
|
} Drw;
|
||||||
|
|
||||||
|
/* Drawable abstraction */
|
||||||
|
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h, Visual*, unsigned int, Colormap);
|
||||||
|
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||||
|
void drw_free(Drw *drw);
|
||||||
|
|
||||||
|
/* Fnt abstraction */
|
||||||
|
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||||
|
void drw_fontset_free(Fnt* set);
|
||||||
|
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||||
|
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
|
||||||
|
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||||
|
|
||||||
|
/* Colorscheme abstraction */
|
||||||
|
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname, unsigned int alpha);
|
||||||
|
Clr *drw_scm_create(Drw *drw, const char *clrnames[], const unsigned int alphas[], size_t clrcount);
|
||||||
|
|
||||||
|
/* Cursor abstraction */
|
||||||
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
|
void drw_cur_free(Drw *drw, Cur *cursor);
|
||||||
|
|
||||||
|
/* Drawing context manipulation */
|
||||||
|
void drw_setfontset(Drw *drw, Fnt *set);
|
||||||
|
void drw_setscheme(Drw *drw, Clr *scm);
|
||||||
|
|
||||||
|
/* Drawing functions */
|
||||||
|
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||||
|
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||||
|
|
||||||
|
/* Map functions */
|
||||||
|
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
@ -0,0 +1,58 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Cursor cursor;
|
||||||
|
} Cur;
|
||||||
|
|
||||||
|
typedef struct Fnt {
|
||||||
|
Display *dpy;
|
||||||
|
unsigned int h;
|
||||||
|
XftFont *xfont;
|
||||||
|
FcPattern *pattern;
|
||||||
|
struct Fnt *next;
|
||||||
|
} Fnt;
|
||||||
|
|
||||||
|
enum { ColFg, ColBg }; /* Clr scheme index */
|
||||||
|
typedef XftColor Clr;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
unsigned int w, h;
|
||||||
|
Display *dpy;
|
||||||
|
int screen;
|
||||||
|
Window root;
|
||||||
|
Drawable drawable;
|
||||||
|
GC gc;
|
||||||
|
Clr *scheme;
|
||||||
|
Fnt *fonts;
|
||||||
|
} Drw;
|
||||||
|
|
||||||
|
/* Drawable abstraction */
|
||||||
|
Drw *drw_create(Display *dpy, int screen, Window win, unsigned int w, unsigned int h);
|
||||||
|
void drw_resize(Drw *drw, unsigned int w, unsigned int h);
|
||||||
|
void drw_free(Drw *drw);
|
||||||
|
|
||||||
|
/* Fnt abstraction */
|
||||||
|
Fnt *drw_fontset_create(Drw* drw, const char *fonts[], size_t fontcount);
|
||||||
|
void drw_fontset_free(Fnt* set);
|
||||||
|
unsigned int drw_fontset_getwidth(Drw *drw, const char *text);
|
||||||
|
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);
|
||||||
|
void drw_font_getexts(Fnt *font, const char *text, unsigned int len, unsigned int *w, unsigned int *h);
|
||||||
|
|
||||||
|
/* Colorscheme abstraction */
|
||||||
|
void drw_clr_create(Drw *drw, Clr *dest, const char *clrname);
|
||||||
|
Clr *drw_scm_create(Drw *drw, const char *clrnames[], size_t clrcount);
|
||||||
|
|
||||||
|
/* Cursor abstraction */
|
||||||
|
Cur *drw_cur_create(Drw *drw, int shape);
|
||||||
|
void drw_cur_free(Drw *drw, Cur *cursor);
|
||||||
|
|
||||||
|
/* Drawing context manipulation */
|
||||||
|
void drw_setfontset(Drw *drw, Fnt *set);
|
||||||
|
void drw_setscheme(Drw *drw, Clr *scm);
|
||||||
|
|
||||||
|
/* Drawing functions */
|
||||||
|
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);
|
||||||
|
int drw_text(Drw *drw, int x, int y, unsigned int w, unsigned int h, unsigned int lpad, const char *text, int invert);
|
||||||
|
|
||||||
|
/* Map functions */
|
||||||
|
void drw_map(Drw *drw, Window win, int x, int y, unsigned int w, unsigned int h);
|
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
patch -p1 < dmenu-border-4.9.diff
|
||||||
|
patch -p1 < dmenu-center-5.2.diff
|
||||||
|
patch -p1 < dmenu-highlight-4.9.diff
|
||||||
|
patch -p1 < dmenu-lineheight-5.2.diff
|
||||||
|
sudo make install
|
||||||
|
|
||||||
|
|
@ -0,0 +1,90 @@
|
|||||||
|
.TH STEST 1 dmenu\-VERSION
|
||||||
|
.SH NAME
|
||||||
|
stest \- filter a list of files by properties
|
||||||
|
.SH SYNOPSIS
|
||||||
|
.B stest
|
||||||
|
.RB [ -abcdefghlpqrsuwx ]
|
||||||
|
.RB [ -n
|
||||||
|
.IR file ]
|
||||||
|
.RB [ -o
|
||||||
|
.IR file ]
|
||||||
|
.RI [ file ...]
|
||||||
|
.SH DESCRIPTION
|
||||||
|
.B stest
|
||||||
|
takes a list of files and filters by the files' properties, analogous to
|
||||||
|
.IR test (1).
|
||||||
|
Files which pass all tests are printed to stdout. If no files are given, stest
|
||||||
|
reads files from stdin.
|
||||||
|
.SH OPTIONS
|
||||||
|
.TP
|
||||||
|
.B \-a
|
||||||
|
Test hidden files.
|
||||||
|
.TP
|
||||||
|
.B \-b
|
||||||
|
Test that files are block specials.
|
||||||
|
.TP
|
||||||
|
.B \-c
|
||||||
|
Test that files are character specials.
|
||||||
|
.TP
|
||||||
|
.B \-d
|
||||||
|
Test that files are directories.
|
||||||
|
.TP
|
||||||
|
.B \-e
|
||||||
|
Test that files exist.
|
||||||
|
.TP
|
||||||
|
.B \-f
|
||||||
|
Test that files are regular files.
|
||||||
|
.TP
|
||||||
|
.B \-g
|
||||||
|
Test that files have their set-group-ID flag set.
|
||||||
|
.TP
|
||||||
|
.B \-h
|
||||||
|
Test that files are symbolic links.
|
||||||
|
.TP
|
||||||
|
.B \-l
|
||||||
|
Test the contents of a directory given as an argument.
|
||||||
|
.TP
|
||||||
|
.BI \-n " file"
|
||||||
|
Test that files are newer than
|
||||||
|
.IR file .
|
||||||
|
.TP
|
||||||
|
.BI \-o " file"
|
||||||
|
Test that files are older than
|
||||||
|
.IR file .
|
||||||
|
.TP
|
||||||
|
.B \-p
|
||||||
|
Test that files are named pipes.
|
||||||
|
.TP
|
||||||
|
.B \-q
|
||||||
|
No files are printed, only the exit status is returned.
|
||||||
|
.TP
|
||||||
|
.B \-r
|
||||||
|
Test that files are readable.
|
||||||
|
.TP
|
||||||
|
.B \-s
|
||||||
|
Test that files are not empty.
|
||||||
|
.TP
|
||||||
|
.B \-u
|
||||||
|
Test that files have their set-user-ID flag set.
|
||||||
|
.TP
|
||||||
|
.B \-v
|
||||||
|
Invert the sense of tests, only failing files pass.
|
||||||
|
.TP
|
||||||
|
.B \-w
|
||||||
|
Test that files are writable.
|
||||||
|
.TP
|
||||||
|
.B \-x
|
||||||
|
Test that files are executable.
|
||||||
|
.SH EXIT STATUS
|
||||||
|
.TP
|
||||||
|
.B 0
|
||||||
|
At least one file passed all tests.
|
||||||
|
.TP
|
||||||
|
.B 1
|
||||||
|
No files passed all tests.
|
||||||
|
.TP
|
||||||
|
.B 2
|
||||||
|
An error occurred.
|
||||||
|
.SH SEE ALSO
|
||||||
|
.IR dmenu (1),
|
||||||
|
.IR test (1)
|
@ -0,0 +1,109 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "arg.h"
|
||||||
|
char *argv0;
|
||||||
|
|
||||||
|
#define FLAG(x) (flag[(x)-'a'])
|
||||||
|
|
||||||
|
static void test(const char *, const char *);
|
||||||
|
static void usage(void);
|
||||||
|
|
||||||
|
static int match = 0;
|
||||||
|
static int flag[26];
|
||||||
|
static struct stat old, new;
|
||||||
|
|
||||||
|
static void
|
||||||
|
test(const char *path, const char *name)
|
||||||
|
{
|
||||||
|
struct stat st, ln;
|
||||||
|
|
||||||
|
if ((!stat(path, &st) && (FLAG('a') || name[0] != '.') /* hidden files */
|
||||||
|
&& (!FLAG('b') || S_ISBLK(st.st_mode)) /* block special */
|
||||||
|
&& (!FLAG('c') || S_ISCHR(st.st_mode)) /* character special */
|
||||||
|
&& (!FLAG('d') || S_ISDIR(st.st_mode)) /* directory */
|
||||||
|
&& (!FLAG('e') || access(path, F_OK) == 0) /* exists */
|
||||||
|
&& (!FLAG('f') || S_ISREG(st.st_mode)) /* regular file */
|
||||||
|
&& (!FLAG('g') || st.st_mode & S_ISGID) /* set-group-id flag */
|
||||||
|
&& (!FLAG('h') || (!lstat(path, &ln) && S_ISLNK(ln.st_mode))) /* symbolic link */
|
||||||
|
&& (!FLAG('n') || st.st_mtime > new.st_mtime) /* newer than file */
|
||||||
|
&& (!FLAG('o') || st.st_mtime < old.st_mtime) /* older than file */
|
||||||
|
&& (!FLAG('p') || S_ISFIFO(st.st_mode)) /* named pipe */
|
||||||
|
&& (!FLAG('r') || access(path, R_OK) == 0) /* readable */
|
||||||
|
&& (!FLAG('s') || st.st_size > 0) /* not empty */
|
||||||
|
&& (!FLAG('u') || st.st_mode & S_ISUID) /* set-user-id flag */
|
||||||
|
&& (!FLAG('w') || access(path, W_OK) == 0) /* writable */
|
||||||
|
&& (!FLAG('x') || access(path, X_OK) == 0)) != FLAG('v')) { /* executable */
|
||||||
|
if (FLAG('q'))
|
||||||
|
exit(0);
|
||||||
|
match = 1;
|
||||||
|
puts(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "usage: %s [-abcdefghlpqrsuvwx] "
|
||||||
|
"[-n file] [-o file] [file...]\n", argv0);
|
||||||
|
exit(2); /* like test(1) return > 1 on error */
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct dirent *d;
|
||||||
|
char path[PATH_MAX], *line = NULL, *file;
|
||||||
|
size_t linesiz = 0;
|
||||||
|
ssize_t n;
|
||||||
|
DIR *dir;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
ARGBEGIN {
|
||||||
|
case 'n': /* newer than file */
|
||||||
|
case 'o': /* older than file */
|
||||||
|
file = EARGF(usage());
|
||||||
|
if (!(FLAG(ARGC()) = !stat(file, (ARGC() == 'n' ? &new : &old))))
|
||||||
|
perror(file);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* miscellaneous operators */
|
||||||
|
if (strchr("abcdefghlpqrsuvwx", ARGC()))
|
||||||
|
FLAG(ARGC()) = 1;
|
||||||
|
else
|
||||||
|
usage(); /* unknown flag */
|
||||||
|
} ARGEND;
|
||||||
|
|
||||||
|
if (!argc) {
|
||||||
|
/* read list from stdin */
|
||||||
|
while ((n = getline(&line, &linesiz, stdin)) > 0) {
|
||||||
|
if (line[n - 1] == '\n')
|
||||||
|
line[n - 1] = '\0';
|
||||||
|
test(line, line);
|
||||||
|
}
|
||||||
|
free(line);
|
||||||
|
} else {
|
||||||
|
for (; argc; argc--, argv++) {
|
||||||
|
if (FLAG('l') && (dir = opendir(*argv))) {
|
||||||
|
/* test directory contents */
|
||||||
|
while ((d = readdir(dir))) {
|
||||||
|
r = snprintf(path, sizeof path, "%s/%s",
|
||||||
|
*argv, d->d_name);
|
||||||
|
if (r >= 0 && (size_t)r < sizeof path)
|
||||||
|
test(path, d->d_name);
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
} else {
|
||||||
|
test(*argv, *argv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return match ? 0 : 1;
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
die(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
|
||||||
|
fputc(' ', stderr);
|
||||||
|
perror(NULL);
|
||||||
|
} else {
|
||||||
|
fputc('\n', stderr);
|
||||||
|
}
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void *
|
||||||
|
ecalloc(size_t nmemb, size_t size)
|
||||||
|
{
|
||||||
|
void *p;
|
||||||
|
|
||||||
|
if (!(p = calloc(nmemb, size)))
|
||||||
|
die("calloc:");
|
||||||
|
return p;
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
|
||||||
|
#define MAX(A, B) ((A) > (B) ? (A) : (B))
|
||||||
|
#define MIN(A, B) ((A) < (B) ? (A) : (B))
|
||||||
|
#define BETWEEN(X, A, B) ((A) <= (X) && (X) <= (B))
|
||||||
|
|
||||||
|
void die(const char *fmt, ...);
|
||||||
|
void *ecalloc(size_t nmemb, size_t size);
|
@ -0,0 +1,165 @@
|
|||||||
|
Fonticons, Inc. (https://fontawesome.com)
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Font Awesome Free License
|
||||||
|
|
||||||
|
Font Awesome Free is free, open source, and GPL friendly. You can use it for
|
||||||
|
commercial projects, open source projects, or really almost whatever you want.
|
||||||
|
Full Font Awesome Free license: https://fontawesome.com/license/free.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Icons: CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/)
|
||||||
|
|
||||||
|
The Font Awesome Free download is licensed under a Creative Commons
|
||||||
|
Attribution 4.0 International License and applies to all icons packaged
|
||||||
|
as SVG and JS file types.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Fonts: SIL OFL 1.1 License
|
||||||
|
|
||||||
|
In the Font Awesome Free download, the SIL OFL license applies to all icons
|
||||||
|
packaged as web and desktop font files.
|
||||||
|
|
||||||
|
Copyright (c) 2022 Fonticons, Inc. (https://fontawesome.com)
|
||||||
|
with Reserved Font Name: "Font Awesome".
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
SIL OPEN FONT LICENSE
|
||||||
|
Version 1.1 - 26 February 2007
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting — in part or in whole — any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Code: MIT License (https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
In the Font Awesome Free download, the MIT license applies to all non-font and
|
||||||
|
non-icon files.
|
||||||
|
|
||||||
|
Copyright 2022 Fonticons, Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in the
|
||||||
|
Software without restriction, including without limitation the rights to use, copy,
|
||||||
|
modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
and to permit persons to whom the Software is furnished to do so, subject to the
|
||||||
|
following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Attribution
|
||||||
|
|
||||||
|
Attribution is required by MIT, SIL OFL, and CC BY licenses. Downloaded Font
|
||||||
|
Awesome Free files already contain embedded comments with sufficient
|
||||||
|
attribution, so you shouldn't need to do anything additional when using these
|
||||||
|
files normally.
|
||||||
|
|
||||||
|
We've kept attribution comments terse, so we ask that you do not actively work
|
||||||
|
to remove them from files, especially code. They're a great way for folks to
|
||||||
|
learn about Font Awesome.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
# Brand Icons
|
||||||
|
|
||||||
|
All brand icons are trademarks of their respective owners. The use of these
|
||||||
|
trademarks does not indicate endorsement of the trademark holder by Font
|
||||||
|
Awesome, nor vice versa. **Please do not use brand logos for any purpose except
|
||||||
|
to represent the company, product, or service to which they refer.**
|
@ -0,0 +1,377 @@
|
|||||||
|
area-chart:
|
||||||
|
name: chart-area
|
||||||
|
arrow-circle-o-down:
|
||||||
|
name: circle-down
|
||||||
|
prefix: far
|
||||||
|
arrow-circle-o-left:
|
||||||
|
name: circle-left
|
||||||
|
prefix: far
|
||||||
|
arrow-circle-o-right:
|
||||||
|
name: circle-right
|
||||||
|
prefix: far
|
||||||
|
arrow-circle-o-up:
|
||||||
|
name: circle-up
|
||||||
|
prefix: far
|
||||||
|
arrows:
|
||||||
|
name: up-down-left-right
|
||||||
|
arrows-alt:
|
||||||
|
name: maximize
|
||||||
|
arrows-h:
|
||||||
|
name: left-right
|
||||||
|
arrows-v:
|
||||||
|
name: up-down
|
||||||
|
bar-chart:
|
||||||
|
name: chart-column
|
||||||
|
behance-square:
|
||||||
|
name: square-behance
|
||||||
|
prefix: fab
|
||||||
|
bitbucket-square:
|
||||||
|
name: bitbucket
|
||||||
|
prefix: fab
|
||||||
|
calendar:
|
||||||
|
name: calendar-days
|
||||||
|
calendar-o:
|
||||||
|
name: calendar
|
||||||
|
prefix: far
|
||||||
|
caret-square-o-down:
|
||||||
|
name: square-caret-down
|
||||||
|
prefix: far
|
||||||
|
caret-square-o-left:
|
||||||
|
name: square-caret-left
|
||||||
|
prefix: far
|
||||||
|
caret-square-o-right:
|
||||||
|
name: square-caret-right
|
||||||
|
prefix: far
|
||||||
|
caret-square-o-up:
|
||||||
|
name: square-caret-up
|
||||||
|
prefix: far
|
||||||
|
cc:
|
||||||
|
name: closed-captioning
|
||||||
|
prefix: far
|
||||||
|
chain-broken:
|
||||||
|
name: link-slash
|
||||||
|
circle-o-notch:
|
||||||
|
name: circle-notch
|
||||||
|
circle-thin:
|
||||||
|
name: circle
|
||||||
|
prefix: far
|
||||||
|
clipboard:
|
||||||
|
name: paste
|
||||||
|
clone:
|
||||||
|
prefix: far
|
||||||
|
cloud-download:
|
||||||
|
name: cloud-arrow-down
|
||||||
|
cloud-upload:
|
||||||
|
name: cloud-arrow-up
|
||||||
|
code-fork:
|
||||||
|
name: code-branch
|
||||||
|
comment-alt:
|
||||||
|
name: comment-dots
|
||||||
|
prefix: far
|
||||||
|
commenting:
|
||||||
|
name: comment-dots
|
||||||
|
compass:
|
||||||
|
prefix: far
|
||||||
|
compress:
|
||||||
|
name: down-left-and-up-right-to-center
|
||||||
|
copyright:
|
||||||
|
prefix: far
|
||||||
|
creative-commons:
|
||||||
|
prefix: fab
|
||||||
|
credit-card:
|
||||||
|
prefix: far
|
||||||
|
credit-card-alt:
|
||||||
|
name: credit-card
|
||||||
|
cutlery:
|
||||||
|
name: utensils
|
||||||
|
diamond:
|
||||||
|
name: gem
|
||||||
|
prefix: far
|
||||||
|
eercast:
|
||||||
|
name: sellcast
|
||||||
|
prefix: fab
|
||||||
|
eur:
|
||||||
|
name: euro-sign
|
||||||
|
exchange:
|
||||||
|
name: right-left
|
||||||
|
expand:
|
||||||
|
name: up-right-and-down-left-from-center
|
||||||
|
external-link:
|
||||||
|
name: up-right-from-square
|
||||||
|
external-link-square:
|
||||||
|
name: square-up-right
|
||||||
|
eye:
|
||||||
|
prefix: far
|
||||||
|
eye-dropper:
|
||||||
|
name: eye-dropper
|
||||||
|
prefix: far
|
||||||
|
eye-slash:
|
||||||
|
prefix: far
|
||||||
|
eyedropper:
|
||||||
|
name: eye-dropper
|
||||||
|
facebook:
|
||||||
|
name: facebook-f
|
||||||
|
prefix: fab
|
||||||
|
facebook-official:
|
||||||
|
name: facebook
|
||||||
|
prefix: fab
|
||||||
|
facebook-square:
|
||||||
|
name: square-facebook
|
||||||
|
prefix: fab
|
||||||
|
file-text:
|
||||||
|
name: file-lines
|
||||||
|
files-o:
|
||||||
|
name: copy
|
||||||
|
prefix: far
|
||||||
|
floppy-o:
|
||||||
|
name: floppy-disk
|
||||||
|
prefix: far
|
||||||
|
gbp:
|
||||||
|
name: sterling-sign
|
||||||
|
git-square:
|
||||||
|
name: square-git
|
||||||
|
prefix: fab
|
||||||
|
github-square:
|
||||||
|
name: square-github
|
||||||
|
prefix: fab
|
||||||
|
gitlab-square:
|
||||||
|
name: square-gitlab
|
||||||
|
prefix: fab
|
||||||
|
glass:
|
||||||
|
name: martini-glass-empty
|
||||||
|
globe:
|
||||||
|
name: earth-americas
|
||||||
|
google-plus:
|
||||||
|
name: google-plus-g
|
||||||
|
prefix: fab
|
||||||
|
google-plus-circle:
|
||||||
|
name: google-plus
|
||||||
|
prefix: fab
|
||||||
|
google-plus-official:
|
||||||
|
name: google-plus
|
||||||
|
prefix: fab
|
||||||
|
google-plus-square:
|
||||||
|
name: square-google-plus
|
||||||
|
prefix: fab
|
||||||
|
hacker-news-square:
|
||||||
|
name: square-hacker-news
|
||||||
|
prefix: fab
|
||||||
|
hand-o-down:
|
||||||
|
name: hand-point-down
|
||||||
|
prefix: far
|
||||||
|
hand-o-left:
|
||||||
|
name: hand-point-left
|
||||||
|
prefix: far
|
||||||
|
hand-o-right:
|
||||||
|
name: hand-point-right
|
||||||
|
prefix: far
|
||||||
|
hand-o-up:
|
||||||
|
name: hand-point-up
|
||||||
|
prefix: far
|
||||||
|
header:
|
||||||
|
name: heading
|
||||||
|
home:
|
||||||
|
name: house
|
||||||
|
hourglass-o:
|
||||||
|
name: hourglass
|
||||||
|
id-badge:
|
||||||
|
prefix: far
|
||||||
|
ils:
|
||||||
|
name: shekel-sign
|
||||||
|
inr:
|
||||||
|
name: indian-rupee-sign
|
||||||
|
instagram-square:
|
||||||
|
name: square-instagram
|
||||||
|
prefix: fab
|
||||||
|
jpy:
|
||||||
|
name: yen-sign
|
||||||
|
js-square:
|
||||||
|
name: square-js
|
||||||
|
prefix: fab
|
||||||
|
krw:
|
||||||
|
name: won-sign
|
||||||
|
lastfm-square:
|
||||||
|
name: square-lastfm
|
||||||
|
prefix: fab
|
||||||
|
level-down:
|
||||||
|
name: turn-down
|
||||||
|
level-up:
|
||||||
|
name: turn-up
|
||||||
|
line-chart:
|
||||||
|
name: chart-line
|
||||||
|
linkedin:
|
||||||
|
name: linkedin-in
|
||||||
|
prefix: fab
|
||||||
|
linkedin-square:
|
||||||
|
name: linkedin
|
||||||
|
prefix: fab
|
||||||
|
list-alt:
|
||||||
|
name: rectangle-list
|
||||||
|
prefix: far
|
||||||
|
long-arrow-down:
|
||||||
|
name: down-long
|
||||||
|
long-arrow-left:
|
||||||
|
name: left-long
|
||||||
|
long-arrow-right:
|
||||||
|
name: right-long
|
||||||
|
long-arrow-up:
|
||||||
|
name: up-long
|
||||||
|
magic:
|
||||||
|
name: wand-magic-sparkles
|
||||||
|
map-marker:
|
||||||
|
name: location-dot
|
||||||
|
meanpath:
|
||||||
|
name: font-awesome
|
||||||
|
prefix: fab
|
||||||
|
mobile:
|
||||||
|
name: mobile-screen-button
|
||||||
|
money:
|
||||||
|
name: money-bill-1
|
||||||
|
object-group:
|
||||||
|
prefix: far
|
||||||
|
object-ungroup:
|
||||||
|
prefix: far
|
||||||
|
odnoklassniki-square:
|
||||||
|
name: square-odnoklassniki
|
||||||
|
prefix: fab
|
||||||
|
paste:
|
||||||
|
prefix: far
|
||||||
|
pencil-square:
|
||||||
|
name: square-pen
|
||||||
|
pencil-square-o:
|
||||||
|
name: pen-to-square
|
||||||
|
prefix: far
|
||||||
|
picture:
|
||||||
|
name: image
|
||||||
|
pie-chart:
|
||||||
|
name: chart-pie
|
||||||
|
pied-piper-square:
|
||||||
|
name: square-pied-piper
|
||||||
|
prefix: fab
|
||||||
|
pinterest-square:
|
||||||
|
name: square-pinterest
|
||||||
|
prefix: fab
|
||||||
|
reddit-square:
|
||||||
|
name: square-reddit
|
||||||
|
prefix: fab
|
||||||
|
refresh:
|
||||||
|
name: arrows-rotate
|
||||||
|
registered:
|
||||||
|
prefix: far
|
||||||
|
repeat:
|
||||||
|
name: arrow-rotate-right
|
||||||
|
rub:
|
||||||
|
name: ruble-sign
|
||||||
|
share-square-o:
|
||||||
|
name: share-from-square
|
||||||
|
sign-in:
|
||||||
|
name: right-to-bracket
|
||||||
|
sign-out:
|
||||||
|
name: right-from-bracket
|
||||||
|
snapchat-ghost:
|
||||||
|
name: snapchat
|
||||||
|
prefix: fab
|
||||||
|
snapchat-square:
|
||||||
|
name: square-snapchat
|
||||||
|
prefix: fab
|
||||||
|
sort-alpha-asc:
|
||||||
|
name: arrow-down-a-z
|
||||||
|
sort-alpha-desc:
|
||||||
|
name: arrow-down-z-a
|
||||||
|
sort-amount-asc:
|
||||||
|
name: arrow-down-short-wide
|
||||||
|
sort-amount-desc:
|
||||||
|
name: arrow-down-wide-short
|
||||||
|
sort-asc:
|
||||||
|
name: sort-up
|
||||||
|
sort-desc:
|
||||||
|
name: sort-down
|
||||||
|
sort-numeric-asc:
|
||||||
|
name: arrow-down-1-9
|
||||||
|
sort-numeric-desc:
|
||||||
|
name: arrow-down-9-1
|
||||||
|
star-half-empty:
|
||||||
|
name: star-half
|
||||||
|
star-half-full:
|
||||||
|
name: star-half
|
||||||
|
star-half-o:
|
||||||
|
name: star-half-stroke
|
||||||
|
prefix: far
|
||||||
|
steam-square:
|
||||||
|
name: square-steam
|
||||||
|
prefix: fab
|
||||||
|
support:
|
||||||
|
name: life-ring
|
||||||
|
prefix: far
|
||||||
|
tablet:
|
||||||
|
name: tablet-screen-button
|
||||||
|
tachometer:
|
||||||
|
name: gauge-high
|
||||||
|
tasks:
|
||||||
|
name: bars-progress
|
||||||
|
television:
|
||||||
|
name: tv
|
||||||
|
thumb-tack:
|
||||||
|
name: thumbtack
|
||||||
|
thumbs-o-down:
|
||||||
|
name: thumbs-down
|
||||||
|
prefix: far
|
||||||
|
thumbs-o-up:
|
||||||
|
name: thumbs-up
|
||||||
|
prefix: far
|
||||||
|
transgender:
|
||||||
|
name: mars-and-venus
|
||||||
|
transgender-alt:
|
||||||
|
name: transgender
|
||||||
|
trash:
|
||||||
|
name: trash-can
|
||||||
|
trash-o:
|
||||||
|
name: trash-can
|
||||||
|
prefix: far
|
||||||
|
try:
|
||||||
|
name: turkish-lira-sign
|
||||||
|
tumblr-square:
|
||||||
|
name: square-tumblr
|
||||||
|
prefix: fab
|
||||||
|
twitter-square:
|
||||||
|
name: square-twitter
|
||||||
|
prefix: fab
|
||||||
|
unlock-alt:
|
||||||
|
name: unlock
|
||||||
|
usd:
|
||||||
|
name: dollar-sign
|
||||||
|
user-circle-o:
|
||||||
|
name: circle-user
|
||||||
|
prefix: far
|
||||||
|
viadeo-square:
|
||||||
|
name: square-viadeo
|
||||||
|
prefix: fab
|
||||||
|
video-camera:
|
||||||
|
name: video
|
||||||
|
vimeo:
|
||||||
|
name: vimeo-v
|
||||||
|
prefix: fab
|
||||||
|
vimeo-square:
|
||||||
|
name: square-vimeo
|
||||||
|
prefix: fab
|
||||||
|
volume-control-phone:
|
||||||
|
name: phone-volume
|
||||||
|
whatsapp-square:
|
||||||
|
name: square-whatsapp
|
||||||
|
prefix: fab
|
||||||
|
wheelchair-alt:
|
||||||
|
name: accessible-icon
|
||||||
|
prefix: fab
|
||||||
|
window-maximize:
|
||||||
|
prefix: far
|
||||||
|
window-restore:
|
||||||
|
prefix: far
|
||||||
|
xing-square:
|
||||||
|
name: square-xing
|
||||||
|
prefix: fab
|
||||||
|
youtube-play:
|
||||||
|
name: youtube
|
||||||
|
prefix: fab
|
||||||
|
youtube-square:
|
||||||
|
name: square-youtube
|
||||||
|
prefix: fab
|
After Width: | Height: | Size: 953 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 986 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 478 B |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 615 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 956 B |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 931 B |
After Width: | Height: | Size: 816 B |
After Width: | Height: | Size: 592 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.1 KiB |
After Width: | Height: | Size: 450 B |
After Width: | Height: | Size: 937 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 726 B |
After Width: | Height: | Size: 484 B |
After Width: | Height: | Size: 975 B |
After Width: | Height: | Size: 577 B |
After Width: | Height: | Size: 785 B |
After Width: | Height: | Size: 490 B |
After Width: | Height: | Size: 782 B |
After Width: | Height: | Size: 2.3 KiB |
After Width: | Height: | Size: 2.5 KiB |
After Width: | Height: | Size: 391 B |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 895 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 696 B |
After Width: | Height: | Size: 517 B |
After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 970 B |
After Width: | Height: | Size: 388 B |
After Width: | Height: | Size: 887 B |
After Width: | Height: | Size: 1.1 KiB |