From c2dbb5925fe9eb8ef1b2cb5ff9f3481a595727c1 Mon Sep 17 00:00:00 2001 From: Adam Hellberg Date: Sat, 14 Jan 2017 03:06:40 +0100 Subject: [PATCH] Move i3 config to config dir, add music block --- {i3 => config/i3}/config | 26 ++++++++--------- i3blocks.conf => config/i3blocks/config | 13 +++++++++ i3blocks/sharp-music.rb | 38 +++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 13 deletions(-) rename {i3 => config/i3}/config (93%) rename i3blocks.conf => config/i3blocks/config (93%) create mode 100755 i3blocks/sharp-music.rb diff --git a/i3/config b/config/i3/config similarity index 93% rename from i3/config rename to config/i3/config index 6236303..d2d9465 100644 --- a/i3/config +++ b/config/i3/config @@ -15,11 +15,7 @@ set $mod Mod4 # Font for window titles. Will also be used by the bar unless a different font # is used in the bar {} block below. -font pango:Fira Code 7 - -# This font is widely installed, provides lots of unicode glyphs, right-to-left -# text rendering and scalability on retina/hidpi displays (thanks to pango). -#font pango:DejaVu Sans Mono 8 +font pango:Fira Code,DejaVu Sans Mono 7 # Before i3 v4.8, we used to recommend this one as the default: # font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1 @@ -55,10 +51,10 @@ bindsym $mod+l focus up bindsym $mod+semicolon focus right # alternatively, you can use the cursor keys: -bindsym $mod+Left focus left -bindsym $mod+Down focus down -bindsym $mod+Up focus up -bindsym $mod+Right focus right +#bindsym $mod+Left focus left +#bindsym $mod+Down focus down +#bindsym $mod+Up focus up +#bindsym $mod+Right focus right # move focused window bindsym $mod+Shift+j move left @@ -67,10 +63,10 @@ bindsym $mod+Shift+l move up bindsym $mod+Shift+semicolon move right # alternatively, you can use the cursor keys: -bindsym $mod+Shift+Left move left -bindsym $mod+Shift+Down move down -bindsym $mod+Shift+Up move up -bindsym $mod+Shift+Right move right +#bindsym $mod+Shift+Left move left +#bindsym $mod+Shift+Down move down +#bindsym $mod+Shift+Up move up +#bindsym $mod+Shift+Right move right # split in horizontal orientation bindsym $mod+h split h @@ -203,6 +199,10 @@ bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute 1 toggle bindsym XF86MonBrightnessUp exec xbacklight -inc 5 bindsym XF86MonBrightnessDown exec xbacklight -dec 5 +bindsym $mod+Left exec --no-startup-id mpc prev && pkill -RTMIN+12 i3blocks +bindsym $mod+Right exec --no-startup-id mpc next && pkill -RTMIN+12 i3blocks +bindsym $mod+Down exec --no-startup-id mpc toggle && pkill -RTMIN+12 i3blocks + bindsym Ctrl+Mod1+l exec /home/sharparam/bin/lockify workspace_auto_back_and_forth yes diff --git a/i3blocks.conf b/config/i3blocks/config similarity index 93% rename from i3blocks.conf rename to config/i3blocks/config index 777f73a..8aa0582 100644 --- a/i3blocks.conf +++ b/config/i3blocks/config @@ -28,6 +28,19 @@ command=/usr/lib/i3blocks/$BLOCK_NAME separator_block_width=15 markup=none +#[mediaplayer] +#label=♪ +#command=$SCRIPT_DIR/mediaplayer/mediaplayer +#instance=mpd +#interval=5 +#signal=15 + +[sharp-music] +command=/home/sharparam/dotfiles/i3blocks/sharp-music.rb +#label=♪ +interval=5 +signal=12 + # Volume indicator # # The first parameter sets the step (and units to display) diff --git a/i3blocks/sharp-music.rb b/i3blocks/sharp-music.rb new file mode 100755 index 0000000..897c63a --- /dev/null +++ b/i3blocks/sharp-music.rb @@ -0,0 +1,38 @@ +#!/usr/bin/env ruby +# encoding: utf-8 + +ICONS = { playing: '', paused: '', stopped: '' }.freeze + +MODS = { repeat: '', random: '', single: '', consume: '' }.freeze + +case ENV['BLOCK_BUTTON'].to_i +when 1 # Left mouse button + `mpc next` +when 2 # Scroll click + `mpc toggle` +when 3 # Right mouse button + `mpc prev` +when 4 # Mouse 4 (?) + `mpc volume +5` +when 5 # Mouse 5 (?) + `mpc volume -5` +end + +mpc = `mpc`.split "\n" + +# If we get less than 3 lines of output, it means playback is stopped +exit if mpc.size < 3 + +mods = Hash[mpc[2].scan(/(\w+): (off|on)/).map do |m| + [m.first.to_sym, m.last == 'on'] +end] + +data = { + now_playing: mpc[0], + status: mpc[1].match(/^\[(\w+)\]/)[1].to_sym, + mods: [:repeat, :random, :single, :consume].map { |m| MODS[m] if mods[m] }.compact.join(' ') +} + +print "#{ICONS[data[:status]]} #{data[:now_playing]}" +print " #{data[:mods]}" if data[:mods].size > 0 +puts -- 2.54.0