From 2bef034a14cb5c67572b4b2d0ffb583de9dce616 Mon Sep 17 00:00:00 2001 From: killajoe Date: Sat, 20 Nov 2021 20:24:37 +0100 Subject: [PATCH] cleanup and updating scripts --- .config/i3/config | 53 +++---- .config/i3/i3blocks.conf | 32 ++-- ...y-pinebook-pro.sh => battery-pinebook-pro} | 0 .config/i3/scripts/{battery.sh => battery1} | 0 .config/i3/scripts/battery2 | 106 ++++++++++++++ .../i3/scripts/{blur-lock.sh => blur-lock} | 0 .../{empty_workspace.sh => empty_workspace} | 0 .../{keyboard-switch.sh => keyboard-switch} | 0 .config/i3/scripts/{keyhint.sh => keyhint} | 0 .config/i3/scripts/keyhint-2 | 6 + .../scripts/{openweather.sh => openweather} | 0 .config/i3/scripts/openweather.conf | 5 +- .config/rofi/rofikeyhint.rasi | 137 ++++++++++++++++++ 13 files changed, 294 insertions(+), 45 deletions(-) rename .config/i3/scripts/{battery-pinebook-pro.sh => battery-pinebook-pro} (100%) rename .config/i3/scripts/{battery.sh => battery1} (100%) create mode 100644 .config/i3/scripts/battery2 rename .config/i3/scripts/{blur-lock.sh => blur-lock} (100%) rename .config/i3/scripts/{empty_workspace.sh => empty_workspace} (100%) rename .config/i3/scripts/{keyboard-switch.sh => keyboard-switch} (100%) rename .config/i3/scripts/{keyhint.sh => keyhint} (100%) create mode 100755 .config/i3/scripts/keyhint-2 rename .config/i3/scripts/{openweather.sh => openweather} (100%) create mode 100644 .config/rofi/rofikeyhint.rasi diff --git a/.config/i3/config b/.config/i3/config index 029bcb2..7cb5b38 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -3,7 +3,7 @@ exec --no-startup-id ~/set_once.sh # This file is a modified version based on default i3-config-wizard config # source is available here: # https://raw.githubusercontent.com/endeavouros-team/endeavouros-i3wm-setup/master/.config/i3/config -# Maintainer: joekamprad [joekamprad@endeavouros.com] +# Maintainer: joekamprad [joekamprad@endeavouros.com] # https://endeavouros.com # # iconic font icon search: https://fontawesome.com/v4.7/cheatsheet/ @@ -48,7 +48,7 @@ workspace_layout default # extra options for windows: # ############################## -#border indicator on windows: +#border indicator on windows: new_window pixel 1 # thin borders @@ -179,16 +179,19 @@ bindsym $mod+Shift+e exec ~/.config/i3/scripts/powermenu # lock with a picture: #bindsym $mod+l exec i3lock -i ~/.config/i3/i3-lock-screen.png -p default|win -t # lock by blurring the screen: -bindsym $mod+l exec ~/.config/i3/scripts/blur-lock.sh +bindsym $mod+l exec ~/.config/i3/scripts/blur-lock # reload the configuration file bindsym $mod+Shift+c reload -# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +# restart i3 inplace (preserves your layout/session, can be used to update i3) bindsym $mod+Shift+r restart +# keybinding in fancy rofi (automated): +bindsym F1 exec ~/.config/i3/scripts/keyhint-2 +# alternative # keybinding list in editor: -bindsym $mod+F1 exec xed ~/.config/i3/keybindings +# bindsym $mod+F1 exec xed ~/.config/i3/keybindings # Backlight control bindsym XF86MonBrightnessUp exec xbacklight +10 @@ -242,7 +245,7 @@ bindsym $mod+space focus mode_toggle bindsym $mod+a focus parent # open new empty workspace -bindsym $mod+Shift+n exec ~/.config/i3/scripts/empty_workspace.sh +bindsym $mod+Shift+n exec ~/.config/i3/scripts/empty_workspace ## Multimedia Keys @@ -300,7 +303,7 @@ set $ws9 "9" set $ws10 "10" # use workspaces on different displays: -# where you have to replace VGA-0/HDMI-0 with the names for your displays +# where you have to replace VGA-0/HDMI-0 with the names for your displays # you can get from xrandr command #workspace $ws1 output VGA-0 #workspace $ws2 output VGA-0 @@ -331,7 +334,7 @@ for_window [class=TelegramDesktop] focus exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 # dex execute .desktop files -# keep in mind that it can cause issues +# keep in mind that it can cause issues # when second to i3 a DE is installed or mixed usage of i3 + xfce4 or GNOME # in this cases better disable dex and use manual starting apps using xdg/autostart #exec --no-startup-id dex -a -s /etc/xdg/autostart/:~/.config/autostart/ @@ -341,7 +344,7 @@ exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 # configure multiple keyboard layouts and hotkey to switch (Alt+CAPSLOCK in this example) #exec --no-startup-id setxkbmap -layout 'us,sk' -variant altgr-intl,qwerty -option 'grp:alt_caps_toggle' -# start conky: +# start conky: #exec_always --no-startup-id conky # start a script to setup displays @@ -351,7 +354,7 @@ exec --no-startup-id ~/.screenlayout/monitor.sh # start blueberry app for managing bluetooth devices from tray: exec --no-startup-id blueberry-tray -# transparency +# transparency # uncomment one of them to be used (picom package is installed per default) # options could need changes, related to used GPU and drivers. # to find the right setting consult the archwiki or ask at the forum. @@ -397,8 +400,8 @@ for_window [class="Pamac-manager"] floating enable ###################################### # color settings for bar and windows # ###################################### - -# Define colors variables: + +# Define colors variables: set $darkbluetrans #08052be6 set $darkblue #08052b set $lightblue #5294e2 @@ -423,20 +426,20 @@ client.urgent $urgentred $urgentred $white $purple $yellowbrown # bar settings (input comes from i3blocks) # ############################################ -# Start i3bar to display a workspace bar +# Start i3bar to display a workspace bar # (plus the system information i3status finds out, if available) bar { font pango:Noto Sans Regular 10, FontAwesome 10 status_command i3blocks -c ~/.config/i3/i3blocks.conf - position bottom + position bottom # i3bar_command i3bar --transparency # it could be that you have no primary display set: set one (xrandr --output --primary) # reference: https://i3wm.org/docs/userguide.html#_tray_output tray_output primary tray_padding 0 -# When strip_workspace_numbers is set to yes, -# any workspace that has a name of the form +# When strip_workspace_numbers is set to yes, +# any workspace that has a name of the form # “[n][:][NAME]” will display only the name. strip_workspace_numbers yes ##strip_workspace_name no @@ -449,7 +452,7 @@ strip_workspace_numbers yes focused_workspace $mediumgrey $grey $darkgrey $purple active_workspace $lightblue $mediumgrey $darkgrey $purple inactive_workspace $darkgrey $darkgrey $grey $purple - urgent_workspace $urgentred $urgentred $white $purple + urgent_workspace $urgentred $urgentred $white $purple } } @@ -459,15 +462,15 @@ strip_workspace_numbers yes # https://gist.github.com/lopspower/03fb1cc0ac9f32ef38f4 # #08052be6 --> e6=90% -# bar { +# bar { # font pango:Noto Sans Regular 9, FontAwesome 9 # status_command i3blocks -c ~/.config/i3/i3blocks-2.conf # i3bar_command i3bar --transparency # output HDMI-0 # position bottom # -# When strip_workspace_numbers is set to yes, -# any workspace that has a name of the form +# When strip_workspace_numbers is set to yes, +# any workspace that has a name of the form # “[n][:][NAME]” will display only the name. #strip_workspace_numbers yes ##strip_workspace_name no @@ -480,7 +483,7 @@ strip_workspace_numbers yes # focused_workspace $lighterblue $lighterblue $darkblue $purple # active_workspace $lightdblue $lightdblue $darkblue $purple # inactive_workspace $darkblue $darkblue $lightdblue $purple -# urgent_workspace $urgentred $urgentred $white $purple +# urgent_workspace $urgentred $urgentred $white $purple # } #} @@ -492,14 +495,14 @@ strip_workspace_numbers yes bindsym $mod+d exec rofi -modi drun -show drun \ -config ~/.config/rofi/rofidmenu.rasi - + #bindsym F9 exec rofi -modi drun -show drun \ # -config ~/.config/rofi/rofidmenu.rasi - + ## rofi bindings for window menu ($mod+t /F10 optional disabled) bindsym $mod+t exec rofi -show window \ - -config ~/.config/rofi/rofidmenu.rasi + -config ~/.config/rofi/rofidmenu.rasi #bindsym F10 exec rofi -show window \ -# -config ~/.config/rofi/rofidmenu.rasi +# -config ~/.config/rofi/rofidmenu.rasi diff --git a/.config/i3/i3blocks.conf b/.config/i3/i3blocks.conf index bf39a4e..a271838 100644 --- a/.config/i3/i3blocks.conf +++ b/.config/i3/i3blocks.conf @@ -70,7 +70,7 @@ color=#717171 # The script may be called with a optional argument to set the alert # (defaults to 10 for 10%). [disk] -label= +label= instance=/ command=~/.config/i3/scripts/disk interval=30 @@ -79,12 +79,12 @@ interval=30 # # The type defaults to "mem" if the instance is not specified. [memory] -label= +label= command=~/.config/i3/scripts/memory interval=2 [cpu_usage] -label= +label= command=~/.config/i3/scripts/cpu_usage #min_width=CPU: 100.00% interval=2 @@ -110,13 +110,11 @@ command=~/.config/i3/scripts/bandwidth2 interval=persist # Battery indicator -# -# The battery instance defaults to 0. [battery] -command=~/.config/i3/scripts/battery.sh -# change this to battery-pinebook-pro.sh if you are running on pinebook-pro -label= -#instance=1 +command=~/.config/i3/scripts/battery2 +# for alternative battery script change to battery1 +# change this to battery-pinebook-pro if you are running on pinebook-pro +label= interval=30 [simple-2] @@ -132,22 +130,24 @@ command=~/.config/i3/scripts/volume instance=Master interval=1 -[keybindings] -full_text= -command=~/.config/i3/scripts/keyhint.sh - # display keyboard layout name +# for keyboard layouts switcher +# see i3 config file #[keyboard-layout] -#command=~/.config/i3/scripts/keyboard-layout.sh +#command=~/.config/i3/scripts/keyboard-layout #interval=2 +[keybindings] +full_text= +command=~/.config/i3/scripts/keyhint + [time] -#label= +#label= command=date '+%a %d %b %H:%M:%S' interval=1 [shutdown_menu] -full_text= +full_text= command=~/.config/i3/scripts/powermenu [simple-2] diff --git a/.config/i3/scripts/battery-pinebook-pro.sh b/.config/i3/scripts/battery-pinebook-pro similarity index 100% rename from .config/i3/scripts/battery-pinebook-pro.sh rename to .config/i3/scripts/battery-pinebook-pro diff --git a/.config/i3/scripts/battery.sh b/.config/i3/scripts/battery1 similarity index 100% rename from .config/i3/scripts/battery.sh rename to .config/i3/scripts/battery1 diff --git a/.config/i3/scripts/battery2 b/.config/i3/scripts/battery2 new file mode 100644 index 0000000..2d55dab --- /dev/null +++ b/.config/i3/scripts/battery2 @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2016 James Murphy +# Licensed under the GPL version 2 only +# +# A battery indicator blocklet script for i3blocks + +from subprocess import check_output +import os +import re + +config = dict(os.environ) +status = check_output(['acpi'], universal_newlines=True) + +if not status: + # stands for no battery found + color = config.get("color_10", "red") + fulltext = "\uf00d \uf240".format(color) + percentleft = 100 +else: + # if there is more than one battery in one laptop, the percentage left is + # available for each battery separately, although state and remaining + # time for overall block is shown in the status of the first battery + batteries = status.split("\n") + state_batteries=[] + commasplitstatus_batteries=[] + percentleft_batteries=[] + time = "" + for battery in batteries: + if battery!='': + state_batteries.append(battery.split(": ")[1].split(", ")[0]) + commasplitstatus = battery.split(", ") + if not time: + time = commasplitstatus[-1].strip() + # check if it matches a time + time = re.match(r"(\d+):(\d+)", time) + if time: + time = ":".join(time.groups()) + timeleft = " ({})".format(time) + else: + timeleft = "" + + p = int(commasplitstatus[1].rstrip("%\n")) + if p>0: + percentleft_batteries.append(p) + commasplitstatus_batteries.append(commasplitstatus) + state = state_batteries[0] + commasplitstatus = commasplitstatus_batteries[0] + if percentleft_batteries: + percentleft = int(sum(percentleft_batteries)/len(percentleft_batteries)) + else: + percentleft = 0 + + # stands for charging + color = config.get("color_charging", "yellow") + FA_LIGHTNING = "\uf0e7".format(color) + + # stands for plugged in + FA_PLUG = "\uf1e6" + + # stands for using battery + FA_BATTERY = "\uf240" + + # stands for unknown status of battery + FA_QUESTION = "\uf128" + + + if state == "Discharging": + fulltext = FA_BATTERY + " " + elif state == "Full": + fulltext = FA_PLUG + " " + timeleft = "" + elif state == "Unknown": + fulltext = FA_QUESTION + " " + FA_BATTERY + " " + timeleft = "" + else: + fulltext = FA_LIGHTNING + " " + FA_PLUG + " " + + def color(percent): + if percent < 10: + # exit code 33 will turn background red + return config.get("color_10", "#FFFFFF") + if percent < 20: + return config.get("color_20", "#FF3300") + if percent < 30: + return config.get("color_30", "#FF6600") + if percent < 40: + return config.get("color_40", "#FF9900") + if percent < 50: + return config.get("color_50", "#FFCC00") + if percent < 60: + return config.get("color_60", "#FFFF00") + if percent < 70: + return config.get("color_70", "#FFFF33") + if percent < 80: + return config.get("color_80", "#FFFF66") + return config.get("color_full", "#FFFFFF") + + form = '{}%' + fulltext += form.format(color(percentleft), percentleft) + #fulltext += timeleft + +print(fulltext) +print(fulltext) +if percentleft < 10: + exit(33) diff --git a/.config/i3/scripts/blur-lock.sh b/.config/i3/scripts/blur-lock similarity index 100% rename from .config/i3/scripts/blur-lock.sh rename to .config/i3/scripts/blur-lock diff --git a/.config/i3/scripts/empty_workspace.sh b/.config/i3/scripts/empty_workspace similarity index 100% rename from .config/i3/scripts/empty_workspace.sh rename to .config/i3/scripts/empty_workspace diff --git a/.config/i3/scripts/keyboard-switch.sh b/.config/i3/scripts/keyboard-switch similarity index 100% rename from .config/i3/scripts/keyboard-switch.sh rename to .config/i3/scripts/keyboard-switch diff --git a/.config/i3/scripts/keyhint.sh b/.config/i3/scripts/keyhint similarity index 100% rename from .config/i3/scripts/keyhint.sh rename to .config/i3/scripts/keyhint diff --git a/.config/i3/scripts/keyhint-2 b/.config/i3/scripts/keyhint-2 new file mode 100755 index 0000000..2e86d12 --- /dev/null +++ b/.config/i3/scripts/keyhint-2 @@ -0,0 +1,6 @@ +I3_CONFIG=$HOME/.config/i3/config +mod_key=$(sed -nre 's/^set \$mod (.*)/\1/p' ${I3_CONFIG}) +grep "^bindsym" ${I3_CONFIG} \ + | sed "s/-\(-\w\+\)\+//g;s/\$mod/${mod_key}/g;s/Mod1/Alt/g;s/exec //;s/bindsym //;s/^\s\+//;s/^\([^ ]\+\) \(.\+\)$/\2: \1/;s/^\s\+//" \ + | tr -s ' ' \ + | rofi -dmenu -theme ~/.config/rofi/rofikeyhint.rasi diff --git a/.config/i3/scripts/openweather.sh b/.config/i3/scripts/openweather similarity index 100% rename from .config/i3/scripts/openweather.sh rename to .config/i3/scripts/openweather diff --git a/.config/i3/scripts/openweather.conf b/.config/i3/scripts/openweather.conf index 5d5d2e2..f11aa86 100644 --- a/.config/i3/scripts/openweather.conf +++ b/.config/i3/scripts/openweather.conf @@ -1,8 +1,5 @@ # Weather [Weather] -command=~/.config/i3/scripts/openweather.sh +command=~/.config/i3/scripts/openweather interval=1800 color=#7275b3 - - - diff --git a/.config/rofi/rofikeyhint.rasi b/.config/rofi/rofikeyhint.rasi new file mode 100644 index 0000000..6db955c --- /dev/null +++ b/.config/rofi/rofikeyhint.rasi @@ -0,0 +1,137 @@ +/******************************************************* + * ROFI configs i3 Apps menu for EndeavourOS + * Maintainer: joekamprad + *******************************************************/ +configuration { + font: "Sourcecode Pro Regular 10"; + show-icons: false; + icon-theme: "Arc-X-D"; + display-drun: "KeyHint"; + drun-display-format: "{name}"; + scroll-method: 0; + disable-history: false; + fullscreen: false; + hide-scrollbar: true; + sidebar-mode: false; +} + +@import "~/.config/rofi/arc_dark_colors.rasi" + +window { + background-color: @background; + border: 0; + padding: 30; +} +listview { + lines: 10; + columns: 1; +} +mainbox { + border: 0; + padding: 0; +} +message { + border: 2px 0px 0px ; + border-color: @separatorcolor; + padding: 1px ; +} +textbox { + text-color: @foreground; +} +listview { + fixed-height: 0; + border: 8px 0px 0px ; + border-color: @separatorcolor; + spacing: 8px ; + scrollbar: false; + padding: 2px 0px 0px ; +} +element { + border: 0; + padding: 1px ; +} +element-text { + background-color: inherit; + text-color: inherit; +} +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-color: @normal-foreground; + handle-width: 8px ; + padding: 0; +} +mode-switcher { + border: 2px 0px 0px ; + border-color: @separatorcolor; +} +button { + spacing: 0; + text-color: @normal-foreground; +} +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; +}