Compare commits

..

5 Commits

19 changed files with 178 additions and 1317 deletions

View File

@ -1,129 +0,0 @@
! ------------------------------------------------------------------------------
! Colour Configuration
! ------------------------------------------------------------------------------
! special
*.foreground: #d8dee8
*.background: #2f343f
*.cursorColor: #b48ead
! black
*.color0 : #4b5262
*.color8 : #434a5a
! red
*.color1 : #bf616a
*.color9 : #b3555e
! green
*.color2 : #a3be8c
*.color10 : #93ae7c
! yellow
*.color3 : #ebcb8b
*.color11 : #dbbb7b
! blue
*.color4 : #81a1c1
*.color12 : #7191b1
! magenta
*.color5 : #b48ead
*.color13 : #a6809f
! cyan
*.color6 : #89d0bA
*.color14 : #7dbba8
! white
*.color7 : #e5e9f0
*.color15 : #d1d5dc
! ------------------------------------------------------------------------------
! Font configuration
! ------------------------------------------------------------------------------
URxvt*font: xft:M+ 1mn:regular:size=8
URxvt*boldFont: xft:M+ 1mn:bold:size=8
URxvt*italicFont: xft:M+ 1mn:italic:size=8
URxvt*boldItalicFont: xft:M+ 1mn:bold italic:size=8
! ------------------------------------------------------------------------------
! Xft Font Configuration
! ------------------------------------------------------------------------------
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintslight
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb
! ------------------------------------------------------------------------------
! URxvt configs
! ------------------------------------------------------------------------------
! font spacing
URxvt*letterSpace: 0
URxvt.lineSpace: 0
! general settings
URxvt*saveline: 15000
URxvt*termName: rxvt-256color
URxvt*iso14755: false
URxvt*urgentOnBell: true
! appearance
URxvt*depth: 24
URxvt*scrollBar: false
URxvt*scrollBar_right: false
URxvt*internalBorder: 24
URxvt*externalBorder: 0
URxvt.geometry: 84x22
! perl extensions
URxvt.perl-ext-common: default,clipboard,url-select,keyboard-select
! macros for clipboard and selection
URxvt.copyCommand: xclip -i -selection clipboard
URxvt.pasteCommand: xclip -o -selection clipboard
URxvt.keysym.M-c: perl:clipboard:copy
URxvt.keysym.M-v: perl:clipboard:paste
URxvt.keysym.M-C-v: perl:clipboard:paste_escaped
URxvt.keysym.M-Escape: perl:keyboard-select:activate
URxvt.keysym.M-s: perl:keyboard-select:search
URxvt.keysym.M-u: perl:url-select:select_next
URxvt.urlLauncher: firefox
URxvt.underlineURLs: true
URxvt.urlButton: 1
! scroll one line
URxvt.keysym.Shift-Up: command:\033]720;1\007
URxvt.keysym.Shift-Down: command:\033]721;1\007
! control arrow
URxvt.keysym.Control-Up: \033[1;5A
URxvt.keysym.Control-Down: \033[1;5B
URxvt.keysym.Control-Right: \033[1;5C
URxvt.keysym.Control-Left: \033[1;5D
! ------------------------------------------------------------------------------
! Rofi configs
! ------------------------------------------------------------------------------
rofi.color-enabled: true
rofi.color-window: #2e3440, #2e3440, #2e3440
rofi.color-normal: #2e3440, #d8dee9, #2e3440, #2e3440, #bf616a
rofi.color-active: #2e3440, #b48ead, #2e3440, #2e3440, #93e5cc
rofi.color-urgent: #2e3440, #ebcb8b, #2e3440, #2e3440, #ebcb8b
rofi.modi: run,drun,window
! ------------------------------------------------------------------------------
! Dmenu configs
! ------------------------------------------------------------------------------
dmenu.selforeground: #d8dee9
dmenu.background: #2e3440
dmenu.selbackground: #bf616a
dmenu.foreground: #d8dee9

View File

@ -1,3 +1,4 @@
############################ GENERAL for all platform #############################
# set modifier # set modifier
set $super Mod4 set $super Mod4
set $alt Mod1 set $alt Mod1
@ -8,12 +9,11 @@ font pango: Noto Sans 8
# Use Mouse+$super to drag floating windows to their wanted position # Use Mouse+$super to drag floating windows to their wanted position
floating_modifier $super floating_modifier $super
#autostart # Autostart (GENERAL)
exec_always --no-startup-id hsetroot -cover ~/Pictures/wallpaper/wallhaven-gjev1e.jpg
exec --no-startup-id xsettingsd & exec --no-startup-id xsettingsd &
exec --no-startup-id compton -b exec --no-startup-id compton -b
exec --no-startup-id ibus-daemon & exec --no-startup-id ibus-daemon &
exec --no-startup-id synology-drive exec --no-startup-id ~/.SynologyDrive/SynologyDrive.app/bin/cloud-drive-ui
# start a terminal # start a terminal
bindsym $super+Return exec i3-sensible-terminal bindsym $super+Return exec i3-sensible-terminal
@ -24,42 +24,9 @@ bindsym $super+d exec rofi -lines 12 -padding 18 -width 60 -location 0 -show dru
# common apps keybinds # common apps keybinds
bindsym Print exec scrot 'Cheese_%a-%d%b%y_%H.%M.png' -e 'viewnior ~/$f' bindsym Print exec scrot 'Cheese_%a-%d%b%y_%H.%M.png' -e 'viewnior ~/$f'
bindsym $super+l exec i3lock -i ~/.wallpaper.png bindsym $super+l exec i3lock -i ~/Pictures/wallpaper/Download-free-Wonder-Woman-Wallpaper-HD-1.jpg
bindsym $super+Shift+w exec firefox bindsym $super+Shift+w exec firefox
bindsym $super+Shift+f exec thunar;workspace 3;focus bindsym $super+Shift+f exec thunar;workspace $workspace;focus
#bindsym $super+Shift+g exec geany
#change volume
# bindsym XF86AudioRaiseVolume exec amixer -q set Master
# bindsym XF86AudioLowerVolume exec amixer -q set Master 5%-
# bindsym XF86AudioMute exec amixer set Master toggle
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 1 +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume 1 -5%
bindsym XF86AudioMute exec pactl set-sink-mute 1 toggle
# music control
#bindsym XF86AudioNext exec mpc next
#bindsym XF86AudioPrev exec mpc prev
#bindsym XF86AudioPlay exec mpc toggle
#bindsym XF86AudioStop exec mpc stop
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
bindsym XF86AudioPlay exec playerctl play-pause
mode "media" {
bindsym Up exec pactl set-sink-volume 1 +5%
bindsym Down exec pactl set-sink-volume 1 -5%
bindsym Right exec playerctl next
bindsym Left exec playerctl previous
bindsym space exec playerctl play-pause
bindsym Return mode "default"
}
bindsym $super+m mode "media"
# brightness control
bindsym XF86MonBrightnessUp exec xbacklight -inc 10
bindsym XF86MonBrightnessDown exec xbacklight -dec 10
# kill focused window # kill focused window
bindsym $super+c kill bindsym $super+c kill
@ -101,35 +68,63 @@ bindsym $alt+Control+Left workspace prev
set $workspace1 "1: Terminal" set $workspace1 "1: Terminal"
set $workspace2 "2: Firefox" set $workspace2 "2: Firefox"
set $workspace3 "3: " set $workspace3 "3: File"
set $workspace4 "4: " set $workspace4 "4: Time"
set $workspace5 "5: " set $workspace5 "5: Editor"
set $workspace6 "6: " set $workspace6 "6: Chat"
set $workspace7 "7: " set $workspace7 "7: Anything"
set $workspace8 "8: Editor" set $workspace8 "8: Anything"
set $workspace9 "9: Music" set $workspace9 "9: Music"
bindsym $super+1 workspace $workspace1 bindsym $super+1 workspace $workspace1
bindsym $super+2 workspace $workspace2 bindsym $super+2 workspace $workspace2
bindsym $super+3 workspace $workspace3 bindsym $super+3 workspace $workspace3
bindsym $super+4 workspace $workspace4 bindsym $super+4 workspace $workspace4
bindsym $super+5 workspace 5 bindsym $super+5 workspace $workspace5
bindsym $super+6 workspace 6 bindsym $super+6 workspace $workspace6
bindsym $super+7 workspace 7 bindsym $super+7 workspace $workspace7
bindsym $super+8 workspace 8 bindsym $super+8 workspace $workspace8
bindsym $super+9 workspace $workspace9 bindsym $super+9 workspace $workspace9
# move focused container to workspace # Move Focused Container To Workspace
bindsym $super+Shift+1 move container to workspace $workspace1 bindsym $super+Shift+1 move container to workspace $workspace1
bindsym $super+Shift+2 move container to workspace $workspace2 bindsym $super+Shift+2 move container to workspace $workspace2
bindsym $super+Shift+3 move container to workspace $workspace3 bindsym $super+Shift+3 move container to workspace $workspace3
bindsym $super+Shift+4 move container to workspace $workspace4 bindsym $super+Shift+4 move container to workspace $workspace4
bindsym $super+Shift+5 move container to workspace 5 bindsym $super+Shift+5 move container to workspace $workspace5
bindsym $super+Shift+6 move container to workspace 6 bindsym $super+Shift+6 move container to workspace $workspace6
bindsym $super+Shift+7 move container to workspace 7 bindsym $super+Shift+7 move container to workspace $workspace7
bindsym $super+Shift+8 move container to workspace 8 bindsym $super+Shift+8 move container to workspace $workspace8
bindsym $super+Shift+9 move container to workspace $workspace9 bindsym $super+Shift+9 move container to workspace $workspace9
# Volume Tunning with media key on keyboard (Check media.md in repo for installing/using programs)
bindsym XF86AudioRaiseVolume exec pactl set-sink-volume 1 +5%
bindsym XF86AudioLowerVolume exec pactl set-sink-volume 1 -5%
bindsym XF86AudioMute exec pactl set-sink-mute 1 toggle
# Music Control with media key on keyboard (Check media.md in repo for installing/using programs)
bindsym XF86AudioNext exec playerctl next
bindsym XF86AudioPrev exec playerctl previous
bindsym XF86AudioPlay exec playerctl play-pause
# Media control using separate mode (for 60% keyboard)
bindsym $super+m mode "media"
mode "media" {
bindsym Up exec pactl set-sink-volume 1 +5%
bindsym Down exec pactl set-sink-volume 1 -5%
bindsym 9 exec pactl set-sink-volume 1 90%
bindsym 8 exec pactl set-sink-volume 1 80%
bindsym 7 exec pactl set-sink-volume 1 70%
bindsym 6 exec pactl set-sink-volume 1 60%
bindsym 5 exec pactl set-sink-volume 1 50%
bindsym 4 exec pactl set-sink-volume 1 40%
bindsym Right exec playerctl next
bindsym Left exec playerctl previous
bindsym space exec playerctl play-pause
bindsym Return mode "default"
}
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) # restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $super+Shift+r restart bindsym $super+Shift+r restart
@ -167,9 +162,9 @@ for_window [class=".*"] border pixel 4
assign [class=URxvt] $workspace1 assign [class=URxvt] $workspace1
assign [class=Firefox|Transmission-gtk] $workspace2 assign [class=Firefox|Transmission-gtk] $workspace2
assign [class=Thunar|File-roller] $workspace3 assign [class=Thunar|File-roller] $workspace3
assign [class=Code|Geany|Evince|Gucharmap|Soffice|libreoffice*] $workspace4 assign [class=Audacity|Vlc|mpv|Ghb|Xfburn|Gimp*|Inkscape] $workspace4
assign [class=Audacity|Vlc|mpv|Ghb|Xfburn|Gimp*|Inkscape] 5 assign [class=Code*|Geany|Evince|Gucharmap|Soffice|libreoffice*] $workspace5
assign [class=Lxappearance|System-config-printer.py|Lxtask|GParted|Pavucontrol|Exo-helper*|Lxrandr|Arandr] 6 assign [class=Lxappearance|System-config-printer.py|Lxtask|GParted|Pavucontrol|Exo-helper*|Lxrandr|Arandr] $workspace6
assign [class=Spotify] $workspace9 assign [class=Spotify] $workspace9
for_window [class=Viewnior|feh|Audacious|File-roller|Lxappearance|Lxtask|Pavucontrol] floating enable for_window [class=Viewnior|feh|Audacious|File-roller|Lxappearance|Lxtask|Pavucontrol] floating enable
for_window [class=URxvt|Firefox|Geany|Evince|Soffice|libreoffice*|mpv|Ghb|Xfburn|Gimp*|Inkscape|Vlc|Lxappearance|Audacity] focus for_window [class=URxvt|Firefox|Geany|Evince|Soffice|libreoffice*|mpv|Ghb|Xfburn|Gimp*|Inkscape|Vlc|Lxappearance|Audacity] focus
@ -182,3 +177,27 @@ client.unfocused #2f343f #2f343f #d8dee8 #2f343f #2f343f
client.urgent #2f343f #2f343f #d8dee8 #2f343f #2f343f client.urgent #2f343f #2f343f #d8dee8 #2f343f #2f343f
client.placeholder #2f343f #2f343f #d8dee8 #2f343f #2f343f client.placeholder #2f343f #2f343f #d8dee8 #2f343f #2f343f
client.background #2f343f client.background #2f343f
########################### Specific for different platform ###########################
# Wallpaper
exec_always --no-startup-id hsetroot -cover ~/Pictures/wallpaper/wallhaven-r2ze21.jpg
# Monitor setup
# exec_always --no-startup-id bash ~/.screenlayout/TOP_DELL_U3415W+BOTTOM_DELL_S2719DGF.sh
exec_always --no-startup-id bash ~/.screenlayout/LEFT_DELL_S2719DGF+RIGHT_DELL_U3415W.sh
# brightness control (Only available on Laptop)
bindsym XF86MonBrightnessUp exec xbacklight -inc 10
bindsym XF86MonBrightnessDown exec xbacklight -dec 10
# Assign workspace on specific monitor
workspace $workspace1 output DP-2
workspace $workspace2 output DP-2
workspace $workspace3 output DP-2
workspace $workspace4 output DP-2
workspace $workspace5 output DP-0
workspace $workspace6 output DP-0
workspace $workspace7 output DP-0
workspace $workspace8 output DP-0
workspace $workspace9 output DP-0

View File

@ -10,10 +10,12 @@ general {
order += "load" order += "load"
order += "cpu_temperature 0" order += "cpu_temperature 0"
order += "cpu_temperature 1"
order += "fan_speed 1"
order += "disk /" order += "disk /"
order += "disk /home" order += "disk /home"
# order += "ethernet eno1" # order += "ethernet eno1"
order += "wireless wlo1" order += "wireless wlp6s0"
order += "volume master" order += "volume master"
order += "tztime local" order += "tztime local"
@ -23,9 +25,14 @@ load {
cpu_temperature 0 { cpu_temperature 0 {
format = "<span background='#bf616a'>  %degrees °C </span>" format = "<span background='#bf616a'>  %degrees °C </span>"
path = "/sys/class/thermal/thermal_zone0/temp" path = "/sys/class/hwmon/hwmon1/temp1_input" # used by lm_sensors
} }
# TODO: complete fan_speed widget
# cpu_temperature 1 {
# path = "sys/class/hwmon/hwmon2/fan1_input"
#}
disk "/" { disk "/" {
format = "<span background='#fec7cd'>  %free Free </span>" format = "<span background='#fec7cd'>  %free Free </span>"
} }
@ -39,7 +46,7 @@ ethernet eno1 {
format_down = "<span background='#88c0d0'>  Disconnected </span>" format_down = "<span background='#88c0d0'>  Disconnected </span>"
} }
wireless wlo1 { wireless wlp6s0 {
format_up = "<span background='#b48ead'>  %essid </span>" format_up = "<span background='#b48ead'>  %essid </span>"
format_down = "<span background='#b48ead'>  Disconnected </span>" format_down = "<span background='#b48ead'>  Disconnected </span>"
} }

4
.gitmodules vendored 100644
View File

@ -0,0 +1,4 @@
[submodule "dotbot"]
path = dotbot
url = https://github.com/anishathalye/dotbot
ignore = dirty

View File

@ -0,0 +1,2 @@
#!/bin/sh
xrandr --output DVI-D-0 --off --output HDMI-1 --off --output HDMI-0 --off --output DP-3 --off --output DP-2 --mode 2560x1440 --pos 0x0 --rotate normal --output DP-1 --off --output DP-0 --off

View File

@ -0,0 +1,2 @@
#!/bin/sh
xrandr --output DVI-D-0 --off --output HDMI-1 --off --output HDMI-0 --off --output DP-3 --off --output DP-2 --mode 2560x1440 --pos 0x0 --rotate normal --output DP-1 --off --output DP-0 --mode 3440x1440 --pos 2560x0 --rotate normal

View File

@ -0,0 +1,2 @@
#!/bin/sh
xrandr --output DVI-D-0 --off --output HDMI-1 --off --output HDMI-0 --off --output DP-3 --off --output DP-2 --mode 2560x1440 --pos 304x1440 --rotate normal --output DP-1 --off --output DP-0 --mode 3440x1440 --pos 0x0 --rotate normal

View File

@ -1,115 +0,0 @@
#! perl -w
# Author: Bert Muennich
# Website: http://www.github.com/muennich/urxvt-perls
# License: GPLv2
# Use keyboard shortcuts to copy the selection to the clipboard and to paste
# the clipboard contents (optionally escaping all special characters).
# Requires xsel to be installed!
# Usage: put the following lines in your .Xdefaults/.Xresources:
# URxvt.perl-ext-common: ...,clipboard
# URxvt.keysym.M-c: perl:clipboard:copy
# URxvt.keysym.M-v: perl:clipboard:paste
# URxvt.keysym.M-C-v: perl:clipboard:paste_escaped
# Options:
# URxvt.clipboard.autocopy: If true, PRIMARY overwrites clipboard
# You can also overwrite the system commands to use for copying/pasting.
# The default ones are:
# URxvt.clipboard.copycmd: xsel -ib
# URxvt.clipboard.pastecmd: xsel -ob
# If you prefer xclip, then put these lines in your .Xdefaults/.Xresources:
# URxvt.clipboard.copycmd: xclip -i -selection clipboard
# URxvt.clipboard.pastecmd: xclip -o -selection clipboard
# On Mac OS X, put these lines in your .Xdefaults/.Xresources:
# URxvt.clipboard.copycmd: pbcopy
# URxvt.clipboard.pastecmd: pbpaste
# The use of the functions should be self-explanatory!
use strict;
sub on_start {
my ($self) = @_;
$self->{copy_cmd} = $self->x_resource('clipboard.copycmd') || 'xsel -ib';
$self->{paste_cmd} = $self->x_resource('clipboard.pastecmd') || 'xsel -ob';
if ($self->x_resource('clipboard.autocopy') eq 'true') {
$self->enable(sel_grab => \&sel_grab);
}
()
}
sub copy {
my ($self) = @_;
if (open(CLIPBOARD, "| $self->{copy_cmd}")) {
my $sel = $self->selection();
utf8::encode($sel);
print CLIPBOARD $sel;
close(CLIPBOARD);
} else {
print STDERR "error running '$self->{copy_cmd}': $!\n";
}
()
}
sub paste {
my ($self) = @_;
my $str = `$self->{paste_cmd}`;
if ($? == 0) {
$self->tt_paste($str);
} else {
print STDERR "error running '$self->{paste_cmd}': $!\n";
}
()
}
sub paste_escaped {
my ($self) = @_;
my $str = `$self->{paste_cmd}`;
if ($? == 0) {
$str =~ s/([!#\$%&\*\(\) ='"\\\|\[\]`~,<>\?])/\\\1/g;
$self->tt_paste($str);
} else {
print STDERR "error running '$self->{paste_cmd}': $!\n";
}
()
}
sub on_action {
my ($self, $action) = @_;
on_user_command($self, "clipboard:" . $action);
}
sub on_user_command {
my ($self, $cmd) = @_;
if ($cmd eq "clipboard:copy") {
$self->copy;
} elsif ($cmd eq "clipboard:paste") {
$self->paste;
} elsif ($cmd eq "clipboard:paste_escaped") {
$self->paste_escaped;
}
()
}
sub sel_grab {
my ($self) = @_;
$self->copy;
()
}

View File

@ -1,597 +0,0 @@
#! perl -w
# Author: Bert Muennich
# Website: http://www.github.com/muennich/urxvt-perls
# License: GPLv2
# Use keyboard shortcuts to select and copy text.
# Usage: put the following lines in your .Xdefaults/.Xresources:
# URxvt.perl-ext-common: ...,keyboard-select
# URxvt.keysym.M-Escape: perl:keyboard-select:activate
# The following line overwrites the default Meta-s binding and allows to
# activate keyboard-select directly in backward search mode:
# URxvt.keysym.M-s: perl:keyboard-select:search
# Use Meta-Escape to activate selection mode, then use the following keys:
# h/j/k/l: Move cursor left/down/up/right (also with arrow keys)
# g/G/0/^/$/H/M/L/f/F/;/,/w/W/b/B/e/E: More vi-like cursor movement keys
# '/'/?: Start forward/backward search
# n/N: Repeat last search, N: in reverse direction
# Ctrl-f/b: Scroll down/up one screen
# Ctrl-d/u: Scroll down/up half a screen
# v/V/Ctrl-v: Toggle normal/linewise/blockwise selection
# y/Return: Copy selection to primary buffer, Return: quit afterwards
# Y: Copy selected lines to primary buffer or cursor line and quit
# q/Escape: Quit keyboard selection mode
use strict;
sub on_start{
my ($self) = @_;
$self->{patterns}{'w'} = qr/\w[^\w\s]|\W\w|\s\S/;
$self->{patterns}{'W'} = qr/\s\S/;
$self->{patterns}{'b'} = qr/.*(?:\w[^\w\s]|\W\w|\s\S)/;
$self->{patterns}{'B'} = qr/.*\s\S/;
$self->{patterns}{'e'} = qr/[^\w\s](?=\w)|\w(?=\W)|\S(?=\s|$)/;
$self->{patterns}{'E'} = qr/\S(?=\s|$)/;
()
}
sub on_action {
my ($self, $action) = @_;
on_user_command($self, "keyboard-select:" . $action);
}
sub on_user_command {
my ($self, $cmd) = @_;
if (not $self->{active}) {
if ($cmd eq 'keyboard-select:activate') {
activate($self);
} elsif ($cmd eq 'keyboard-select:search') {
activate($self, 1);
}
}
()
}
sub key_press {
my ($self, $event, $keysym, $char) = @_;
my $key = chr($keysym);
if (lc($key) eq 'c' && $event->{state} & urxvt::ControlMask) {
deactivate($self);
} elsif ($self->{search}) {
if ($keysym == 0xff1b) {
if ($self->{search_mode}) {
deactivate($self);
} else {
$self->{search} = '';
status_area($self);
}
} elsif ($keysym == 0xff08) {
$self->{search} = substr($self->{search}, 0, -1);
if (not $self->{search} and $self->{search_mode}) {
deactivate($self);
} else {
status_area($self);
}
} elsif ($keysym == 0xff0d ||
(lc($key) eq 'm' && $event->{state} & urxvt::ControlMask)) {
my $txt = substr($self->{search}, 1);
if ($txt) {
$self->{pattern} = ($txt =~ m/[[:upper:]]/) ? qr/\Q$txt\E/ :
qr/\Q$txt\E/i;
} elsif ($self->{pattern}) {
delete $self->{pattern};
}
$self->{search} = '';
$self->screen_cur($self->{srhcr}, $self->{srhcc});
if (not find_next($self)) {
if ($self->{search_mode}) {
deactivate($self);
} else {
status_area($self);
}
}
} elsif (length($char) > 0) {
$self->{search} .= $self->locale_decode($char);
my $txt = substr($self->{search}, 1);
if ($txt) {
$self->{pattern} = ($txt =~ m/[[:upper:]]/) ? qr/\Q$txt\E/ :
qr/\Q$txt\E/i;
} elsif ($self->{pattern}) {
delete $self->{pattern};
}
$self->screen_cur($self->{srhcr}, $self->{srhcc});
find_next($self);
status_area($self);
}
} elsif ($self->{move_to}) {
if ($keysym == 0xff1b) {
$self->{move_to} = 0;
status_area($self);
} elsif (length($char) > 0) {
$self->{move_to} = 0;
$self->{patterns}{'f-1'} = qr/^.*\Q$key\E/;
$self->{patterns}{'f+1'} = qr/^.+?\Q$key\E/;
move_to($self, ';');
status_area($self);
}
} elsif ($keysym == 0xff1b || lc($key) eq 'q') {
deactivate($self);
} elsif (lc($key) eq 'y' || $keysym == 0xff0d ||
(lc($key) eq 'm' && $event->{state} & urxvt::ControlMask)) {
my $quit = 0;
if ($key eq 'Y' && $self->{select} ne 'l') {
$quit = !$self->{select};
toggle_select($self, 'l');
}
if ($self->{select}) {
my ($br, $bc, $er, $ec) = calc_span($self);
$ec = $self->line($er)->l if $self->{select} eq 'l';
$self->selection_beg($br, $bc);
$self->selection_end($er, $ec);
$self->selection_make($event->{time}, $self->{select} eq 'b');
if (lc($key) eq 'y') {
$self->selection_beg(1, 0);
$self->selection_end(1, 0);
$self->{select} = '';
status_area($self);
$self->want_refresh();
} else {
$quit = 1;
}
}
if ($quit) {
deactivate($self);
}
} elsif ($key eq 'V') {
toggle_select($self, 'l');
} elsif ($key eq 'v') {
if ($event->{state} & urxvt::ControlMask) {
toggle_select($self, 'b');
} else {
toggle_select($self, 'n');
}
} elsif ($key eq 'k' || $keysym == 0xff52) {
move_cursor($self, 'k');
} elsif ($key eq 'j' || $keysym == 0xff54) {
move_cursor($self, 'j');
} elsif ($key eq 'h' || $keysym == 0xff51) {
move_cursor($self, 'h');
} elsif ($key eq 'l' || $keysym == 0xff53) {
move_cursor($self, 'l');
} elsif ($keysym == 0xff57) {
move_cursor($self, '$');
} elsif ($keysym == 0xff50) {
move_cursor($self, '^');
} elsif ('gG0^$HML' =~ m/\Q$key\E/ ||
('fbdu' =~ m/\Q$key\E/ && $event->{state} & urxvt::ControlMask)) {
move_cursor($self, $key);
} elsif (lc($key) eq 'f') {
$self->{move_to} = 1;
$self->{move_dir} = $key eq 'F' ? -1 : 1;
status_area($self, $key);
} elsif (';,wWbBeE' =~ m/\Q$key\E/) {
move_to($self, $key);
} elsif ($key eq '/' || $key eq '?') {
$self->{search} = $key;
$self->{search_dir} = $key eq '?' ? -1 : 1;
($self->{srhcr}, $self->{srhcc}) = $self->screen_cur();
status_area($self);
} elsif (lc($key) eq 'n') {
find_next($self, $self->{search_dir} * ($key eq 'N' ? -1 : 1));
}
return 1;
}
sub move_cursor {
my ($self, $key) = @_;
my ($cr, $cc) = $self->screen_cur();
my $line = $self->line($cr);
if ($key eq 'k' && $line->beg > $self->top_row) {
$cr = $line->beg - 1;
} elsif ($key eq 'j' && $line->end < $self->nrow - 1) {
$cr = $line->end + 1;
} elsif ($key eq 'h' && $self->{offset} > 0) {
$self->{offset} = $line->offset_of($cr, $cc) - 1;
$self->{dollar} = 0;
} elsif ($key eq 'l' && $self->{offset} < $line->l - 1) {
++$self->{offset};
} elsif ($key eq 'f' || $key eq 'd') {
my $vs = $self->view_start() +
($key eq 'd' ? $self->nrow / 2 : $self->nrow - 1);
$vs = 0 if $vs > 0;
$cr += $vs - $self->view_start($vs);
} elsif ($key eq 'b' || $key eq 'u') {
my $vs = $self->view_start() -
($key eq 'u' ? $self->nrow / 2 : $self->nrow - 1);
$vs = $self->top_row if $vs < $self->top_row;
$cr += $vs - $self->view_start($vs);
} elsif ($key eq 'g') {
($cr, $self->{offset}) = ($self->top_row, 0);
$self->{dollar} = 0;
} elsif ($key eq 'G') {
($cr, $self->{offset}) = ($self->nrow - 1, 0);
$self->{dollar} = 0;
} elsif ($key eq '0') {
$self->{offset} = 0;
$self->{dollar} = 0;
} elsif ($key eq '^') {
my $ltxt = $self->special_decode($line->t);
while ($ltxt =~ s/^( *)\t/$1 . " " x (8 - length($1) % 8)/e) {}
$self->{offset} = $ltxt =~ m/^ +/ ? $+[0] : 0;
$self->{dollar} = 0;
} elsif ($key eq '$') {
my $co = $line->offset_of($cr, $cc);
$self->{dollar} = $co + 1;
$self->{offset} = $line->l - 1;
} elsif ($key eq 'H') {
$cr = $self->view_start();
} elsif ($key eq 'M') {
$cr = $self->view_start() + $self->nrow / 2;
} elsif ($key eq 'L') {
$cr = $self->view_start() + $self->nrow - 1;
}
$line = $self->line($cr);
$cc = $self->{dollar} || $self->{offset} >= $line->l ? $line->l - 1 :
$self->{offset};
$self->screen_cur($line->coord_of($cc));
status_area($self);
$self->want_refresh();
()
}
sub move_to {
my ($self, $key) = @_;
my ($cr, $cc) = $self->screen_cur();
my $line = $self->line($cr);
my $offset = $self->{offset};
my ($dir, $pattern);
my ($wrap, $found) = (0, 0);
if ($key eq ';' || $key eq ',') {
$dir = $self->{move_dir} * ($key eq ',' ? -1 : 1);
$pattern = $self->{patterns}{sprintf('f%+d', $dir)};
return if not $pattern;
} else {
if (lc($key) eq 'b') {
$dir = -1;
} else {
$dir = 1;
++$offset if lc($key) eq 'e';
}
$pattern = $self->{patterns}{$key};
$wrap = 1;
}
if ($dir > 0) {
NEXTDOWN: my $text = substr($line->t, $offset);
if ($text =~ m/$pattern/) {
$offset += $+[0] - 1;
$found = 1;
} elsif ($wrap && $line->end + 1 < $self->nrow) {
$cr = $line->end + 1;
$line = $self->line($cr);
$offset = 0;
if (lc($key) eq 'e') {
goto NEXTDOWN;
} else {
$found = 1;
}
}
} elsif ($dir < 0) {
NEXTUP: my $text = substr($line->t, 0, $offset);
if ($text =~ m/$pattern/) {
$offset += $+[0] - length($text) - 1;
$found = 1;
} elsif ($wrap) {
if ($offset > 0) {
$offset = 0;
$found = 1;
} elsif ($line->beg > $self->top_row) {
$cr = $line->beg - 1;
$line = $self->line($cr);
$offset = $line->l;
goto NEXTUP;
}
}
}
if ($found) {
$self->{dollar} = 0;
$self->{offset} = $offset;
$self->screen_cur($line->coord_of($offset));
$self->want_refresh();
}
()
}
sub find_next {
my ($self, $dir) = @_;
return if not $self->{pattern};
$dir = $self->{search_dir} if not $dir;
my ($cr, $cc) = $self->screen_cur();
my $line = $self->line($cr);
my $offset = $line->offset_of($cr, $cc);
my $text;
my $found = 0;
++$offset if $dir > 0;
while (not $found) {
if ($dir > 0) {
$text = substr($line->t, $offset);
if ($text =~ m/$self->{pattern}/) {
$found = 1;
$offset += $-[0];
} else {
last if $line->end >= $self->nrow;
$line = $self->line($line->end + 1);
$offset = 0;
}
} else {
$text = substr($line->t, 0, $offset);
if ($text =~ m/$self->{pattern}/) {
$found = 1;
$offset = $-[0] while $text =~ m/$self->{pattern}/g;
} else {
last if $line->beg <= $self->top_row;
$line = $self->line($line->beg - 1);
$offset = $line->l;
}
}
}
if ($found) {
$self->{dollar} = 0;
$self->{offset} = $offset;
$self->screen_cur($line->coord_of($offset));
status_area($self);
$self->want_refresh();
}
return $found;
}
sub tt_write {
return 1;
}
sub refresh {
my ($self) = @_;
my ($cr, $cc) = $self->screen_cur();
# scroll the current cursor position into visible area
if ($cr < $self->view_start()) {
$self->view_start($cr);
} elsif ($cr >= $self->view_start() + $self->nrow) {
$self->view_start($cr - $self->nrow + 1);
}
if ($self->{select}) {
my ($hl, $reverse_cursor);
my ($br, $bc, $er, $ec) = calc_span($self);
if ($self->x_resource('highlightColor')) {
$hl = urxvt::RS_Sel;
$reverse_cursor = 0;
} else {
$hl = urxvt::RS_RVid;
$reverse_cursor = $self->{select} ne 'l';
}
if ($self->{select} eq 'b') {
my $co = $self->line($cr)->offset_of($cr, $cc);
my $dollar = $self->{dollar} && $co >= $self->{dollar} - 1;
my $r = $br;
while ($r <= $er) {
my $line = $self->line($r);
if ($bc < $line->l) {
$ec = $line->l if $dollar;
my ($br, $bc) = $line->coord_of($bc);
my ($er, $ec) = $line->coord_of($ec <= $line->l ? $ec : $line->l);
$self->scr_xor_span($br, $bc, $er, $ec, $hl);
} elsif ($r == $cr) {
$reverse_cursor = 0;
}
$r = $line->end + 1;
}
} else {
$self->scr_xor_span($br, $bc, $er, $ec, $hl);
}
if ($reverse_cursor) {
# make the cursor visible again
$self->scr_xor_span($cr, $cc, $cr, $cc + 1, $hl);
}
}
()
}
sub activate {
my ($self, $search) = @_;
$self->{active} = 1;
$self->{select} = '';
$self->{dollar} = 0;
$self->{move_to} = 0;
if ($search) {
$self->{search} = '?';
$self->{search_dir} = -1;
$self->{search_mode} = 1;
} else {
$self->{search} = '';
$self->{search_mode} = 0;
}
($self->{oldcr}, $self->{oldcc}) = $self->screen_cur();
($self->{srhcr}, $self->{srhcc}) = $self->screen_cur();
$self->{old_view_start} = $self->view_start();
$self->{old_pty_ev_events} = $self->pty_ev_events(urxvt::EV_NONE);
my $line = $self->line($self->{oldcr});
$self->{offset} = $line->offset_of($self->{oldcr}, $self->{oldcc});
$self->selection_beg(1, 0);
$self->selection_end(1, 0);
$self->enable(
key_press => \&key_press,
refresh_begin => \&refresh,
refresh_end => \&refresh,
tt_write => \&tt_write,
);
if ($self->{offset} >= $line->l) {
$self->{offset} = $line->l > 0 ? $line->l - 1 : 0;
$self->screen_cur($line->coord_of($self->{offset}));
$self->want_refresh();
}
$self->{overlay_len} = 0;
status_area($self);
()
}
sub deactivate {
my ($self) = @_;
$self->selection_beg(1, 0);
$self->selection_end(1, 0);
delete $self->{overlay} if $self->{overlay};
$self->disable("key_press", "refresh_begin", "refresh_end", "tt_write");
$self->screen_cur($self->{oldcr}, $self->{oldcc});
$self->view_start($self->{old_view_start});
$self->pty_ev_events($self->{old_pty_ev_events});
$self->want_refresh();
$self->{active} = 0;
()
}
sub status_area {
my ($self, $extra) = @_;
my ($stat, $stat_len);
if ($self->{search}) {
$stat_len = $self->ncol;
$stat = $self->{search} . ' ' x ($stat_len - length($self->{search}));
} else {
if ($self->{select}) {
$stat = "-V" . ($self->{select} ne 'n' ? uc($self->{select}) : "") . "- ";
}
if ($self->top_row == 0) {
$stat .= "All";
} elsif ($self->view_start() == $self->top_row) {
$stat .= "Top";
} elsif ($self->view_start() == 0) {
$stat .= "Bot";
} else {
$stat .= sprintf("%2d%%",
($self->top_row - $self->view_start) * 100 / $self->top_row);
}
$stat = "$extra $stat" if $extra;
$stat_len = length($stat);
}
if (!$self->{overlay} || $self->{overlay_len} != $stat_len) {
delete $self->{overlay} if $self->{overlay};
$self->{overlay} = $self->overlay(-1, -1, $stat_len, 1,
urxvt::OVERLAY_RSTYLE, 0);
$self->{overlay_len} = $stat_len;
}
$self->{overlay}->set(0, 0, $self->special_encode($stat));
$self->{overlay}->show();
()
}
sub toggle_select {
my ($self, $mode) = @_;
if ($self->{select} eq $mode) {
$self->{select} = '';
} else {
if (not $self->{select}) {
($self->{ar}, $self->{ac}) = $self->screen_cur();
}
$self->{select} = $mode;
}
status_area($self);
$self->want_refresh();
()
}
sub calc_span {
my ($self) = @_;
my ($cr, $cc) = $self->screen_cur();
my ($br, $bc, $er, $ec);
if ($self->{select} eq 'b') {
$br = $self->line($cr)->beg;
$bc = $self->line($cr)->offset_of($cr, $cc);
$er = $self->line($self->{ar})->beg;
$ec = $self->line($self->{ar})->offset_of($self->{ar}, $self->{ac});
($br, $er) = ($er, $br) if $br > $er;
($bc, $ec) = ($ec, $bc) if $bc > $ec;
} else {
if ($cr < $self->{ar}) {
($br, $bc, $er, $ec) = ($cr, $cc, $self->{ar}, $self->{ac});
} elsif ($cr > $self->{ar}) {
($br, $bc, $er, $ec) = ($self->{ar}, $self->{ac}, $cr, $cc);
} else {
($br, $er) = ($cr, $cr);
($bc, $ec) = $cc < $self->{ac} ? ($cc, $self->{ac}) : ($self->{ac}, $cc);
}
}
if ($self->{select} eq 'l') {
($br, $er) = ($self->line($br)->beg, $self->line($er)->end);
($bc, $ec) = (0, $self->ncol);
} else {
++$ec;
}
return ($br, $bc, $er, $ec);
}

View File

@ -1,408 +0,0 @@
#! perl -w
# Author: Bert Muennich
# Website: http://www.github.com/muennich/urxvt-perls
# Based on: http://www.jukie.net/~bart/blog/urxvt-url-yank
# License: GPLv2
# Use keyboard shortcuts to select URLs.
# This should be used as a replacement for the default matcher extension,
# it also makes URLs clickable with the middle mouse button.
# Usage: put the following lines in your .Xdefaults/.Xresources:
# URxvt.perl-ext-common: ...,url-select
# URxvt.keysym.M-u: perl:url-select:select_next
# Use Meta-u to activate URL selection mode, then use the following keys:
# j/k: Select next downward/upward URL (also with arrow keys)
# g/G: Select first/last URL (also with home/end key)
# o/Return: Open selected URL in browser, Return: deactivate afterwards
# y: Copy (yank) selected URL and deactivate selection mode
# q/Escape: Deactivate URL selection mode
# Options:
# URxvt.url-select.autocopy: If true, selected URLs are copied to PRIMARY
# URvxt.url-select.button: Mouse button to click-open URLs (default: 2)
# URxvt.url-select.launcher: Browser/command to open selected URL with
# URxvt.url-select.underline: If set to true, all URLs get underlined
use strict;
# The custom rendition bit to use for marking the cell as being underlined
# by us so we can unset it again after a line has changed.
use constant UNDERLINED => 1<<3; # arbitrarily chosen in hope of no collision
sub on_start {
my ($self) = @_;
# read resource settings
if ($self->x_resource('url-select.launcher')) {
@{$self->{browser}} = split /\s+/, $self->x_resource('url-select.launcher');
} else {
@{$self->{browser}} = ('x-www-browser');
}
if ($self->x_resource('url-select.underline') eq 'true') {
$self->enable(line_update => \&line_update);
}
if ($self->x_resource('url-select.autocopy') eq 'true') {
$self->{autocopy} = 1;
}
$self->{state} = 0;
for my $mod (split '', $self->x_resource("url-select.button") ||
$self->x_resource("matcher.button") || 2) {
if ($mod =~ /^\d+$/) {
$self->{button} = $mod;
} elsif ($mod eq "C") {
$self->{state} |= urxvt::ControlMask;
} elsif ($mod eq "S") {
$self->{state} |= urxvt::ShiftMask;
} elsif ($mod eq "M") {
$self->{state} |= $self->ModMetaMask;
} elsif ($mod ne "-" && $mod ne " ") {
warn("invalid button/modifier in $self->{_name}<$self->{argv}[0]>: $mod\n");
}
}
if ($self->x_resource('matcher.pattern')) {
@{$self->{pattern}} = ($self->x_resource('matcher.pattern'));
} elsif ($self->x_resource('matcher.pattern.0')) {
my $current = 0;
while (defined (my $res = $self->x_resource("matcher.pattern.$current"))) {
$res = $self->locale_decode($res);
utf8::encode $res;
push @{$self->{pattern}}, qr($res)x;
$current++;
}
} else {
@{$self->{pattern}} = qr{
(?:https?://|ftp://|news://|mailto:|file://|\bwww\.)
[\w\-\@;\/?:&=%\$.+!*\x27,~#]*
(
\([\w\-\@;\/?:&=%\$.+!*\x27,~#]*\) # Allow a pair of matched parentheses
| #
[\w\-\@;\/?:&=%\$+*~] # exclude some trailing characters (heuristic)
)+
}x;
}
()
}
sub line_update {
my ($self, $row) = @_;
my $line = $self->line($row);
my $text = $line->t;
my $rend = $line->r;
# clear all underlines that were set by us
for (@$rend) {
if (urxvt::GET_CUSTOM($_) & UNDERLINED) {
$_ = urxvt::SET_CUSTOM($_, urxvt::GET_CUSTOM($_) & ~UNDERLINED) &
~urxvt::RS_Uline;
}
}
for my $pattern (@{$self->{pattern}}) {
while ($text =~ /$pattern/g) {
my $url = $&;
my ($beg, $end) = ($-[0], $+[0] - 1);
for (@{$rend}[$beg .. $end]) {
unless ($_ & urxvt::RS_Uline) {
$_ = urxvt::SET_CUSTOM($_, urxvt::GET_CUSTOM($_) | UNDERLINED);
$_ |= urxvt::RS_Uline;
}
}
}
}
$line->r($rend);
()
}
sub on_action {
my ($self, $action) = @_;
on_user_command($self, "url-select:" . $action);
}
sub on_user_command {
my ($self, $cmd) = @_;
if ($cmd eq 'url-select:select_next') {
if (not $self->{active}) {
activate($self);
}
select_next($self, -1);
}
()
}
sub key_press {
my ($self, $event, $keysym) = @_;
my $char = chr($keysym);
if ($keysym == 0xff1b || lc($char) eq 'q' ||
(lc($char) eq 'c' && $event->{state} & urxvt::ControlMask)) {
deactivate($self);
} elsif ($keysym == 0xff0d || $char eq 'o' ||
(lc($char) eq 'm' && $event->{state} & urxvt::ControlMask)) {
$self->exec_async(@{$self->{browser}}, ${$self->{found}[$self->{n}]}[4]);
deactivate($self) unless $char eq 'o';
} elsif ($char eq 'y') {
my $found = $self->{found}[$self->{n}];
$self->selection_beg(${$found}[0], ${$found}[1]);
$self->selection_end(${$found}[2], ${$found}[3]);
$self->selection_make($event->{time});
$self->selection_beg(1, 0);
$self->selection_end(1, 0);
deactivate($self);
} elsif ($char eq 'k' || $keysym == 0xff52 || $keysym == 0xff51) {
select_next($self, -1, $event);
} elsif ($char eq 'j' || $keysym == 0xff54 || $keysym == 0xff53) {
select_next($self, 1, $event);
} elsif ($char eq 'g' || $keysym == 0xff50) {
$self->{row} = $self->top_row - 1;
delete $self->{found};
select_next($self, 1, $event);
} elsif ($char eq 'G' || $keysym == 0xff57) {
$self->{row} = $self->nrow;
delete $self->{found};
select_next($self, -1, $event);
}
return 1;
}
sub on_button_press {
my ($self, $event) = @_;
my $mask = $self->ModLevel3Mask | $self->ModMetaMask |
urxvt::ShiftMask | urxvt::ControlMask;
if ($event->{button} == $self->{button} && ($event->{state} & $mask) == $self->{state}) {
my $col = $event->{col};
my $row = $event->{row};
my $line = $self->line($row);
my $text = $line->t;
for my $pattern (@{$self->{pattern}}) {
while ($text =~ /$pattern/g) {
my ($url, $beg, $end) = ($&, $-[0], $+[0]);
--$end if $url =~ s/["')]$//;
if ($col >= $beg && $col <= $end) {
$self->{button_pressed} = 1;
$self->{button_col} = $col;
$self->{button_row} = $row;
$self->{button_url} = $url;
return 1;
}
}
}
}
()
}
sub on_button_release {
my ($self, $event) = @_;
if ($self->{button_pressed} && $event->{button} == $self->{button}) {
my $col = $event->{col};
my $row = $event->{row};
$self->{button_pressed} = 0;
if ($col == $self->{button_col} && $row == $self->{button_row}) {
$self->exec_async(@{$self->{browser}}, $self->{button_url});
return 1;
}
}
()
}
sub select_next {
# $dir < 0: up, > 0: down
my ($self, $dir, $event) = @_;
my $row = $self->{row};
if (($dir < 0 && $self->{n} > 0) ||
($dir > 0 && $self->{n} < $#{ $self->{found} })) {
# another url on current line
$self->{n} += $dir;
hilight($self);
if ($self->{autocopy}) {
my $found = $self->{found}[$self->{n}];
$self->selection_beg(${$found}[0], ${$found}[1]);
$self->selection_end(${$found}[2], ${$found}[3]);
$self->selection_make($event->{time});
$self->selection_beg(1, 0);
$self->selection_end(1, 0);
}
return;
}
while (($dir < 0 && $row > $self->top_row) ||
($dir > 0 && $row < $self->nrow - 1)) {
my $line = $self->line($row);
$row = ($dir < 0 ? $line->beg : $line->end) + $dir;
$line = $self->line($row);
my $text = $line->t;
for my $pattern (@{$self->{pattern}}) {
if ($text =~ /$pattern/g) {
delete $self->{found};
do {
my ($beg, $end) = ($-[0], $+[0]);
push @{$self->{found}}, [$line->coord_of($beg),
$line->coord_of($end), substr($text, $beg, $end - $beg)];
} while ($text =~ /$pattern/g);
$self->{row} = $row;
$self->{n} = $dir < 0 ? $#{$self->{found}} : 0;
hilight($self);
if ($self->{autocopy}) {
my $found = $self->{found}[$self->{n}];
$self->selection_beg(${$found}[0], ${$found}[1]);
$self->selection_end(${$found}[2], ${$found}[3]);
$self->selection_make($event->{time});
$self->selection_beg(1, 0);
$self->selection_end(1, 0);
}
return;
}
}
}
deactivate($self) unless $self->{found};
()
}
sub hilight {
my ($self) = @_;
if ($self->{found}) {
if ($self->{row} < $self->view_start() ||
$self->{row} >= $self->view_start() + $self->nrow) {
# scroll selected url into visible area
my $top = $self->{row} - ($self->nrow >> 1);
$self->view_start($top < 0 ? $top : 0);
}
status_area($self);
$self->want_refresh();
}
()
}
sub refresh {
my ($self) = @_;
if ($self->{found}) {
if ($self->x_resource('highlightColor')) {
$self->scr_xor_span(@{$self->{found}[$self->{n}]}[0 .. 3], urxvt::RS_Sel);
} else {
$self->scr_xor_span(@{$self->{found}[$self->{n}]}[0 .. 3], urxvt::RS_RVid);
}
}
()
}
sub status_area {
my ($self) = @_;
my $row = $self->{row} < 0 ?
$self->{row} - $self->top_row : abs($self->top_row) + $self->{row};
my $text = sprintf("%d,%d ", $row + 1, $self->{n} + 1);
if ($self->top_row == 0) {
$text .= "All";
} elsif ($self->view_start() == $self->top_row) {
$text .= "Top";
} elsif ($self->view_start() == 0) {
$text .= "Bot";
} else {
$text .= sprintf("%2d%",
($self->top_row - $self->view_start) * 100 / $self->top_row);
}
my $text_len = length($text);
if ($self->{overlay_len} != $text_len) {
delete $self->{overlay} if $self->{overlay};
$self->{overlay} = $self->overlay(-1, -1, $text_len, 1,
urxvt::OVERLAY_RSTYLE, 0);
$self->{overlay_len} = $text_len;
}
$self->{overlay}->set(0, 0, $self->special_encode($text));
$self->{overlay}->show();
()
}
sub tt_write {
return 1;
}
sub activate {
my ($self) = @_;
$self->{active} = 1;
$self->{row} = $self->view_start() + $self->nrow;
$self->{n} = 0;
$self->{overlay_len} = 0;
$self->{button_pressed} = 0;
$self->{view_start} = $self->view_start();
$self->{pty_ev_events} = $self->pty_ev_events(urxvt::EV_NONE);
$self->enable(
key_press => \&key_press,
refresh_begin => \&refresh,
refresh_end => \&refresh,
tt_write => \&tt_write,
);
()
}
sub deactivate {
my ($self) = @_;
$self->disable("key_press", "refresh_begin", "refresh_end", "tt_write");
$self->view_start($self->{view_start});
$self->pty_ev_events($self->{pty_ev_events});
delete $self->{overlay} if $self->{overlay};
delete $self->{found} if $self->{found};
$self->want_refresh();
$self->{active} = 0;
()
}

View File

@ -1,4 +0,0 @@
Xft/Hinting 1
Xft/RGBA "rgb"
Xft/HintStyle "hintslight"
Xft/Antialias 1

View File

@ -1,3 +1,3 @@
# dotfiles # dotfiles
This repository contains my dotfiles for all linux operating systems, including Ubuntu HomeDesktop, Lubuntu Laptop, and others This repository has been deprecated, as now we switch to dotfiles-local + dotbot workflow

3
backlight.md 100644
View File

@ -0,0 +1,3 @@
# backlight control using i3
Follow [backlight](https://wiki.archlinux.org/index.php/backlight), it will provide step by step guidance to use xbacklight on intel laptop

1
dotbot 160000

@ -0,0 +1 @@
Subproject commit 5d83f9e797b1950199e127a8196803f5e33e0916

View File

@ -1,5 +1,7 @@
# ibus multi-language input # ibus multi-language input
Check current ibus engine: `ibus engine` Check current ibus engine: `ibus engine`
Check available ibus engine: `ibus list-engine` Check available ibus engine: `ibus list-engine`

15
install 100755
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -e
CONFIG="install.conf.yaml"
DOTBOT_DIR="dotbot"
DOTBOT_BIN="bin/dotbot"
BASEDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${BASEDIR}"
git -C "${DOTBOT_DIR}" submodule sync --quiet --recursive
git submodule update --init --recursive "${DOTBOT_DIR}"
"${BASEDIR}/${DOTBOT_DIR}/${DOTBOT_BIN}" -d "${BASEDIR}" -c "${CONFIG}" "${@}"

View File

@ -0,0 +1,8 @@
- defaults:
link:
relink: true
- clean: ['~']
- link:

View File

@ -1,11 +1,51 @@
# Media control in i3 # Media control in i3
There are multiple choices of audio program available, the i3 config file I followed at beginning using amixer, while I choose PulseAudio. Please check "addy-dclxvi/i3-staterpack"
## Media control using i3 commands His volume/music control config is shown as below:
```
# change volume
bindsym XF86AudioRaiseVolume exec amixer -q set Master
bindsym XF86AudioLowerVolume exec amixer -q set Master 5%-
bindsym XF86AudioMute exec amixer set Master toggle
# music control
bindsym XF86AudioNext exec mpc next
bindsym XF86AudioPrev exec mpc prev
bindsym XF86AudioPlay exec mpc toggle
bindsym XF86AudioStop exec mpc stop
```
Following are the process I used in my Media/Volume control in i3
## Volume Control using PulseAudio
* Install `PulseAudio` (Pulse Audio Sound server system)
* Install `pactl` as commandline controller `PulseAudio`
* Install `pavucontrol` as GUI controler of `PulseAudio`
### Check `pactl` controller is working and learn how to use it and add to i3
1. Play music on youtube or Spotify
2. Open `pavucontrol` to check sound is player correctly
3. Find correct Sink by `pactl list`, the playing one should be the "Sink" that has "State: Running"
4. Increase volume by `pactl set-sink-volume <sink number> 70%`, which change volume and should be reflected on `pavucontrol` and your ear
5. Now you know which sink is using and add the command line into i3 config
## Check `playerctl` controller is working and learn how to use it and add to i3
1. Play music on Spotify
2. Pause the music by `playerctl play-pause`, and check whether the music stopped
3. After confimring this commandline worked, add it to with keybind in your i3
## Media control in separate mode
1. Create a mode "media" in i3 configuration 1. Create a mode "media" in i3 configuration
2. Check pulseaudio is installed 2. In the mode, add bindsym to control media flow
3. Check `pactl` is installed, which will be used as command line interface to turn music on/off
4. Check sink number, by `pactl list`, which will show SINK 0,1,2,etc. Find corret based on which hardware are you using
## Media control using TUI ## Media control using TUI
1. Install `pulsemixer` 1. Install `pulsemixer`
2. Use `pulsemixer` TUI to change volume, this program cannot do single channel change, it can only do change on both channel at once 2. Use `pulsemixer` TUI to change volume, this program cannot do single channel change, it can only do change on both channel at once
## Media control using GUI (Suggested in Ubuntu Distro)
1. Install `pavucontrol`
2. Use `pavucontrol` to change volume

9
multi-screen.md 100644
View File

@ -0,0 +1,9 @@
# Multi-screen setup in i3 config
1. Install `arandr`, which can be used to visually setup multiscreen layout
2. Configure multiscreen layout using `arandr` and save to a bash script (which containing `xrandr` commands)
3. Add bash script execution in i3 config with `exec_always --no-startup-id ...` to let multiscreen configuration taking effect