summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/i3/config17
-rw-r--r--.config/i3blocks/config7
-rw-r--r--.config/nvim/init.vim23
-rwxr-xr-x.local/bin/blocks/calendar2
-rwxr-xr-x.local/bin/blocks/gpu2
-rwxr-xr-x.local/bin/blocks/player156
6 files changed, 194 insertions, 13 deletions
diff --git a/.config/i3/config b/.config/i3/config
index 8268103..01e3f18 100644
--- a/.config/i3/config
+++ b/.config/i3/config
@@ -185,6 +185,15 @@ bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @D
bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -2% && $rstbar
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $rstbar
bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $rstbar
+# bindsym XF86AudioMedia exec
+bindsym XF86AudioPrev exec playerctl previous && $rstbar
+bindsym XF86AudioNext exec playerctl next && $rstbar
+bindsym XF86AudioPlay exec playerctl play-pause && $rstbar
+# bindsym XF86AudioPause exec # Same as XF86AudioPlay in my keyboard. That's why the 'play-pause' option is used.
+# bindsym XF86AudioStop exec
+# bindsym XF86AudioRecord exec
+# bindsym XF86AudioRewind exec
+# bindsym XF86AudioForward exec
# bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $rstbar
# bindsym XF86PowerOff exec
# bindsym XF86Copy exec
@@ -208,13 +217,6 @@ bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@
# bindsym XF86Back exec
# bindsym XF86Forward exec
# bindsym XF86Eject exec
-# bindsym XF86AudioNext exec
-# bindsym XF86AudioPlay exec
-# bindsym XF86AudioPrev exec
-# bindsym XF86AudioStop exec
-# bindsym XF86AudioRecord exec
-# bindsym XF86AudioRewind exec
-# bindsym XF86AudioForward exec
# bindsym XF86Phone exec
# bindsym XF86Tools exec
# bindsym XF86HomePage exec
@@ -247,7 +249,6 @@ bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@
# bindsym XF86Shop exec
# bindsym XF86MonBrightnessDown exec
# bindsym XF86MonBrightnessUp exec
-# bindsym XF86AudioMedia exec
# bindsym XF86Display exec
# bindsym XF86KbdLightOnOff exec
# bindsym XF86KbdBrightnessDown exec
diff --git a/.config/i3blocks/config b/.config/i3blocks/config
index 3b0f5e3..b34ce87 100644
--- a/.config/i3blocks/config
+++ b/.config/i3blocks/config
@@ -8,6 +8,11 @@ separator=false
separator_block_width=5
markup=pango
+[player]
+interval=5
+instance=spotify
+signal=1
+
[gpu]
interval=5
label=
@@ -26,7 +31,7 @@ label=
[memory]
interval=5
label=
-#i nstance=swap
+# instance=swap
[volume]
interval=once
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim
index 34e25e9..3d21058 100644
--- a/.config/nvim/init.vim
+++ b/.config/nvim/init.vim
@@ -48,13 +48,24 @@ call plug#end()
set shiftwidth=4
" Spell checking
- set spelllang=es_mx,en_us
autocmd FileType tex setlocal spell
+ set spelllang=es_mx,en_us
" Leader key
- let mapleader=' '
+ let mapleader='\'
set showcmd
+""---Custom functions---""
+ " Toggle spellchecking
+ function! ToggleSpellCheck()
+ set spell!
+ if &spell
+ echo "Spellcheck ON"
+ else
+ echo "Spellcheck OFF"
+ endif
+ endfunction
+
""---Plugin configuration---""
" vim-airline
let g:airline_powerline_fonts=1
@@ -64,6 +75,11 @@ call plug#end()
" vim-signify
set updatetime=100
+
+ " vimtex
+ let g:tex_flavor='latex'
+ let g:vimtex_view_method=$READER
+ let g:vimtex_quickfix_mode=0
" tex-conceal
set conceallevel=2
@@ -91,3 +107,6 @@ call plug#end()
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
+
+ " Spell checking
+ map <Leader>s :call ToggleSpellCheck()<CR>
diff --git a/.local/bin/blocks/calendar b/.local/bin/blocks/calendar
index eb8e210..fa9c805 100755
--- a/.local/bin/blocks/calendar
+++ b/.local/bin/blocks/calendar
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
WIDTH=${WIDTH:-200}
HEIGHT=${HEIGHT:-200}
diff --git a/.local/bin/blocks/gpu b/.local/bin/blocks/gpu
index e5e460b..73c17f1 100755
--- a/.local/bin/blocks/gpu
+++ b/.local/bin/blocks/gpu
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/perl
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
diff --git a/.local/bin/blocks/player b/.local/bin/blocks/player
new file mode 100755
index 0000000..f78bd78
--- /dev/null
+++ b/.local/bin/blocks/player
@@ -0,0 +1,156 @@
+#!/usr/bin/env perl
+# Copyright (C) 2014 Tony Crisci <tony@dubstepdish.com>
+# Copyright (C) 2015 Thiago Perrotta <perrotta dot thiago at poli dot ufrj dot br>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Requires playerctl binary to be in your path (except cmus)
+# See: https://github.com/acrisci/playerctl
+
+# Set instance=NAME in the i3blocks configuration to specify a music player
+# (playerctl will attempt to connect to org.mpris.MediaPlayer2.[NAME] on your
+# DBus session).
+
+use Time::HiRes qw(usleep);
+use Env qw(BLOCK_INSTANCE);
+
+use constant DELAY => 50; # Delay in ms to let network-based players (spotify) reflect new data.
+use constant SPOTIFY_STR => 'spotify';
+
+my @metadata = ();
+my $player_arg = "";
+
+if ($BLOCK_INSTANCE) {
+ $player_arg = "--player='$BLOCK_INSTANCE'";
+}
+
+sub buttons {
+ my $method = shift;
+
+ if($method eq 'mpd') {
+ if ($ENV{'BLOCK_BUTTON'} == 1) {
+ system("mpc prev");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 2) {
+ system("mpc toggle");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 3) {
+ system("mpc next");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 4) {
+ system("mpc volume +10");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 5) {
+ system("mpc volume -10");
+ }
+ } elsif ($method eq 'cmus') {
+ if ($ENV{'BLOCK_BUTTON'} == 1) {
+ system("cmus-remote --prev");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 2) {
+ system("cmus-remote --pause");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 3) {
+ system("cmus-remote --next");
+ }
+ } elsif ($method eq 'playerctl') {
+ if ($ENV{'BLOCK_BUTTON'} == 1) {
+ system("playerctl $player_arg previous");
+ usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR;
+ } elsif ($ENV{'BLOCK_BUTTON'} == 2) {
+ system("playerctl $player_arg play-pause");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 3) {
+ system("playerctl $player_arg next");
+ usleep(DELAY * 1000) if $BLOCK_INSTANCE eq SPOTIFY_STR;
+ } elsif ($ENV{'BLOCK_BUTTON'} == 4) {
+ system("playerctl $player_arg volume 0.01+");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 5) {
+ system("playerctl $player_arg volume 0.01-");
+ }
+ } elsif ($method eq 'rhythmbox') {
+ if ($ENV{'BLOCK_BUTTON'} == 1) {
+ system("rhythmbox-client --previous");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 2) {
+ system("rhythmbox-client --play-pause");
+ } elsif ($ENV{'BLOCK_BUTTON'} == 3) {
+ system("rhythmbox-client --next");
+ }
+ }
+}
+
+sub cmus {
+ my @cmus = split /^/, qx(cmus-remote -Q);
+ if ($? == 0) {
+ foreach my $line (@cmus) {
+ my @data = split /\s/, $line;
+ if (shift @data eq 'tag') {
+ my $key = shift @data;
+ my $value = join ' ', @data;
+
+ @metadata[0] = $value if $key eq 'artist';
+ @metadata[1] = $value if $key eq 'title';
+ }
+ }
+
+ if (@metadata) {
+ buttons('cmus');
+
+ # metadata found so we are done
+ print(join ' - ', @metadata);
+ exit 0;
+ }
+ }
+}
+
+sub mpd {
+ my $data = qx(mpc current);
+ if (not $data eq '') {
+ buttons("mpd");
+ print($data);
+ exit 0;
+ }
+}
+
+sub playerctl {
+ buttons('playerctl');
+
+ my $artist = qx(playerctl $player_arg metadata artist);
+ chomp $artist;
+ # exit status will be nonzero when playerctl cannot find your player
+ exit(0) if $? || $artist eq '(null)';
+
+ push(@metadata, $artist) if $artist;
+
+ my $title = qx(playerctl $player_arg metadata title);
+ exit(0) if $? || $title eq '(null)';
+
+ push(@metadata, $title) if $title;
+
+ print(join(" - ", @metadata)) if @metadata;
+}
+
+sub rhythmbox {
+ buttons('rhythmbox');
+
+ my $data = qx(rhythmbox-client --print-playing --no-start);
+ print($data);
+}
+
+if ($player_arg eq '' or $player_arg =~ /mpd/) {
+ mpd;
+}
+elsif ($player_arg =~ /cmus/) {
+ cmus;
+}
+elsif ($player_arg =~ /rhythmbox/) {
+ rhythmbox;
+}
+else {
+ playerctl;
+}
+print("\n");