all repos

dotfiles @ f8ffdbd

my dotfiles
15 files changed, 1356 insertions(+), 0 deletions(-)
Add: i3, polybar, rofi, redshift config
Author: Smirnov Olexandr ss2316544@gmail.com
Committed at: 2020-09-27 21:55:01 +0300
Parent: 68604c9
A config/i3/config

@@ -0,0 +1,171 @@

+############# General ############# +# Bind $MOD(super) key +set $mod Mod4 +# Font +font monospace 10 +font pango:hack 10 +# Disable window title +default_border pixel + +############ Autostart ############ +exec --no-startup-id exec picom -b +exec --no-startup-id exec feh --bg-scale ~/Imager/wallpaper.png +exec --no-startup-id exec setxkbmap "us,ru,ua" ",winkeys" "grp:alt_shift_toggle" +exec --no-startup-id exec org.telegram.desktop +exec --no-startup-id exec discord + +############ Key bindings ######### +# Terminal +bindsym $mod+Return exec kitty +#bindsym $mod+Return exec konsole + +# Kill focus window +bindsym $mod+q kill +bindsym Mod1+F4 kill + +# Program/Exit louncher +bindsym $mod+space exec "rofi -show drun -show-icons -font 'hack 12' -show cobi -disable-history" +bindsym $mod+Escape exec "rofi -show power-menu -show-icons -font 'hack 12' -width 30 -lines 6 -disable-history -modi power-menu:~/.config/rofi/rofi-power-menu" +# Restart i3wm +bindsym $mod+Shift+r restart + +# Load program +bindsym $mod+F1 exec dolphin +bindsym $mod+F2 exec chromium +bindsym $mod+b exec firefox +bindsym $mod+F3 exec spotify +bindsym $mod+F4 exec subl +bindsym $mod+F5 exec notable + +# Floating window +floating_modifier $mod +bindsym $mod+Shift+space floating toggle +bindsym $mod+Shift+f focus mode_toggle + +# Fullscreen mode +bindsym $mod+f fullscreen toggle +bindsym $mod+F11 fullscreen toggle + +# Splits +bindsym $mod+h split h +bindsym $mod+v split v + +# Focus the parent container +bindsym $mod+a focus parent + +# Change container layout(stacked, tabbed, toggle split) +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout toggle split + +# Scratchpad +bindsym $mod+Shift+grave move scratchpad +bindsym $mod+grave scratchpad show + +######### Window preferens ######## +assign [class="(?i)konsole|kitty"] $ws1 +assign [class="(?i)chromium|firefox"] $ws2 +assign [class="(?i)subl|code|atom|typora|prepros"] $ws3 +assign [class="(?i)dolphin"] $ws4 +assign [class="(?i)telegram|discord"] $ws6 +assign [title="Notable|Simplenote"] $ws7 +assign [title="KeePassXC"] $ws8 +for_window [class="Spotify"] move to workspace $ws10 + +##### Change containet focus ###### +# Vim like keys container +bindsym $mod+j focus left +bindsym $mod+k focus down +bindsym $mod+l focus up +bindsym $mod+semicolon focus right + +# Alternatively cursor keys +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +##### Move focused container ###### +# Vim like keys +bindsym $mod+Shift+j move left +bindsym $mod+Shift+k move down +bindsym $mod+Shift+l move up +bindsym $mod+Shift+colon move right + +# Alternatively 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 + +############ Workspaces ########### +set $ws1 "1" +set $ws2 "2" +set $ws3 "3" +set $ws4 "4" +set $ws5 "5" +set $ws6 "6" +set $ws7 "7" +set $ws8 "8" +set $ws9 "9" +set $ws10 "10" + +# Switch workspace +bindsym $mod+1 workspace $ws1 +bindsym $mod+2 workspace $ws2 +bindsym $mod+3 workspace $ws3 +bindsym $mod+4 workspace $ws4 +bindsym $mod+5 workspace $ws5 +bindsym $mod+6 workspace $ws6 +bindsym $mod+7 workspace $ws7 +bindsym $mod+8 workspace $ws8 +bindsym $mod+9 workspace $ws9 +bindsym $mod+0 workspace $ws10 + +# Move focused container to workspace +bindsym $mod+Shift+1 move container to workspace $ws1 +bindsym $mod+Shift+2 move container to workspace $ws2 +bindsym $mod+Shift+3 move container to workspace $ws3 +bindsym $mod+Shift+4 move container to workspace $ws4 +bindsym $mod+Shift+5 move container to workspace $ws5 +bindsym $mod+Shift+6 move container to workspace $ws6 +bindsym $mod+Shift+7 move container to workspace $ws7 +bindsym $mod+Shift+8 move container to workspace $ws8 +bindsym $mod+Shift+9 move container to workspace $ws9 +bindsym $mod+Shift+0 move container to workspace $ws10 + +########### Resize mode ########### +mode "resize" { + bindsym j resize shrink width 10 px or 10 ppt + bindsym k resize grow height 10 px or 10 ppt + bindsym l resize shrink height 10 px or 10 ppt + bindsym semicolon resize grow width 10 px or 10 ppt + + # same bindings, but for the arrow keys + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape or $mod+r + bindsym Return mode "default" + bindsym Escape mode "default" + bindsym $mod+r mode "default" +} +bindsym $mod+r mode "resize" + +############### Bar ############### +exec_always --no-startup-id $HOME/.config/polybar/launch.sh +#bar { +# status_command i3status +# position top +#} + +############## Colors ############# +# class border backgr. text indicator child_border +client.focused #268bd2 #268bd2 #ffffff #268bd2 #268bd2 +client.focused_inactive #000000 #000000 #ffffff #000000 #000000 +client.unfocused #000000 #000000 #888888 #000000 #000000 +client.urgent #000000 #000000 #ffffff #000000 #000000 +client.placeholder #000000 #000000 #ffffff #000000 #000000 +client.background #ffffff
A config/kitty/kitty.conf

@@ -0,0 +1,238 @@

+#: MOD +kitty_mod ctrl+shift +clear_all_shortcuts no + + + +#: Font +font_family Jetbrains Mono +bold_font auto +italic_font auto +bold_italic_font auto + +font_size 12.0 + +adjust_line_height 0 +adjust_column_width 0 + +disable_ligatures never +font_features none +box_drawing_scale 0.001, 1, 1.5, 2 + + + +#: Cursor +cursor #dfdfdf +cursor_text_color #7d7d7d + +#cursor_shape block +cursor_shape beam + +cursor_beam_thickness 1.5 +cursor_underline_thickness 2.0 + +cursor_blink_interval 0 +cursor_stop_blinking_after 15.0 + + + +#: Bell +enable_audio_bell no +visual_bell_duration 0.0 +window_alert_on_bell no +command_on_bell none +bell_on_tab no + + + +#: Scrollback (History) +scrollback_lines 500 +scrollback_pager less --chop-long-lines --RAW-CONTROL-CHARS +INPUT_LINE_NUMBER +scrollback_pager_history_size 0 +wheel_scroll_multiplier 5.0 +touch_scroll_multiplier 1.0 + + + +#: Mouse +mouse_hide_wait 2.5 + +url_color #4ecdc4 +url_style curly + +open_url_modifiers kitty_mod +open_url_with default +url_prefixes http https file ftp +copy_on_select yes +strip_trailing_spaces never +rectangle_select_modifiers ctrl+alt +terminal_select_modifiers shift +select_by_word_characters :@-./_~?&=%+# +click_interval -1.0 +focus_follows_mouse yes +pointer_shape_when_grabbed arrow + + + +#: Perfomance +repaint_delay 10 +input_delay 3 +sync_to_monitor yes +command_on_bell none + + + +#: Window +remember_window_size yes +initial_window_width 640 +initial_window_height 480 +enabled_layouts * + +window_resize_step_cells 2 +window_resize_step_lines 2 +window_border_width 1.0 +draw_minimal_borders no +window_margin_width 0.0 +single_window_margin_width -1000.0 +window_padding_width 0.0 + +placement_strategy center +active_border_color #073642 +inactive_border_color #292f36 +bell_border_color #ff5a00 +inactive_text_alpha 1.0 +hide_window_decorations no +resize_debounce_time 0.1 +resize_draw_strategy static +resize_in_steps no + + + +#: Tabs +tab_bar_edge bottom +tab_bar_margin_width 0.0 +tab_bar_style powerline +tab_bar_min_tabs 2 +tab_switch_strategy previous +tab_fade 0.25 0.5 0.75 1 +tab_separator " ┇" +tab_title_template "{title}" +active_tab_title_template none + +active_tab_foreground #dfdfdf +active_tab_background #073642 +active_tab_font_style bold-italic +inactive_tab_foreground #dfdfdf +inactive_tab_background #292f36 +inactive_tab_font_style normal + +tab_bar_background none + + + +#: Theming +foreground #dfdfdf +background_opacity 0.87 +background_image none +background_image_layout tiled +background_image_linear no +dynamic_background_opacity no +background_tint 0.0 +dim_opacity 0.75 +selection_foreground #edebd7 +selection_background #073642 + + + +#: Keyboard Shortcuts +#: #: Clipboard +map ctrl+shift+c copy_to_clipboard +map ctrl+shift+v paste_from_clipboard +map shift+insert paste_from_selection +map kitty_mod+o pass_selection_to_program + +#: #: Scroll +map kitty_mod+up scroll_line_up +map kitty_mod+k scroll_line_up +map kitty_mod+down scroll_line_down +map kitty_mod+j scroll_line_down +map kitty_mod+page_up scroll_page_up +map kitty_mod+page_down scroll_page_down +map kitty_mod+home scroll_home +map kitty_mod+end scroll_end +map kitty_mod+h show_scrollback + +#: #: Window +map kitty_mod+F9 new_os_window +map kitty_mod+enter new_window +map kitty_mod+x close_window +map kitty_mod+] next_window +map kitty_mod+[ previous_window +map kitty_mod+f move_window_forward +map kitty_mod+b move_window_backward +map kitty_mod+` move_window_to_top +map kitty_mod+r start_resizing_window + +#: #: Tab +map kitty_mod+l next_tab +map kitty_mod+h previous_tab +map kitty_mod+t new_tab +map kitty_mod+q close_tab +map kitty_mod+. set_tab_title +map kitty_mod+1 first_window +map kitty_mod+2 second_window +map kitty_mod+3 third_window +map kitty_mod+4 fourth_window +map kitty_mod+5 fifth_window +map kitty_mod+6 sixth_window +map kitty_mod+7 seventh_window +map kitty_mod+8 eighth_window +map kitty_mod+9 ninth_window +map kitty_mod+0 tenth_window + +#: #: Layouts +map kitty_mod+l next_layout + +#: #: Font Size +map kitty_mod+equal change_font_size all +2.0 +map kitty_mod+minus change_font_size all -2.0 +map kitty_mod+backspace change_font_size all 0 + +#:#: Other +map f11 toggle_fullscreen +map kitty_mod+f10 toggle_maximized +map kitty_mod+u kitten unicode_input +map kitty_mod+f2 edit_config_file +map kitty_mod+escape kitty_shell window + +map kitty_mod+delete clear_terminal reset active + +selection_background #073642 +selection_foreground #edebd7 +foreground #d2dae2 +background #1e272e +cursorColor #d2dae2 + +color0 #1e272e +color8 #485460 + +color1 #ff3f34 +color9 #ff5e57 + +color2 #05c46b +color10 #0be881 + +color3 #ffa801 +color11 #ffc048 + +color4 #3c40c6 +color12 #575fcf + +color5 #f53b57 +color13 #ef5777 + +color6 #0fbcf9 +color14 #4bcffa + +color7 #808e9b +color15 #d2dae2
A config/polybar/config

@@ -0,0 +1,245 @@

+[settings] +pseudo-transparency = true + +[colors] +background = #002B36 +background-alt = #073642 +foreground = #dfdfdf +foreground-alt = #fdf6e3 +primary = #268bd2 +secondary = #218DC8 +alert = #268bd2 +;alert = #dc322f + +############################################################################################################ +[bar/example] +#monitor = ${env:MONITOR:HDMI-1} +width = 100% +height = 26 +fixed-center = true +locale = en_US.UTF-8 + +background = ${colors.background} +foreground = ${colors.foreground} + +line-size = 1 +line-color = #f00 + +padding-left = 0 +padding-right = 0 +module-margin-left = 1 +module-margin-right = 1 + +; Fonts +font-0 = Iosevka Nerd Font:style=Medium:size=8;3 +font-1 = FontAwesome5Free:style=Solid:size=7.5;2.5 +font-2 = Weather Icons:size=7;2 +font-3 = FontAwesome5Brands:style=Solid:size=7.5;2.5 + +############################################################################################################ +; Modules position +modules-left = i3 sp2 openweathermap-simple updates-pacman +;modules-center = title +modules-center = spotify +modules-right = pulseaudio xkeyboard powermenu sp2 calendar +tray-position = right +tray-padding = 2 +tray-detached = false + +############################################################################################################ +# INCLUDE MODULES +############################################################################################################ +[module/filesystem] +type = internal/fs +interval = 25 +mount-0 = / +mount-1 = /home + +label-mounted = %{F#c38611} %mountpoint%: %percentage_used%% +label-unmounted = %mountpoint% not mounted +label-unmounted-foreground = ${colors.foreground-alt} + +############################################################################################################ +[settings] +screenchange-reload = true + +############################################################################################################ +; Used for top and bottom aligned bars +[global/wm] +margin-top = 5 +margin-bottom = 5 +cursor-click = pointer +cursor-scroll = ns-resize +wm-restack = i3 + +############################################################################################################ +; i3wm workspace indicator +[module/i3] +type = internal/i3 +format = <label-state><label-mode> +index-sort = true +wrapping-scroll = false +label-mode-padding = 1 +label-mode-foreground = #000 +label-mode-background = ${colors.primary} +label-focused = %icon% +label-focused-background = 002873C0 +label-focused-foreground = ${colors.foreground} +label-focused-padding = 1 +label-focused-underline = 018BFF +#label-focused-overline = ${colors.primary} + +label-unfocused = %icon% +label-unfocused-background = 00255498 +label-unfocused-foreground = ${colors.foreground} +label-unfocused-padding = 1 +#label-unfocused-underline = 255498 +#label-unfocused-overline = ${colors.background} + +label-urgent = %icon% +label-urgent-background = ${colors.alert} +label-urgent-foreground = ${colors.foreground} +label-urgent-padding = 1 +label-urgent-underline = ${colors.alert} +#label-urgent-overline = ${colors.background} + +label-visible = %icon% +label-visible-background = ${colors.background} +label-visible-foreground = ${colors.foreground} +label-visible-padding = 1 +label-visible-underline = ${colors.background} +#label-visible-overline = ${colors.background} + +ws-icon-0 = "1;1 " +ws-icon-1 = "2;2 " +ws-icon-2 = "3;3 " +ws-icon-3 = "4;4 " +ws-icon-4 = "5;5 " +ws-icon-5 = "6;6 " +ws-icon-6 = "7;7 " +ws-icon-7 = 8;8 +ws-icon-8 = "9;9 " +ws-icon-9 = "10;10 " +;label-separator = | + +############################################################################################################ +# PulseAudio- https://github.com/polybar/polybar/wiki/Module:-pulseaudio +[module/pulseaudio] +type = internal/pulseaudio +format-volume = %{F#61a8ff}<ramp-volume><label-volume> +label-volume = %{F#61a8ff} %percentage%% +label-volume-foreground = ${root.foreground} +label-muted =  +label-muted-foreground = #e8793e + +ramp-volume-0 =  +ramp-volume-1 =  +ramp-volume-2 =  +ramp-volume-3 =  +ramp-volume-4 =  + +############################################################################################################ +; CPU Loads - https://github.com/polybar/polybar/wiki/Module:-cpu +[module/cpu] +type = internal/cpu +interval = 2 +format-prefix = " " +format-prefix-foreground = ${colors.foreground-alt} +label = %{F#1ecb0b} CPU %percentage%% + + +############################################################################################################ +# Memmory(RAM) - https://github.com/polybar/polybar/wiki/Module:-memory +[module/memory] +type = internal/memory +interval = 2 +format-prefix = " " +#format-prefix-foreground = ${colors.foreground-alt} +#format-overline = #61C07C +#format-underline = #61C07C +label = %{F#8d61ff}  MEM %percentage_used%% + +############################################################################################################ +; Weather +[module/openweathermap-simple] +type = custom/script +exec = ~/.config/polybar/scripts/openweathermap-simple.sh +interval = 60 +label-font = 3 + +############################################################################################################ +; Sporify inkator - https://github.com/Jvanrhijn/polybar-spotify +[module/spotify] +type = custom/script +interval = 1 +format-prefix = " " +format = <label> +exec = python ~/.config/polybar/scripts/spotify_status.py -f '{artist} - {song}' +line-size +format-underline = #1db954 + +############################################################################################################ +; Updates cheacker (pacman) +[module/updates-pacman] +type = custom/script +exec = ~/.config/polybar/scripts/updates-pacman.sh +interval = 600 + +############################################################################################################ +; Keyboard layout - https://github.com/polybar/polybar/wiki/Module:-xkeyboard +[module/xkeyboard] +type = internal/xkeyboard +blacklist-0 = num lock +label-NAME-maxlen = 10 +format-prefix = "" +label-layout =  %layout% + +label-indicator-padding = 2 +label-indicator-margin = 1 +label-indicator-background = 2B7DBC +label-indicator-overline = 2B7DBC +label-indicator-underline = 2B7DBC + +############################################################################################################ +; Battery - https://github.com/polybar/polybar/wiki/Module:-battery +[module/battery-combined-tlp] +type = custom/script +exec = ~/.config/polybar/scripts/battery-combined-tlp.sh +interval = 10 + +############################################################################################################ +; Separator +[module/sp2] +type = custom/text +content = "┇" +; content-foreground = #93A1A1 + +############################################################################################################ +; Calendar +[module/calendar] +type = custom/script +exec = ~/.config/polybar/scripts/popup-calendar.sh +interval = 5 +click-left = ~/.config/polybar/scripts/popup-calendar.sh --popup & + +############################################################################################################ +# Date & time - https://github.com/polybar/polybar/wiki/Module:-date +[module/date] +type = internal/date +interval = 1 +dqate = +time =%{F#E0D9FF} %H:%M:%S +date-alt =%{F#E0D9FF} %a %e %B %Y +time-alt = %H:%M +format-prefix =  +label = %date% %time% + +############################################################################################################ +; Focus window name - https://github.com/polybar/polybar/wiki/Module:-xwindow +[module/title] +type = internal/xwindow +label = %{F#f0f0f0}%title:0:50:...% +label-empty = Empty +label-empty-foreground = #707880 +label-maxlen = 30 +label-padding = 0
A config/polybar/launch.sh

@@ -0,0 +1,4 @@

+#!/bin/bash +killall -q polybar +while pgrep -u $UID -x polybar >/dev/null; do sleep 1; done +polybar example &
A config/polybar/scripts/battery-combined-tlp.sh

@@ -0,0 +1,5 @@

+#!/bin/sh + +battery=$(sudo tlp-stat -b | tac | grep -m 1 "Charge" | tr -d -c "[:digit:],.") + +echo " $battery %"
A config/polybar/scripts/btc

@@ -0,0 +1,25 @@

+#!/usr/bin/python +# -*- coding: utf-8 -*- + +import json,sys,urllib.request,time + +if len(sys.argv) != 3: + print("Usage: btc usd,eur,btc nok") + sys.exit() + +currencies = sys.argv[1] +basecurrency = sys.argv[2] + +currencyurl = "http://freecurrencyrates.com/api/action.php?do=cvals&iso=" + currencies.replace(',','') + "&f=" + basecurrency + "&v=1&s=cbr" +f = urllib.request.urlopen(currencyurl) +obj = json.loads(f.read()) +res=""; +for c in currencies.split(','): + res += c.upper() + ":{:,.2f}".format(1/obj[c.upper()]).replace(',',' ') + +# some unicode currency code replacement (optional) +res = res.replace("USD", " $") +res = res.replace("EUR", " €") +res = res.replace("BTC", " ") + +print(res);
A config/polybar/scripts/openweathermap-simple.sh

@@ -0,0 +1,57 @@

+#!/bin/sh +API="https://api.openweathermap.org/data/2.5" +KEY="34e5d198afe8fb0303e3c3c37774d2ca" +CITY="Horodnytsya, UA" +UNITS="metric" +SYMBOL="°С" + +get_icon() { + case $1 in + # Icons for weather-icons + 01d) icon="";; + 01n) icon="";; + 02d) icon="";; + 02n) icon="";; + 03*) icon="";; + 04*) icon="";; + 09d) icon="";; + 09n) icon="";; + 10d) icon="";; + 10n) icon="";; + 11d) icon="";; + 11n) icon="";; + 13d) icon="";; + 13n) icon="";; + 50d) icon="";; + 50n) icon="";; + *) icon=""; + esac + + echo $icon +} + +if [ -n "$CITY" ]; then + if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then + CITY_PARAM="id=$CITY" + else + CITY_PARAM="q=$CITY" + fi + + weather=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS") +else + location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue) + + if [ -n "$location" ]; then + location_lat="$(echo "$location" | jq '.location.lat')" + location_lon="$(echo "$location" | jq '.location.lng')" + + weather=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS") + fi +fi + +if [ -n "$weather" ]; then + weather_temp=$(echo "$weather" | jq ".main.temp" | cut -d "." -f 1) + weather_icon=$(echo "$weather" | jq -r ".weather[0].icon") + + echo "$(get_icon "$weather_icon")" "$weather_temp$SYMBOL" +fi
A config/polybar/scripts/popup-calendar.sh

@@ -0,0 +1,41 @@

+#!/bin/sh + +BAR_HEIGHT=22 # polybar height +BORDER_SIZE=1 # border size from your wm settings +YAD_WIDTH=222 # 222 is minimum possible value +YAD_HEIGHT=193 # 193 is minimum possible value +DATE="$(date +"%a %d %H:%M")" + +case "$1" in +--popup) + if [ "$(xdotool getwindowfocus getwindowname)" = "yad-calendar" ]; then + exit 0 + fi + + eval "$(xdotool getmouselocation --shell)" + eval "$(xdotool getdisplaygeometry --shell)" + + # X + if [ "$((X + YAD_WIDTH / 2 + BORDER_SIZE))" -gt "$WIDTH" ]; then #Right side + : $((pos_x = WIDTH - YAD_WIDTH - BORDER_SIZE)) + elif [ "$((X - YAD_WIDTH / 2 - BORDER_SIZE))" -lt 0 ]; then #Left side + : $((pos_x = BORDER_SIZE)) + else #Center + : $((pos_x = X - YAD_WIDTH / 2)) + fi + + # Y + if [ "$Y" -gt "$((HEIGHT / 2))" ]; then #Bottom + : $((pos_y = HEIGHT - YAD_HEIGHT - BAR_HEIGHT - BORDER_SIZE)) + else #Top + : $((pos_y = BAR_HEIGHT + BORDER_SIZE)) + fi + + yad --calendar --undecorated --fixed --close-on-unfocus --no-buttons \ + --width="$YAD_WIDTH" --height="$YAD_HEIGHT" --posx="$pos_x" --posy="$pos_y" \ + --title="yad-calendar" --borders=0 >/dev/null & + ;; +*) + echo "$DATE" + ;; +esac
A config/polybar/scripts/redshift.sh

@@ -0,0 +1,15 @@

+#!/bin/sh + +if [ "$(pgrep -x redshift)" ]; then + temp=$(redshift -p 2> /dev/null | grep temp | cut -d ":" -f 2 | tr -dc "[:digit:]") + + if [ -z "$temp" ]; then + echo "%{F#65737E} #" + elif [ "$temp" -ge 5000 ]; then + echo "%{F#8FA1B3} #" + elif [ "$temp" -ge 4000 ]; then + echo "%{F#EBCB8B} #" + else + echo "%{F#D08770} #" + fi +fi
A config/polybar/scripts/spotify_status.py

@@ -0,0 +1,140 @@

+#!/usr/bin/env python +import sys +import dbus +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument( + '-t', + '--trunclen', + type=int, + metavar='trunclen' +) +parser.add_argument( + '-f', + '--format', + type=str, + metavar='custom format', + dest='custom_format' +) +parser.add_argument( + '-p', + '--playpause', + type=str, + metavar='play-pause indicator', + dest='play_pause' +) +parser.add_argument( + '--font', + type=str, + metavar='the index of the font to use for the main label', + dest='font' +) +parser.add_argument( + '--playpause-font', + type=str, + metavar='the index of the font to use to display the playpause indicator', + dest='play_pause_font' +) +parser.add_argument( + '-q', + '--quiet', + action='store_true', + help="if set, don't show any output when the current song is paused", + dest='quiet', +) + +args = parser.parse_args() + + +def fix_string(string): + # corrects encoding for the python version used + if sys.version_info.major == 3: + return string + else: + return string.encode('utf-8') + + +def truncate(name, trunclen): + if len(name) > trunclen: + name = name[:trunclen] + name += '...' + if ('(' in name) and (')' not in name): + name += ')' + return name + + + +# Default parameters +output = fix_string(u'{play_pause} {artist}: {song}') +trunclen = 35 +play_pause = fix_string(u'\u25B6,\u23F8') # first character is play, second is paused + +label_with_font = '%{{T{font}}}{label}%{{T-}}' +font = args.font +play_pause_font = args.play_pause_font + +quiet = args.quiet + +# parameters can be overwritten by args +if args.trunclen is not None: + trunclen = args.trunclen +if args.custom_format is not None: + output = args.custom_format +if args.play_pause is not None: + play_pause = args.play_pause + +try: + session_bus = dbus.SessionBus() + spotify_bus = session_bus.get_object( + 'org.mpris.MediaPlayer2.spotify', + '/org/mpris/MediaPlayer2' + ) + + spotify_properties = dbus.Interface( + spotify_bus, + 'org.freedesktop.DBus.Properties' + ) + + metadata = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'Metadata') + status = spotify_properties.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus') + + # Handle play/pause label + + play_pause = play_pause.split(',') + + if status == 'Playing': + play_pause = play_pause[0] + elif status == 'Paused': + play_pause = play_pause[1] + else: + play_pause = str() + + if play_pause_font: + play_pause = label_with_font.format(font=play_pause_font, label=play_pause) + + # Handle main label + + artist = fix_string(metadata['xesam:artist'][0]) if metadata['xesam:artist'] else '' + song = fix_string(metadata['xesam:title']) if metadata['xesam:title'] else '' + album = fix_string(metadata['xesam:album']) if metadata['xesam:album'] else '' + + if (quiet and status == 'Paused') or (not artist and not song and not album): + print('') + else: + if font: + artist = label_with_font.format(font=font, label=artist) + song = label_with_font.format(font=font, label=song) + album = label_with_font.format(font=font, label=album) + + # Add 4 to trunclen to account for status symbol, spaces, and other padding characters + print(truncate(output.format(artist=artist, + song=song, + play_pause=play_pause, + album=album), trunclen + 4)) + +except Exception as e: + if isinstance(e, dbus.exceptions.DBusException): + print('') + else: + print(e)
A config/polybar/scripts/updates-pacman.sh

@@ -0,0 +1,16 @@

+#!/bin/sh +if ! updates_arch=$(checkupdates 2> /dev/null | wc -l ); then + updates_arch=0 +fi + +if ! updates_aur=$(yay -Qum 2> /dev/null | wc -l); then + updates_aur=0 +fi + +updates=$(("$updates_arch" + "$updates_aur")) + +if [ "$updates" -gt 0 ]; then + echo "# $updates" +else + echo "" +fi
A config/redshift.conf

@@ -0,0 +1,16 @@

+[redshift] +temp-day=6500 +temp-night=4000 +transition=1 +brightness-day=1.0 +brightness-night=0.9 +gamma=0.8 +location-provider=manual +adjustment-method=randr + +[manual] +lat=50.807 +lon= 27.3168 + +[randr] +screen=0
A config/rofi/config

@@ -0,0 +1,1 @@

+rofi.theme: solarized
A config/rofi/rofi-power-menu

@@ -0,0 +1,246 @@

+#!/usr/bin/env bash + +# This script defines just a mode for rofi instead of being a self-contained +# executable that launches rofi by itself. This makes it more flexible than +# running rofi inside this script as now the user can call rofi as one pleases. +# For instance: +# +# rofi -show powermenu -modi powermenu:./rofi-power-menu +# +# See README.md for more information. + +set -e +set -u + +# All supported choices +all=(shutdown reboot suspend hibernate logout lockscreen) + +# By default, show all (i.e., just copy the array) +show=("${all[@]}") + +declare -A texts +texts[lockscreen]="lock screen" +texts[switchuser]="switch user" +texts[logout]="log out" +texts[suspend]="suspend" +texts[hibernate]="hibernate" +texts[reboot]="reboot" +texts[shutdown]="shut down" + +declare -A icons +icons[lockscreen]="\uf023" +icons[switchuser]="\uf518" +icons[logout]="\uf842" +icons[suspend]="\uf9b1" +icons[hibernate]="\uf7c9" +icons[reboot]="\ufc07" +icons[shutdown]="\uf011" +icons[cancel]="\u00d7" + +declare -A actions +actions[lockscreen]="loginctl lock-session $XDG_SESSION_ID" +#actions[switchuser]="???" +actions[logout]="loginctl terminate-session $XDG_SESSION_ID" +actions[suspend]="systemctl suspend" +actions[hibernate]="systemctl hibernate" +actions[reboot]="systemctl reboot" +actions[shutdown]="systemctl poweroff" + +# By default, ask for confirmation for actions that are irreversible +confirmations=(reboot shutdown logout) + +# By default, no dry run +dryrun=false +showsymbols=true + +function check_valid { + option="$1" + shift 1 + for entry in "${@}" + do + if [ -z "${actions[$entry]+x}" ] + then + echo "Invalid choice in $1: $entry" >&2 + exit 1 + fi + done +} + +# Parse command-line options +parsed=$(getopt --options=h --longoptions=help,dry-run,confirm:,choices:,choose:,symbols,no-symbols --name "$0" -- "$@") +if [ $? -ne 0 ]; then + echo 'Terminating...' >&2 + exit 1 +fi +eval set -- "$parsed" +unset parsed +while true; do + case "$1" in + "-h"|"--help") + echo "rofi-power-menu - a power menu mode for Rofi" + echo + echo "Usage: rofi-power-menu [--choices CHOICES] [--confirm CHOICES]" + echo " [--choose CHOICE] [--dry-run] [--symbols|--no-symbols]" + echo + echo "Use with Rofi in script mode. For instance, to ask for shutdown or reboot:" + echo + echo " rofi -show menu -modi \"menu:rofi-power-menu --choices=shutdown/reboot\"" + echo + echo "Available options:" + echo " --dry-run Don't perform the selected action but print it to stderr." + echo " --choices CHOICES Show only the selected choices in the given order. Use / " + echo " as the separator. Available choices are lockscreen, logout," + echo " suspend, hibernate, reboot and shutdown. By default, all" + echo " available choices are shown." + echo " --confirm CHOICES Require confirmation for the gives choices only. Use / as" + echo " the separator. Available choices are lockscreen, logout," + echo " suspend, hibernate, reboot and shutdown. By default, only" + echo " irreversible actions logout, reboot and shutdown require" + echo " confirmation." + echo " --choose CHOICE Preselect the given choice and only ask for a confirmation" + echo " (if confirmation is set to be requested). It is strongly" + echo " recommended to combine this option with --confirm=CHOICE" + echo " if the choice wouldn't require confirmation by default." + echo " Available choices are lockscreen, logout, suspend," + echo " hibernate, reboot and shutdown." + echo " --[no-]symbols Show Unicode symbols or not. Requires a font with support" + echo " for the symbols. Use, for instance, fonts from the" + echo " Nerdfonts collection. By default, they are shown" + echo " -h,--help Show this help text." + exit 0 + ;; + "--dry-run") + dryrun=true + shift 1 + ;; + "--confirm") + IFS='/' read -ra confirmations <<< "$2" + check_valid "$1" "${confirmations[@]}" + shift 2 + ;; + "--choices") + IFS='/' read -ra show <<< "$2" + check_valid "$1" "${show[@]}" + shift 2 + ;; + "--choose") + # Check that the choice is valid + check_valid "$1" "$2" + selectionID="$2" + shift 2 + ;; + "--symbols") + showsymbols=true + shift 1 + ;; + "--no-symbols") + showsymbols=false + shift 1 + ;; + "--") + shift + break + ;; + *) + echo "Internal error" >&2 + exit 1 + ;; + esac +done + +# Define the messages after parsing the CLI options so that it is possible to +# configure them in the future. + +function write_message { + icon="<span font_size=\"medium\">$1</span>" + text="<span font_size=\"medium\">$2</span>" + if [ "$showsymbols" = "true" ] + then + echo -n "\u200e$icon \u2068$text\u2069" + else + echo -n "$text" + fi +} + +function print_selection { + echo -e "$1" | $(read -r -d '' entry; echo "echo $entry") +} + +declare -A messages +declare -A confirmationMessages +for entry in "${all[@]}" +do + messages[$entry]=$(write_message "${icons[$entry]}" "${texts[$entry]^}") +done +for entry in "${all[@]}" +do + confirmationMessages[$entry]=$(write_message "${icons[$entry]}" "Yes, ${texts[$entry]}") +done +confirmationMessages[cancel]=$(write_message "${icons[cancel]}" "No, cancel") + +if [ $# -gt 0 ] +then + # If arguments given, use those as the selection + selection="${@}" +else + # Otherwise, use the CLI passed choice if given + if [ -n "${selectionID+x}" ] + then + selection="${messages[$selectionID]}" + fi +fi + +# Don't allow custom entries +echo -e "\0no-custom\x1ftrue" +# Use markup +echo -e "\0markup-rows\x1ftrue" + +if [ -z "${selection+x}" ] +then + echo -e "\0prompt\x1fPower menu" + for entry in "${show[@]}" + do + echo -e "${messages[$entry]}\0icon\x1f${icons[$entry]}" + done +else + for entry in "${show[@]}" + do + if [ "$selection" = "$(print_selection "${messages[$entry]}")" ] + then + # Check if the selected entry is listed in confirmation requirements + for confirmation in "${confirmations[@]}" + do + if [ "$entry" = "$confirmation" ] + then + # Ask for confirmation + echo -e "\0prompt\x1fAre you sure" + echo -e "${confirmationMessages[$entry]}\0icon\x1f${icons[$entry]}" + echo -e "${confirmationMessages[cancel]}\0icon\x1f${icons[cancel]}" + exit 0 + fi + done + # If not, then no confirmation is required, so mark confirmed + selection=$(print_selection "${confirmationMessages[$entry]}") + fi + if [ "$selection" = "$(print_selection "${confirmationMessages[$entry]}")" ] + then + if [ $dryrun = true ] + then + # Tell what would have been done + echo "Selected: $entry" >&2 + else + # Perform the action + ${actions[$entry]} + fi + exit 0 + fi + if [ "$selection" = "$(print_selection "${confirmationMessages[cancel]}")" ] + then + # Do nothing + exit 0 + fi + done + # The selection didn't match anything, so raise an error + echo "Invalid selection: $selection" >&2 + exit 1 +fi
A config/rofi/solarized.rasi

@@ -0,0 +1,136 @@

+* { + selected-normal-foreground: rgba ( 129, 147, 150, 100 % ); + foreground: rgba ( 129, 147, 150, 100 % ); + normal-foreground: @foreground; + alternate-normal-background: rgba ( 0, 43, 55, 100 % ); + red: rgba ( 220, 50, 47, 100 % ); + selected-urgent-foreground: rgba ( 218, 66, 129, 100 % ); + blue: rgba ( 38, 139, 210, 100 % ); + urgent-foreground: rgba ( 218, 66, 129, 100 % ); + alternate-urgent-background: rgba ( 0, 43, 55, 100 % ); + active-foreground: rgba ( 0, 142, 212, 100 % ); + lightbg: rgba ( 238, 232, 213, 100 % ); + selected-active-foreground: rgba ( 0, 142, 212, 100 % ); + alternate-active-background: rgba ( 0, 43, 55, 100 % ); + background: rgba ( 0, 43, 55, 100 % ); + bordercolor: rgba ( 0, 43, 55, 100 % ); + alternate-normal-foreground: @foreground; + normal-background: rgba ( 0, 43, 55, 100 % ); + lightfg: rgba ( 88, 104, 117, 100 % ); + selected-normal-background: rgba ( 0, 54, 66, 100 % ); + border-color: @foreground; + spacing: 2; + separatorcolor: rgba ( 0, 54, 66, 100 % ); + urgent-background: rgba ( 0, 43, 55, 100 % ); + selected-urgent-background: rgba ( 0, 54, 66, 100 % ); + alternate-urgent-foreground: @urgent-foreground; + background-color: rgba ( 0, 0, 0, 0 % ); + alternate-active-foreground: @active-foreground; + active-background: rgba ( 0, 43, 55, 100 % ); + selected-active-background: rgba ( 0, 54, 66, 100 % ); +} +#window { + background-color: @background; + border: 1; + padding: 5; +} +#mainbox { + border: 0; + padding: 0; +} +#message { + border: 1px dash 0px 0px ; + border-color: @separatorcolor; + padding: 1px ; +} +#textbox { + text-color: @foreground; +} +#listview { + fixed-height: 0; + border: 2px dash 0px 0px ; + border-color: @separatorcolor; + spacing: 2px ; + scrollbar: true; + padding: 2px 0px 0px ; +} +#element { + border: 0; + padding: 1px ; +} +#element.normal.normal { + background-color: @normal-background; + text-color: @normal-foreground; +} +#element.normal.urgent { + background-color: @urgent-background; + text-color: @urgent-foreground; +} +#element.normal.active { + background-color: @active-background; + text-color: @active-foreground; +} +#element.selected.normal { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +#element.selected.urgent { + background-color: @selected-urgent-background; + text-color: @selected-urgent-foreground; +} +#element.selected.active { + background-color: @selected-active-background; + text-color: @selected-active-foreground; +} +#element.alternate.normal { + background-color: @alternate-normal-background; + text-color: @alternate-normal-foreground; +} +#element.alternate.urgent { + background-color: @alternate-urgent-background; + text-color: @alternate-urgent-foreground; +} +#element.alternate.active { + background-color: @alternate-active-background; + text-color: @alternate-active-foreground; +} +#scrollbar { + width: 4px ; + border: 0; + handle-width: 8px ; + padding: 0; +} +#mode-switcher { + border: 2px dash 0px 0px ; + border-color: @separatorcolor; +} +#button.selected { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +#inputbar { + spacing: 0; + text-color: @normal-foreground; + padding: 1px ; +} +#case-indicator { + spacing: 0; + text-color: @normal-foreground; +} +#entry { + spacing: 0; + text-color: @normal-foreground; +} +#prompt { + spacing: 0; + text-color: @normal-foreground; +} +#inputbar { + children: [ prompt,textbox-prompt-colon,entry,case-indicator ]; +} +#textbox-prompt-colon { + expand: false; + str: ":"; + margin: 0px 0.3em 0em 0em ; + text-color: @normal-foreground; +}