diff --git a/.config/rofi/config.rasi b/.config/rofi/config.rasi index 8c73a8c..d2f168b 100644 --- a/.config/rofi/config.rasi +++ b/.config/rofi/config.rasi @@ -19,8 +19,9 @@ configuration { kb-row-down: "Down,Control+j"; kb-accept-entry: "Control+m,Return,KP_Enter"; kb-remove-to-eol: "Control+Shift+e"; - /*kb-mode-next: "Shift+Right,Control+Tab,Control+l";*/ + kb-mode-next: "Shift+Right,Control+Tab,Control+l"; kb-mode-previous: "Shift+Left,Control+Shift+Tab,Control+h"; + kb-mode-complete: "Control+Shift+space"; kb-remove-char-back: "BackSpace"; } diff --git a/.config/rofi/scripts/calendar.sh b/.config/rofi/scripts/calendar.sh new file mode 100755 index 0000000..602f055 --- /dev/null +++ b/.config/rofi/scripts/calendar.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +DIR=$(dirname $PWD) + +current_day=$(date +"%e") +current_month=$(date +"%m") +current_year=$(date +"%Y") + +month=$(date +"%-m") +year=$(date +"%Y") +previous_month="◀" +next_month="▶" +last_selected_option="" + +format_calendar () { + echo "$1" \ + | sed -E 's/([[:alpha:]])__/\1\n/g' \ + | sed -E 's/___([[:digit:]])/.\n\1/g' \ + | sed -e 's/___/\n./g' \ + | sed -e 's/__/\n/g' \ + | sed -e 's/_/\n/g' +} + +print_month() { + calendar="$(cal -v -- $1 $2 | tail -n +2 | sed -e 's/ /_/g')" + echo "$(format_calendar "$calendar")" +} + +find_day_index() { + index=0 + while IFS=' ' read -ra arr; do + for i in "${arr[@]}"; do + if [[ "$i" == "$2" ]]; then + echo "$index" + break + fi + ((index++)) + done + done <<< "$1" +} + +calendar_menu() { + calendar_header=$(cal -v -- $month $year | head -n 1) + + month_page="$(print_month $month $year)" + calendar_body="\n\n\n$previous_month\n\n\n\n$month_page\n\n\n\n$next_month\n\n\n" + + previous_month_index="3" + next_month_index="59" + calendar_body_column="7" + urgent="-u $previous_month_index,$next_month_index" + active="" + selected_row="" + + if [[ "$(echo $current_month | bc) $current_year" == "$(echo $month | bc) $year" ]]; then + current_day_index=$(($(find_day_index "$month_page" $current_day) + $calendar_body_column)) + active="-a $current_day_index" + selected_row="-selected-row $current_day_index" + fi + + if [[ $last_selected_option == $previous_month ]]; then + selected_row="-selected-row $previous_month_index" + fi + + if [[ $last_selected_option == $next_month ]]; then + selected_row="-selected-row $next_month_index" + fi + + echo -e "$calendar_body" | rofi -dmenu \ + -theme $HOME/.config/rofi/themes/calendar.rasi \ + -p "$calendar_header" $urgent $active $selected_row \ + -monitor -1 +} + +while [[ true ]]; do + selected=$(calendar_menu) + last_selected_option="$selected" + case $selected in + $previous_month) + ((month--)) + if [[ $month -lt 1 ]]; then + month=12 + ((year--)) + fi + ;; + $next_month) + ((month++)) + if [[ $month -gt 12 ]]; then + month=1 + ((year++)) + fi + ;; + *) + break + ;; + esac +done diff --git a/.config/rofi/scripts/copyq.py b/.config/rofi/scripts/copyq.py new file mode 100755 index 0000000..9351cc8 --- /dev/null +++ b/.config/rofi/scripts/copyq.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 + +import json +import sys +import subprocess as sp + +copyq_script_getAll = r""" +var result=[]; +for ( var i = 0; i < size(); ++i ) { + var obj = {}; + obj.row = i; + obj.mimetypes = str(read("?", i)).split("\n"); + obj.mimetypes.pop(); + obj.text = str(read(i)); + result.push(obj); +} +JSON.stringify(result); +""" + +if __name__ == '__main__': + if (len(sys.argv) > 2): + num = sys.argv[2].split(" - ")[0] + sp.run(f'copyq select({num});'.split(), + encoding='utf-8', stdout=sp.PIPE, stderr=sp.PIPE) + else: + p = sp.run('copyq -'.split(), input=copyq_script_getAll, + encoding='utf-8', stdout=sp.PIPE, stderr=sp.PIPE) + json_arr = json.loads(p.stdout) + + num = 0 + items = [] + for json_obj in json_arr: + text = json_obj['text'] + text = " ".join(filter(None, text.replace("\n", " ").split(" "))) + items.append(str(num) + " - " + text) + num += 1 + + print('\n'.join(x for x in items)) diff --git a/.config/rofi/themes/calendar.rasi b/.config/rofi/themes/calendar.rasi new file mode 100644 index 0000000..19f0767 --- /dev/null +++ b/.config/rofi/themes/calendar.rasi @@ -0,0 +1,152 @@ +configuration { + font: "Iosevka 12"; + show-icons: false; + icon-theme: "Papirus"; + display-drun: ":"; + drun-display-format: "{name}"; + threads: 0; + scroll-method: 0; + disable-history: false; + fullscreen: false; + hide-scrollbar: true; + sidebar-mode: false; +} + +@import "colors.rasi" + +window { + transparency: "real"; + background-color: @background; + text-color: @foreground; + border: 1px; + border-radius: 0px; + border-color: @selected; + width: 384px; + location: center; + anchor: center; + x-offset: 0; + y-offset: 0; +} + +prompt { + enabled: true; + padding: 4px 4px 6px 6px; + background-color: @background; + text-color: @foreground; +} + +textbox-prompt-colon { + expand: false; + str: ""; + background-color: @background; + text-color: @urgent; + padding: 5px 0px 0px 4px; + font: "feather 10"; +} + +inputbar { + children: [ textbox-prompt-colon, prompt ]; + background-color: @background; + text-color: @foreground; + expand: false; + border: 0px 0px 1px 0px; + border-radius: 0px; + border-color: @selected; + margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; + position: center; +} + + +entry { + background-color: @background; + text-color: @foreground; + placeholder-color: @foreground; + expand: true; + horizontal-align: 0; + placeholder: "Search"; + blink: true; + padding: 4px 0px 0px 0px; +} + +case-indicator { + background-color: @background; + text-color: @foreground; + spacing: 0; +} + + +listview { + background-color: @background; + columns: 9; + lines: 7; + spacing: 5px; + cycle: true; + dynamic: true; + layout: vertical; +} + +mainbox { + background-color: @background; + children: [ inputbar, listview ]; + spacing: 5px; + padding: 5px 5px 5px 5px; +} + +element { + background-color: @background; + text-color: @foreground; + orientation: horizontal; + border: 0px; + border-radius: 0px; + border-color: @selected; + padding: 5px 5px 5px 5px; +} + +element-icon { + size: 24px; + border: 0px; +} + +element-text { + font: "Iosevka 12"; + expand: true; + horizontal-align: 0; + vertical-align: 0; + margin: 2px 0px 2px 2px; +} + +element selected { + background-color: @selected; + text-color: @background; + border: 0px; + border-radius: 0px; + border-color: @selected; +} + +element.active, +element.selected.urgent { + background-color: @on; + text-color: @background; + border-color: @on; +} + +element.selected.urgent { + border-color: @urgent; +} + +element.urgent, +element.selected.active { + background-color: @off; + text-color: @background; + border-color: @off; +} + +element.selected.active { + border-color: @selected; +} + +element-text, element-icon { + background-color: inherit; + text-color: inherit; +} diff --git a/.config/rofi/themes/colors.rasi b/.config/rofi/themes/colors.rasi new file mode 100644 index 0000000..5d378cf --- /dev/null +++ b/.config/rofi/themes/colors.rasi @@ -0,0 +1,8 @@ +* { + background: #232A2E; + foreground: #83C092; + selected: #A7C080; + urgent: #E67E80; + on: #7FBBB3; + off: #48584E; +} diff --git a/.config/sxhkd/sxhkdrc b/.config/sxhkd/sxhkdrc index 12aff52..a77a513 100644 --- a/.config/sxhkd/sxhkdrc +++ b/.config/sxhkd/sxhkdrc @@ -22,6 +22,10 @@ super + n super + c rofi -modi "clipboard:~/.config/rofi/scripts/copyq.py print,calc" -show clipboard -no-show-match -no-sort -calc-command "echo -n '{result}' | xclip -selection clipboard" +# calendar +super + shift + c + ~/.config/rofi/scripts/calendar.sh + # power menu super + p rofi -show p -modi p:'~/.config/rofi/scripts/rofi-power-menu --symbols-font "JetBrainsMonoNL Nerd Font Mono"' -font "JetBrainsMonoNL Nerd Font Mono" -monitor -1