├── .gitignore ├── LICENSE ├── README.md ├── configs-arch ├── t2ec-top-icons.tint2rc └── t2ec-top-text.tint2rc ├── configs-void ├── t2ec-sample-top-icons.tint2rc └── t2ec-sample-top-text.tint2rc ├── images ├── arch-icon-notify.svg ├── arch-icon.svg ├── arch-update48.svg ├── bat-empty-charging.svg ├── bat-empty.svg ├── bat-full-charging.svg ├── bat-full.svg ├── bat-half-charging.svg ├── bat-half.svg ├── bat-quarter-charging.svg ├── bat-quarter.svg ├── bat-threefourth-charging.svg ├── bat-threefourth.svg ├── bri-full.svg ├── bri-high.svg ├── bri-low.svg ├── bri-medium.svg ├── desktop.svg ├── network.svg ├── no-bumblebee.svg ├── nvidia-off.svg ├── nvidia.svg ├── ow-01d.svg ├── ow-01n.svg ├── ow-02d.svg ├── ow-02n.svg ├── ow-03d.svg ├── ow-04d.svg ├── ow-09d.svg ├── ow-10d.svg ├── ow-10n.svg ├── ow-11d.svg ├── ow-13d.svg ├── ow-50d.svg ├── refresh.svg ├── void-update-notify.svg ├── void-update.svg ├── vol-full.svg ├── vol-low.svg ├── vol-lowest.svg ├── vol-medium.svg └── vol-muted.svg ├── scripts-arch ├── arch-update.py ├── battery-icon.sh ├── bbswitch-status-temp.sh ├── brightness-icon-light.sh ├── brightness-icon.sh ├── desktop.py ├── help.sh ├── menu-template.sh ├── menu-update.sh ├── menus.sh ├── pa-jgmenu.py ├── pa-switch-output.sh ├── t2ec ├── volume-icon.sh ├── weather.py ├── wifi-name.sh └── zenity-box.sh └── scripts-void ├── battery-icon.sh ├── bbswitch-status-temp.sh ├── brightness-icon-light.sh ├── brightness-icon.sh ├── desktop.py ├── help.sh ├── menu-template.sh ├── menu-update.sh ├── menus.sh ├── pa-jgmenu.py ├── pa-switch-output.sh ├── t2ec.sh ├── void-update.py ├── volume-icon.sh ├── weather.py └── wifi-name.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea -------------------------------------------------------------------------------- /images/arch-icon-notify.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 140 | 142 | 143 | 145 | image/svg+xml 146 | 148 | 149 | 150 | 151 | 152 | 157 | 160 | 163 | 166 | 171 | 177 | 178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /images/arch-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 140 | 142 | 143 | 145 | image/svg+xml 146 | 148 | 149 | 150 | 151 | 156 | 159 | 162 | 166 | 171 | 172 | 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /images/arch-update48.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 140 | 142 | 143 | 145 | image/svg+xml 146 | 148 | 149 | 150 | 151 | 152 | 157 | 160 | 163 | 166 | 171 | 177 | 178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /images/bat-empty-charging.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-empty.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-full-charging.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-full.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-half-charging.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-half.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-quarter-charging.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-quarter.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-threefourth-charging.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/bat-threefourth.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 159 | 160 | 162 | 163 | 165 | image/svg+xml 166 | 168 | 169 | 170 | 171 | 172 | 177 | 180 | 183 | 188 | 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /images/desktop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /images/network.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /images/no-bumblebee.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 62 | 66 | 71 | 76 | 81 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /images/nvidia-off.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 62 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /images/nvidia.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 62 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /images/ow-01d.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /images/ow-01n.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 61 | 66 | 72 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /images/ow-03d.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /images/ow-04d.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 21 | 40 | 42 | 43 | 45 | image/svg+xml 46 | 48 | 49 | 50 | 51 | 52 | 57 | 61 | 68 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /images/refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 140 | 142 | 143 | 145 | image/svg+xml 146 | 148 | 149 | 150 | 151 | 152 | 157 | 160 | 163 | 167 | 172 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /images/void-update-notify.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 21 | 23 | image/svg+xml 24 | 26 | 27 | 28 | 29 | 30 | 32 | 52 | 56 | 61 | 66 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /images/void-update.svg: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 21 | 23 | image/svg+xml 24 | 26 | 27 | 28 | 29 | 30 | 32 | 52 | 56 | 61 | 66 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /images/vol-low.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 153 | 155 | 156 | 158 | image/svg+xml 159 | 161 | 162 | 163 | 164 | 165 | 170 | 173 | 176 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /images/vol-lowest.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 153 | 155 | 156 | 158 | image/svg+xml 159 | 161 | 162 | 163 | 164 | 165 | 170 | 173 | 176 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /images/vol-medium.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 153 | 155 | 156 | 158 | image/svg+xml 159 | 161 | 162 | 163 | 164 | 165 | 170 | 173 | 176 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /images/vol-muted.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 26 | 34 | 38 | 42 | 46 | 50 | 54 | 55 | 57 | 61 | 65 | 66 | 69 | 73 | 77 | 78 | 87 | 90 | 94 | 98 | 99 | 108 | 118 | 119 | 142 | 147 | 152 | 153 | 155 | 156 | 158 | image/svg+xml 159 | 161 | 162 | 163 | 164 | 165 | 170 | 173 | 176 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /scripts-arch/arch-update.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # _*_ coding: utf-8 _*_ 3 | 4 | """ 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Credits: RaphaelRochet/arch-update 12 | # https://github.com/RaphaelRochet/arch-update 13 | # Icon by @edskeye 14 | 15 | Arguments [-C] | [-U ] | [menu] | -[O] [-N] | [-M] 16 | 17 | [-C] - check updates 18 | [-U,] - your AUR helper name 19 | [-O] - show pending updates as notification 20 | [-N] - name instead of icon 21 | [menu] - show context jgmenu 22 | 23 | Dependencies: `pacman-contrib` 24 | Optional: `pacaur` | `trizen` | `yay`, `jgmenu` 25 | """ 26 | 27 | import sys 28 | import os 29 | import subprocess 30 | 31 | 32 | def main(): 33 | name = None 34 | helper_name, terminal_name, helper_cmd, updates = "", "", "", "" 35 | do_check, do_update, do_notify = False, False, False 36 | 37 | tmp_file = os.getenv("HOME") + "/.arch-updates" 38 | 39 | check_command = 'sh -c "checkupdates > ' + tmp_file 40 | 41 | aur_check_commands = {'pacaur': 'pacaur check -q', 42 | 'trizen': 'trizen -Qqu -a', 43 | 'yay': 'yay -Qqu -a'} 44 | 45 | if len(sys.argv) > 1: 46 | for i in range(1, len(sys.argv)): 47 | 48 | if sys.argv[i].upper() == '-O': 49 | do_check = False 50 | do_update = False 51 | do_notify = True 52 | break 53 | 54 | elif sys.argv[1].upper() == "MENU": 55 | show_menu() 56 | break 57 | 58 | if sys.argv[i].upper().startswith('-C'): 59 | try: 60 | helper_cmd = aur_check_commands[sys.argv[i][2::]] 61 | except KeyError: 62 | helper_cmd = "" 63 | pass 64 | if helper_cmd: 65 | check_command += " && " + helper_cmd 66 | check_command += ' >> ' + tmp_file + '"' 67 | do_check = True 68 | do_update = False 69 | do_notify = False 70 | 71 | if sys.argv[i].upper().startswith('-U'): 72 | tools = sys.argv[i][2::].split(":") 73 | terminal_name = tools[0] 74 | try: 75 | helper_name = tools[1] 76 | except IndexError: 77 | helper_name = "sudo pacman" 78 | do_check = False 79 | do_update = True 80 | do_notify = False 81 | 82 | if sys.argv[i].upper() == '-N': 83 | name = "Upd:" 84 | 85 | if sys.argv[i].upper().startswith('-M'): 86 | name = sys.argv[i][2::] 87 | 88 | if sys.argv[i].upper() == '-H' or sys.argv[i].upper() == '-HELP': 89 | print("\nt2ec --update -C[aur_helper] | -U[:aur_helper] | [-O] [-N] | [-M]\n") 90 | print("-C[aur_helper] - (C)heck updates with pacman and optionally AUR helper") 91 | print(" example: t2ec --update -Ctrizen\n") 92 | print("-U[:aur_helper] - (U)pdate in with pacman or AUR helper") 93 | print(" example: t2ec --update -Uxfce4-terminal:trizen\n") 94 | print("-O - display saved pending updates as n(O)tification") 95 | print("-N - print (N)ame instead of icon") 96 | print("-M - print custom na(M)e instead of icon\n") 97 | 98 | if do_check: 99 | if name is not None: 100 | os.system("echo Checking...") 101 | else: 102 | os.system("echo /usr/share/t2ec/refresh.svg") 103 | os.system("echo ''") 104 | 105 | subprocess.call(check_command, shell=True) 106 | updates = open(tmp_file, 'r').read().rstrip() 107 | num_upd = len(updates.splitlines()) 108 | 109 | if name is not None: 110 | if num_upd > 0: 111 | print(name + " " + str(num_upd)) 112 | else: 113 | print("Up-to-date") 114 | else: 115 | if num_upd > 0: 116 | os.system("echo /usr/share/t2ec/arch-icon-notify.svg") 117 | os.system("echo " + str(num_upd)) 118 | else: 119 | os.system("echo /usr/share/t2ec/arch-icon.svg") 120 | os.system("echo ''") 121 | 122 | if do_update: 123 | command = terminal_name + ' -e \'sh -c \"' + helper_name + ' -Syu; echo Press enter to exit; read; killall -SIGUSR1 tint2\"\'' 124 | subprocess.call(command, shell=True) 125 | 126 | if do_notify: 127 | updates = open(tmp_file, 'r').read().rstrip() 128 | notify(updates) 129 | 130 | 131 | def notify(updates): 132 | subprocess.call( 133 | ['notify-send', "Pending updates:", "--icon=/usr/share/t2ec/arch-update48.svg", "--expire-time=5000", updates]) 134 | 135 | 136 | def show_menu(): 137 | try: 138 | subprocess.check_output("which jgmenu", shell=True) 139 | except subprocess.CalledProcessError: 140 | print("\nInstall jgmenu package, run `jgmenu init`\n") 141 | return 142 | 143 | t2ec_dir = os.getenv("HOME") + "/.t2ecol" 144 | if not os.path.isdir(t2ec_dir): 145 | os.makedirs(t2ec_dir) 146 | if not os.path.isfile(t2ec_dir + "/menu-update.sh"): 147 | subprocess.call(["cp /usr/lib/t2ec/menu-update.sh "+ t2ec_dir + "/menu-update.sh"], shell=True) 148 | subprocess.call([t2ec_dir + '/menu-update.sh'], shell=True) 149 | 150 | 151 | if __name__ == "__main__": 152 | main() 153 | -------------------------------------------------------------------------------- /scripts-arch/battery-icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script displays battery icon according to the charge level and charging state 4 | 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Dependencies: `acpi` 12 | # argument: [-l] - append textual brightness level 13 | 14 | bat=$(acpi -b) 15 | if [[ $bat ]]; then 16 | state=$(echo ${bat} | awk '{print $3}') 17 | 18 | if [[ "$state" = "Not" ]]; then 19 | level=$(echo ${bat} | awk '{print $5}') 20 | level=${level::-1} 21 | 22 | else 23 | level=$(echo ${bat} | awk '{print $4}') 24 | if [[ "$state" == *"Unknown"* ]]; then 25 | level=${level::-1} 26 | else 27 | if [[ "$level" == "100%" ]]; then 28 | level=${level::-1} 29 | else 30 | level=${level::-2} 31 | fi 32 | fi 33 | fi 34 | 35 | if [[ $1 == -N* ]]; then 36 | echo "Bat: ${level}%" 37 | else 38 | if [[ "$bat" == *"until"* ]]; then 39 | 40 | if [[ "$level" -ge "95" ]]; then 41 | echo /usr/share/t2ec/bat-full-charging.svg 42 | elif [[ "$level" -ge "75" ]]; then 43 | echo /usr/share/t2ec/bat-threefourth-charging.svg 44 | elif [[ "$level" -ge "35" ]]; then 45 | echo /usr/share/t2ec/bat-half-charging.svg 46 | elif [[ "$level" -ge "15" ]]; then 47 | echo /usr/share/t2ec/bat-quarter-charging.svg 48 | else 49 | echo /usr/share/t2ec/bat-empty-charging.svg 50 | fi 51 | else 52 | if [[ "$level" -ge "95" ]]; then 53 | echo /usr/share/t2ec/bat-full.svg 54 | elif [[ "$level" -ge "75" ]]; then 55 | echo /usr/share/t2ec/bat-threefourth.svg 56 | elif [[ "$level" -ge "35" ]]; then 57 | echo /usr/share/t2ec/bat-half.svg 58 | elif [[ "$level" -ge "15" ]]; then 59 | echo /usr/share/t2ec/bat-quarter.svg 60 | else 61 | echo /usr/share/t2ec/bat-empty.svg 62 | fi 63 | fi 64 | if [[ $1 = "-l" ]]; then 65 | echo ${level}% 66 | fi 67 | fi 68 | fi -------------------------------------------------------------------------------- /scripts-arch/bbswitch-status-temp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Author: Piotr Miller 4 | # e-mail: nwg.piotr@gmail.com 5 | # Website: http://nwg.pl 6 | # Project: https://github.com/nwg-piotr/t2ec 7 | # License: GPL3 8 | 9 | # Credits: https://github.com/dsboger/gnome-shell-extension-bumblebee-status 10 | # no-bumblebee icon by @edskeye 11 | 12 | # Argument: [-N] 13 | 14 | if [[ -f "/proc/acpi/bbswitch" ]]; then 15 | 16 | bb_status=$(cat /proc/acpi/bbswitch | awk -F ' ' '{print $2}') 17 | if [[ "$bb_status" = "ON" ]]; then 18 | 19 | t=$(nvidia-smi -q -d TEMPERATURE | grep "GPU Current Temp" | awk -F ' ' '{ print $5 }') 20 | 21 | if [[ $1 == -N* ]]; then 22 | echo "Nvidia: ${t}℃" 23 | else 24 | echo /usr/share/t2ec/nvidia.svg; 25 | echo ${t}"℃" 26 | fi 27 | 28 | elif [[ "$bb_status" = "OFF" ]]; then 29 | if [[ $1 == -N* ]]; then 30 | echo "Nvidia: off" 31 | else 32 | echo /usr/share/t2ec/nvidia-off.svg 33 | fi 34 | fi 35 | else 36 | if [[ $1 == -N* ]]; then 37 | echo "No Bumblebee" 38 | else 39 | echo /usr/share/t2ec/no-bumblebee.svg 40 | fi 41 | fi -------------------------------------------------------------------------------- /scripts-arch/brightness-icon-light.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script displays an appropriate brightness icon according to the brightness level by `light` command 4 | 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Dependencies: `light-git` 12 | # arguments: [up] | [down] | [] | [-N] 13 | 14 | if [[ $1 == up ]]; then 15 | light -A 5 16 | elif [[ $1 == down ]]; then 17 | light -U 5 18 | else 19 | if [[ $(($1)) == $1 ]] && [[ "$1" -ge 0 ]] && [[ "$1" -le 100 ]]; then 20 | light -S $1 21 | fi 22 | fi 23 | 24 | b=$(light -G) 25 | 26 | bri=$(echo $b | awk '{ printf"%0.0f\n", $1 }') 27 | 28 | if [[ $1 == -N* ]]; then 29 | echo "Bri: ${bri}%" 30 | else 31 | if [[ "$bri" -gt "90" ]]; then 32 | echo /usr/share/t2ec/bri-full.svg 33 | elif [[ "$bri" -gt "50" ]]; then 34 | echo /usr/share/t2ec/bri-high.svg 35 | elif [[ "$bri" -gt "30" ]]; then 36 | echo /usr/share/t2ec/bri-medium.svg 37 | else 38 | echo /usr/share/t2ec/bri-low.svg 39 | fi 40 | echo ${bri}% 41 | fi 42 | -------------------------------------------------------------------------------- /scripts-arch/brightness-icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script displays an appropriate brightness icon according to the brightness level by `xbacklight` command 4 | 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Dependencies: `xbacklight` 12 | # arguments: [up] | [down] | [] | [-N] 13 | 14 | if [[ $1 == up ]]; then 15 | exec xbacklight +5 16 | elif [[ $1 == down ]]; then 17 | exec xbacklight -5 18 | else 19 | if [[ $(($1)) == $1 ]] && [[ "$1" -ge 0 ]] && [[ "$1" -le 100 ]]; then 20 | exec xbacklight -set $1 21 | fi 22 | fi 23 | 24 | b=$(xbacklight -get) 25 | 26 | bri=$(echo $b | awk '{ printf"%0.0f\n", $1 }') 27 | 28 | if [[ $1 == -N* ]]; then 29 | echo "Bri: ${bri}%" 30 | else 31 | if [[ "$bri" -gt "90" ]]; then 32 | echo /usr/share/t2ec/bri-full.svg 33 | elif [[ "$bri" -gt "50" ]]; then 34 | echo /usr/share/t2ec/bri-high.svg 35 | elif [[ "$bri" -gt "30" ]]; then 36 | echo /usr/share/t2ec/bri-medium.svg 37 | else 38 | echo /usr/share/t2ec/bri-low.svg 39 | fi 40 | echo ${bri}% 41 | fi 42 | -------------------------------------------------------------------------------- /scripts-arch/desktop.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # _*_ coding: utf-8 _*_ 3 | 4 | """ 5 | 6 | This script uses `wmctrl` to switch desktops, or just prints path to the icon corresponding to currently active desktop, 7 | followed by the desktop number as text. 8 | 9 | Author: Piotr Miller 10 | e-mail: nwg.piotr@gmail.com 11 | Website: http://nwg.pl 12 | Project: https://github.com/nwg-piotr/t2ec 13 | License: GPL3 14 | 15 | Arguments [next] | [prev] | [] | [-menu] [-N] 16 | 17 | [next] - switch to next desktop 18 | [prev] - switch to previous desktop 19 | [number] - switch to desktop of number given 20 | 21 | """ 22 | 23 | import sys 24 | import subprocess 25 | import os 26 | 27 | 28 | def main(): 29 | output = subprocess.check_output("wmctrl -d", shell=True) 30 | desktops = output.splitlines() 31 | textual = False 32 | current = current_desktop(desktops) 33 | last = len(desktops) - 1 34 | 35 | if len(sys.argv) > 1: 36 | if sys.argv[1].upper() == "NEXT": 37 | next_desktop(current, last) 38 | elif sys.argv[1].upper() == "PREV" or sys.argv[1].upper() == "PREVIOUS": 39 | previous_desktop(current, last) 40 | elif sys.argv[1].upper() == "-N": 41 | textual = True 42 | elif sys.argv[1].upper() == "MENU": 43 | create_menu(last + 1) 44 | else: 45 | try: 46 | d = int(sys.argv[1]) 47 | select_desktop(d - 1, last) 48 | except ValueError: 49 | print("Argument not allowed. Should be: desktop.py [next] | [prev] | [] | [menu] [-N]") 50 | 51 | if textual: 52 | print("Desktop: " + str(current_desktop(desktops) + 1)) 53 | else: 54 | print(str("/usr/share/t2ec/desktop.svg")) 55 | print(str(current_desktop(desktops) + 1)) 56 | 57 | 58 | def current_desktop(desktops): 59 | for d in range(len(desktops)): 60 | if str(desktops[d]).find("*") > -1: 61 | return d 62 | 63 | 64 | def next_desktop(current, last): 65 | n = current + 1 if current + 1 <= last else 0 66 | subprocess.call(["wmctrl", "-s", str(n)]) 67 | 68 | 69 | def previous_desktop(current, last): 70 | n = current - 1 if current - 1 >= 0 else last 71 | subprocess.call(["wmctrl", "-s", str(n)]) 72 | 73 | 74 | def select_desktop(which, last): 75 | if 0 <= which <= last: 76 | subprocess.call(["wmctrl", "-s", str(which)]) 77 | else: 78 | print("You only have desktops 1-" + str(last + 1)) 79 | 80 | 81 | def create_menu(d_number): 82 | try: 83 | subprocess.check_output("which jgmenu", shell=True) 84 | except subprocess.CalledProcessError: 85 | print("\nInstall jgmenu package, run `jgmenu init`\n") 86 | return 87 | 88 | # Just in case user had more or less desktops than 4, let's create a relevant template at the 1st run 89 | t2ec_dir = os.getenv("HOME") + "/.t2ecol" 90 | if not os.path.isdir(t2ec_dir): 91 | os.makedirs(t2ec_dir) 92 | 93 | if not os.path.isfile(t2ec_dir + "/menu-desktop.sh"): 94 | content = ['#!/bin/sh', 95 | '', 96 | 'config_file=$(mktemp)', 97 | 'menu_file=$(mktemp)', 98 | 'trap "rm -f ${config_file} ${menu_file}" EXIT', 99 | '', 100 | 'cat <<\'EOF\' >${config_file}', 101 | 'stay_alive = 0', 102 | 'tint2_look = 1', 103 | 'menu_width = 40', 104 | 'menu_border = 0', 105 | 'item_height = 20', 106 | 'font = Sans 10', 107 | 'icon_size = 0', 108 | 'color_norm_fg = #eeeeee 100', 109 | 'color_sel_fg = #eeeeee 100', 110 | 'EOF', 111 | '', 112 | 'cat <<\'EOF\' >${menu_file}'] 113 | 114 | for i in range(1, d_number + 1): 115 | content.append("desktop " + str(i) + ", t2ec --desktop " + str(i)) 116 | 117 | content.append('EOF') 118 | content.append('') 119 | content.append('jgmenu --config-file=${config_file} --csv-file=${menu_file}') 120 | 121 | with open(t2ec_dir + '/menu-desktop.sh', 'w') as menu_file: 122 | for row in content: 123 | menu_file.write('%s\n' % row) 124 | 125 | os.system('chmod +x ' + t2ec_dir + "/menu-desktop.sh") 126 | 127 | subprocess.call([t2ec_dir + '/menu-desktop.sh'], shell=True) 128 | 129 | 130 | if __name__ == "__main__": 131 | main() 132 | -------------------------------------------------------------------------------- /scripts-arch/help.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | printf "\nCOMMAND ARGUMENTS:\n" 4 | 5 | printf "\nt2ec [--desktop] | [--bbswitch] | [--volume] | [--brightness] | [--lbrightness] | [--battery] | [--wifi] | [--zslider] [menu]\n\n" 6 | 7 | printf "Arguments to execute actions | format display:\n\n" 8 | 9 | echo "--desktop [next] | [prev] | [] [-N]" 10 | echo "--bbswitch [-N]" 11 | echo "--volume [up] | [down] | [] [-N]" 12 | echo "--brightness [up] | [down] | [] [-N]" 13 | echo "--lbrightness [up] | [down] | [] [-N] (for 'light-git' optional package)" 14 | echo "--battery [-l] | [-N]" 15 | echo "--wifi [-N] | [-M'custom name']" 16 | echo "--update -C[aur_helper] | -U[:aur_helper] | [-O] [-N] | [-M] | [-h] | [--help]" 17 | echo "--weather [-I] [-A] [-C] [-U] [-L] | [-D[]] | [-h] | [--help]" 18 | printf "\n[menu] argument after --command displays context menu (if jgmenu package installed). Edit templates in ~/.t2ecol folder to customize menus.\n" 19 | printf "\n[-N] - displays name instead of icon in tint2 panel. Uncheck 'Show icon' in executor!\n\n" 20 | echo "In --battery command [-l] - appends level text to the icon | [-N] displays textual name and level instead of icon" 21 | 22 | printf "\n--zbox [bri] | [vol] - displays Zenity box to set volume | brightness level. Depends on 'zenity' and 'rof-git' optional packages.\n" 23 | 24 | printf "\n--paswitch - displays jgmenu to switch audio output.\n\n" -------------------------------------------------------------------------------- /scripts-arch/menu-template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | config_file=$(mktemp) 4 | menu_file=$(mktemp) 5 | trap "rm -f ${config_file} ${menu_file}" EXIT 6 | 7 | cat <<'EOF' >${config_file} 8 | stay_alive = 0 9 | tint2_look = 1 10 | menu_width = 40 11 | menu_border = 1 12 | item_height = 20 13 | font = Sans 10 14 | icon_size = 0 15 | color_norm_fg = #eeeeee 100 16 | color_sel_fg = #eeeeee 100 17 | EOF 18 | 19 | cat <<'EOF' >${menu_file} 20 | Option 1,t2ec --brightness up 21 | Option 2,t2ec --brightness down 22 | EOF 23 | 24 | jgmenu --config-file=${config_file} --csv-file=${menu_file} -------------------------------------------------------------------------------- /scripts-arch/menu-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | config_file=$(mktemp) 4 | menu_file=$(mktemp) 5 | trap "rm -f ${config_file} ${menu_file}" EXIT 6 | 7 | cat <<'EOF' >${config_file} 8 | stay_alive = 0 9 | tint2_look = 1 10 | menu_width = 40 11 | menu_border = 1 12 | item_height = 20 13 | font = Sans 10 14 | icon_size = 0 15 | color_norm_fg = #eeeeee 100 16 | color_sel_fg = #eeeeee 100 17 | EOF 18 | 19 | cat <<'EOF' >${menu_file} 20 | Check updates,t2ec --Cyay 21 | Show pending,t2ec --update -O 22 | Update,t2ec --update -Utermite:yay 23 | EOF 24 | 25 | jgmenu --config-file=${config_file} --csv-file=${menu_file} -------------------------------------------------------------------------------- /scripts-arch/menus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ ! -d ~/.t2ecol ]]; then 4 | mkdir -p ~/.t2ecol 5 | fi 6 | 7 | if [[ $1 == --bbswitch ]]; then 8 | if [[ ! -f ~/.t2ecol/menu-bbswitch.sh ]]; then 9 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-bbswitch.sh 10 | fi 11 | exec ~/.t2ecol/menu-bbswitch.sh 12 | fi 13 | 14 | if [[ $1 == --brightness ]]; then 15 | if [[ ! -f ~/.t2ecol/menu-brightness.sh ]]; then 16 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-brightness.sh 17 | fi 18 | exec ~/.t2ecol/menu-brightness.sh 19 | fi 20 | 21 | if [[ $1 == --brightness ]]; then 22 | if [[ ! -f ~/.t2ecol/menu-brightness.sh ]]; then 23 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-brightness.sh 24 | fi 25 | exec ~/.t2ecol/menu-brightness.sh 26 | fi 27 | 28 | if [[ $1 == --lbrightness ]]; then 29 | if [[ ! -f ~/.t2ecol/menu-lbrightness.sh ]]; then 30 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-lbrightness.sh 31 | fi 32 | exec ~/.t2ecol/menu-lbrightness.sh 33 | fi 34 | 35 | if [[ $1 == --volume ]]; then 36 | if [[ ! -f ~/.t2ecol/menu-volume.sh ]]; then 37 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-volume.sh 38 | fi 39 | exec ~/.t2ecol/menu-volume.sh 40 | fi 41 | 42 | if [[ $1 == --wifi ]]; then 43 | if [[ ! -f ~/.t2ecol/menu-wifi.sh ]]; then 44 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-wifi.sh 45 | fi 46 | exec ~/.t2ecol/menu-wifi.sh 47 | fi 48 | -------------------------------------------------------------------------------- /scripts-arch/pa-jgmenu.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # _*_ coding: utf-8 _*_ 3 | 4 | """ 5 | Author: Piotr Miller 6 | e-mail: nwg.piotr@gmail.com 7 | Website: http://nwg.pl 8 | Project: https://github.com/nwg-piotr/t2ec 9 | License: GPL3 10 | 11 | Credits: mreithub at https://unix.stackexchange.com/a/67398 (and comments below!) 12 | 13 | Dependencies: 'jgmenu' 'pulseaudio' 'pulseaudio-alsa' 14 | 15 | This script creates jgmenu to switch audio output with the pa-switch-output.sh helper script 16 | """ 17 | 18 | import os 19 | import subprocess 20 | 21 | 22 | def main(): 23 | # get sink numbers 24 | sinks = subprocess.check_output("pactl list short sinks", shell=True).decode("utf-8").splitlines() 25 | 26 | # get output descriptions 27 | names = subprocess.check_output("pacmd list-sinks | grep device.description | awk -F '=' '{print $2}'", 28 | shell=True).decode("utf-8").splitlines() 29 | outputs = [] 30 | 31 | # Tuples ("sink_number", "output_description") 32 | for output in range(len(sinks)): 33 | output = sinks[output].split()[0], names[output].strip()[1:-1] 34 | outputs.append(output) 35 | 36 | # Create jgmenu script 37 | jgmenu = [] 38 | jgmenu.append("#!/bin/sh\n") 39 | jgmenu.append("config_file=$(mktemp)") 40 | jgmenu.append("menu_file=$(mktemp)") 41 | jgmenu.append("trap \"rm -f ${config_file} ${menu_file}\" EXIT\n") 42 | jgmenu.append("cat << 'EOF' >${config_file}") 43 | jgmenu.append("stay_alive = 0") 44 | jgmenu.append("tint2_look = 1") 45 | jgmenu.append("menu_width = 40") 46 | jgmenu.append("menu_border = 1") 47 | jgmenu.append("item_height = 20") 48 | jgmenu.append("font = Sans 10") 49 | jgmenu.append("icon_size = 0") 50 | jgmenu.append("color_norm_fg = #eeeeee 100") 51 | jgmenu.append("color_sel_fg = #eeeeee 100") 52 | jgmenu.append("EOF\n") 53 | jgmenu.append("cat <<'EOF' >${menu_file}") 54 | 55 | # Use previously saved tuples (sink_number, output_description) to create jgmenu entries 56 | for output in outputs: 57 | jgmenu.append(output[1] + ", " + "/usr/lib/t2ec/pa-switch-output.sh " + output[0]) 58 | 59 | jgmenu.append("EOF\n") 60 | jgmenu.append("jgmenu --config-file=${config_file} --csv-file=${menu_file}") 61 | 62 | # Exit if jgmenu not installed 63 | try: 64 | subprocess.check_output("which jgmenu", shell=True) 65 | except subprocess.CalledProcessError: 66 | os.system("notify-send 'Install jgmenu package, run jgmenu init'") 67 | exit(0) 68 | 69 | # Save jgmenu script 70 | t2ec_dir = os.getenv("HOME") + "/.t2ecol" 71 | if not os.path.isdir(t2ec_dir): 72 | os.makedirs(t2ec_dir) 73 | 74 | with open(t2ec_dir + '/pulseaudio-menu.sh', 'w') as f: 75 | for item in jgmenu: 76 | f.write("%s\n" % item) 77 | 78 | # Make executable 79 | os.system("chmod u+x " + t2ec_dir + "/pulseaudio-menu.sh") 80 | 81 | # Execute jgmenu script 82 | os.system(t2ec_dir + "/pulseaudio-menu.sh &") 83 | 84 | 85 | if __name__ == "__main__": 86 | main() 87 | -------------------------------------------------------------------------------- /scripts-arch/pa-switch-output.sh: -------------------------------------------------------------------------------- 1 | # Credits go to mreithub at https://unix.stackexchange.com/a/67398 (and comments below!) 2 | #!/usr/bin/env bash 3 | 4 | newSink="$1" 5 | 6 | pactl list short sink-inputs|while read stream; do 7 | streamId=$(echo $stream|cut '-d ' -f1) 8 | pacmd set-default-sink "$newSink" 9 | pactl move-sink-input "$streamId" "$newSink" 10 | done 11 | -------------------------------------------------------------------------------- /scripts-arch/t2ec: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [[ $1 == --bbswitch ]] || [[ $1 == --volume ]] || [[ $1 == --brightness ]] || [[ $1 == --lbrightness ]] || [[ $1 == --battery ]] || [[ $1 == --wifi ]]; then 4 | if [[ $2 == menu ]]; then 5 | exec /usr/lib/t2ec/menus.sh $1 6 | fi 7 | fi 8 | 9 | if [[ $1 == --desktop ]]; then 10 | exec /usr/lib/t2ec/desktop.py $2 11 | elif [[ $1 == --bbswitch ]]; then 12 | exec /usr/lib/t2ec/bbswitch-status-temp.sh $2 13 | elif [[ $1 == --paswitch ]]; then 14 | exec /usr/lib/t2ec/pa-jgmenu.py 15 | elif [[ $1 == --volume ]]; then 16 | exec /usr/lib/t2ec/volume-icon.sh $2 17 | elif [[ $1 == --brightness ]]; then 18 | exec /usr/lib/t2ec/brightness-icon.sh $2 19 | elif [[ $1 == --lbrightness ]]; then 20 | exec /usr/lib/t2ec/brightness-icon-light.sh $2 21 | elif [[ $1 == --battery ]]; then 22 | exec /usr/lib/t2ec/battery-icon.sh $2 23 | elif [[ $1 == --wifi ]]; then 24 | exec /usr/lib/t2ec/wifi-name.sh "$2" 25 | elif [[ $1 == --update ]]; then 26 | exec /usr/lib/t2ec/arch-update.py "${@:2}" 27 | elif [[ $1 == --weather ]]; then 28 | exec /usr/lib/t2ec/weather.py "${@:2}" 29 | elif [[ $1 == --zbox ]]; then 30 | if [[ $(which rof 2>/dev/null) == *"/rof"* ]]; then 31 | exec /usr/lib/t2ec/zenity-box.sh $2 32 | else 33 | echo "'rof-git' package missing" 34 | fi 35 | elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then 36 | exec /usr/lib/t2ec/help.sh 37 | else 38 | echo "Try 't2ec -h' for help" 39 | fi 40 | -------------------------------------------------------------------------------- /scripts-arch/volume-icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script display an appropriate volume icon according to the volume level 4 | 5 | # Authors: Piotr Miller, @natemaia 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Dependencies: `alsa-utils` 12 | # arguments: [up] | [down] | [toggle] | [] [-N] 13 | 14 | if [[ $1 == up ]]; then 15 | amixer set Master 5%+ -q 16 | elif [[ $1 == down ]]; then 17 | amixer set Master 5%- -q 18 | elif [[ $1 == toggle ]]; then 19 | amixer sset Master toggle -q 20 | else 21 | # If none of above, check if argument is a valid int, set volume if so 22 | if [[ $(($1)) == $1 ]] && [[ "$1" -ge 0 ]] && [[ "$1" -le 100 ]]; then 23 | amixer set Master "$1"% -q 24 | fi 25 | fi 26 | 27 | if [[ "$(amixer sget Master | grep -e 'Right:' -e 'Mono:')" == *"[on]"* ]]; then 28 | 29 | # search for the lines containing 'Right:' or 'Mono:', when more than 1 field exists 30 | # we strip the trailing '%' and round it up with printf "%0.0f" just in case 31 | vol=$(amixer sget Master | awk -F'[][]' '/Right:|Mono:/ && NF > 1 {sub(/%/, ""); printf "%0.0f\n", $2}') 32 | 33 | if [[ $1 == -N* ]]; then 34 | echo "Vol: ${vol}%" 35 | else 36 | if [[ ${vol} -ge 90 ]]; then 37 | echo /usr/share/t2ec/vol-full.svg 38 | elif [[ ${vol} -ge 40 ]]; then 39 | echo /usr/share/t2ec/vol-medium.svg 40 | elif [[ ${vol} -ge 10 ]]; then 41 | echo /usr/share/t2ec/vol-low.svg 42 | else 43 | echo /usr/share/t2ec/vol-lowest.svg 44 | fi 45 | echo ${vol}% 46 | fi 47 | else 48 | vol=$(amixer sget Master | awk -F'[][]' '/Right:|Mono:/ && NF > 1 {sub(/%/, ""); printf "%0.0f\n", $2}') 49 | echo /usr/share/t2ec/vol-muted.svg 50 | echo ${vol}% 51 | fi 52 | -------------------------------------------------------------------------------- /scripts-arch/wifi-name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script displays battery icon according to the charge level and charging state 4 | 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # Icon by @edskeye 10 | 11 | # Dependencies: `wireless_tools` 12 | # Arguments: [-N] ("Wi-Fi: " instead of icon) | [-M'custom name'] 13 | 14 | name="none" 15 | 16 | wifi=$(iwgetid | awk -F '"' '{ print $2 }') 17 | if [[ ! -z "$wifi" ]]; then 18 | name="$wifi" 19 | fi 20 | 21 | if [[ $1 == -N* ]]; then 22 | echo "Wi-Fi: $name" 23 | elif [[ $1 == -M* ]]; then 24 | echo "$(echo $1 | cut -c3-) $name" 25 | else 26 | echo /usr/share/t2ec/network.svg 27 | echo ${name} 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /scripts-arch/zenity-box.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Set desired level with a zenity dialog box 4 | 5 | # Dependencies: `alsa-utils`, `xbacklight` or `light-git`, `zenity` 6 | # Arguments: [bri] | [vol] 7 | 8 | if [[ $1 == bri* ]]; then 9 | 10 | # Prefer the `light` package, use `xbacklight` if `light` not found 11 | if [[ $(which light) == *"/light"* ]]; then 12 | lvl=$(light -G) 13 | else 14 | lvl=$(xbacklight -get) 15 | fi 16 | 17 | lvl=$(echo ${lvl} | awk '{ printf"%0.0f\n", $1 }') 18 | 19 | lvl=$(rof -P zenity zenity --scale --value ${lvl} --title "Brightness" --text "Set brightness level") 20 | 21 | if [[ ${lvl} ]]; then 22 | if [[ $(which light) == *"/light"* ]]; then 23 | exec light -S ${lvl} 24 | else 25 | exec xbacklight -set ${lvl} 26 | fi 27 | fi 28 | 29 | elif [[ $1 == vol* ]]; then 30 | lvl=$(amixer sget Master | grep '%' | awk -F'[][]' '{ print $2 }') 31 | lvl=${lvl::-1} 32 | lvl=$(rof -P zenity zenity --scale --value ${lvl} --title "Volume" --text "Set master volume level") 33 | if [[ ${lvl} ]]; then 34 | exec amixer sset 'Master' ${lvl}% -q 35 | fi 36 | else 37 | echo "Allowed arguments: vol | bri" 38 | 39 | fi 40 | -------------------------------------------------------------------------------- /scripts-void/battery-icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script displays battery icon according to the charge level and charging state 4 | 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Dependencies: `acpi` 12 | # argument: [-l] - append textual brightness level 13 | 14 | bat=$(acpi -b) 15 | if [[ $bat ]]; then 16 | state=$(echo ${bat} | awk '{print $3}') 17 | 18 | if [[ "$state" = "Not" ]]; then 19 | level=$(echo ${bat} | awk '{print $5}') 20 | level=${level::-1} 21 | 22 | else 23 | level=$(echo ${bat} | awk '{print $4}') 24 | if [[ "$state" == *"Unknown"* ]]; then 25 | level=${level::-1} 26 | else 27 | if [[ "$level" == "100%" ]]; then 28 | level=${level::-1} 29 | else 30 | level=${level::-2} 31 | fi 32 | fi 33 | fi 34 | 35 | if [[ $1 == -N* ]]; then 36 | echo "Bat: ${level}%" 37 | else 38 | if [[ "$bat" == *"until"* ]]; then 39 | 40 | if [[ "$level" -ge "95" ]]; then 41 | echo /usr/share/t2ec/bat-full-charging.svg 42 | elif [[ "$level" -ge "75" ]]; then 43 | echo /usr/share/t2ec/bat-threefourth-charging.svg 44 | elif [[ "$level" -ge "35" ]]; then 45 | echo /usr/share/t2ec/bat-half-charging.svg 46 | elif [[ "$level" -ge "15" ]]; then 47 | echo /usr/share/t2ec/bat-quarter-charging.svg 48 | else 49 | echo /usr/share/t2ec/bat-empty-charging.svg 50 | fi 51 | else 52 | if [[ "$level" -ge "95" ]]; then 53 | echo /usr/share/t2ec/bat-full.svg 54 | elif [[ "$level" -ge "75" ]]; then 55 | echo /usr/share/t2ec/bat-threefourth.svg 56 | elif [[ "$level" -ge "35" ]]; then 57 | echo /usr/share/t2ec/bat-half.svg 58 | elif [[ "$level" -ge "15" ]]; then 59 | echo /usr/share/t2ec/bat-quarter.svg 60 | else 61 | echo /usr/share/t2ec/bat-empty.svg 62 | fi 63 | fi 64 | if [[ $1 = "-l" ]]; then 65 | echo ${level}% 66 | fi 67 | fi 68 | fi -------------------------------------------------------------------------------- /scripts-void/bbswitch-status-temp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Author: Piotr Miller 4 | # e-mail: nwg.piotr@gmail.com 5 | # Website: http://nwg.pl 6 | # Project: https://github.com/nwg-piotr/t2ec 7 | # License: GPL3 8 | 9 | # Credits: https://github.com/dsboger/gnome-shell-extension-bumblebee-status 10 | # no-bumblebee icon by @edskeye 11 | 12 | # Argument: [-N] 13 | 14 | if [[ -f "/proc/acpi/bbswitch" ]]; then 15 | 16 | bb_status=$(cat /proc/acpi/bbswitch | awk -F ' ' '{print $2}') 17 | if [[ "$bb_status" = "ON" ]]; then 18 | 19 | t=$(nvidia-smi -q -d TEMPERATURE | grep "GPU Current Temp" | awk -F ' ' '{ print $5 }') 20 | 21 | if [[ $1 == -N* ]]; then 22 | echo "Nvidia: ${t}℃" 23 | else 24 | echo /usr/share/t2ec/nvidia.svg; 25 | echo ${t}"℃" 26 | fi 27 | 28 | elif [[ "$bb_status" = "OFF" ]]; then 29 | if [[ $1 == -N* ]]; then 30 | echo "Nvidia: off" 31 | else 32 | echo /usr/share/t2ec/nvidia-off.svg 33 | fi 34 | fi 35 | else 36 | if [[ $1 == -N* ]]; then 37 | echo "No Bumblebee" 38 | else 39 | echo /usr/share/t2ec/no-bumblebee.svg 40 | fi 41 | fi -------------------------------------------------------------------------------- /scripts-void/brightness-icon-light.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script displays an appropriate brightness icon according to the brightness level by `light` command 4 | 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Dependencies: `light-git` 12 | # arguments: [up] | [down] | [] | [-N] 13 | 14 | if [[ $1 == up ]]; then 15 | light -A 5 16 | elif [[ $1 == down ]]; then 17 | light -U 5 18 | else 19 | if [[ $(($1)) == $1 ]] && [[ "$1" -ge 0 ]] && [[ "$1" -le 100 ]]; then 20 | light -S $1 21 | fi 22 | fi 23 | 24 | b=$(light -G) 25 | 26 | bri=$(echo $b | awk '{ printf"%0.0f\n", $1 }') 27 | 28 | if [[ $1 == -N* ]]; then 29 | echo "Bri: ${bri}%" 30 | else 31 | if [[ "$bri" -gt "90" ]]; then 32 | echo /usr/share/t2ec/bri-full.svg 33 | elif [[ "$bri" -gt "50" ]]; then 34 | echo /usr/share/t2ec/bri-high.svg 35 | elif [[ "$bri" -gt "30" ]]; then 36 | echo /usr/share/t2ec/bri-medium.svg 37 | else 38 | echo /usr/share/t2ec/bri-low.svg 39 | fi 40 | echo ${bri}% 41 | fi 42 | -------------------------------------------------------------------------------- /scripts-void/brightness-icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script displays an appropriate brightness icon according to the brightness level by `xbacklight` command 4 | 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Dependencies: `xbacklight` 12 | # arguments: [up] | [down] | [] | [-N] 13 | 14 | if [[ $1 == up ]]; then 15 | exec xbacklight +5 16 | elif [[ $1 == down ]]; then 17 | exec xbacklight -5 18 | else 19 | if [[ $(($1)) == $1 ]] && [[ "$1" -ge 0 ]] && [[ "$1" -le 100 ]]; then 20 | exec xbacklight -set $1 21 | fi 22 | fi 23 | 24 | b=$(xbacklight -get) 25 | 26 | bri=$(echo $b | awk '{ printf"%0.0f\n", $1 }') 27 | 28 | if [[ $1 == -N* ]]; then 29 | echo "Bri: ${bri}%" 30 | else 31 | if [[ "$bri" -gt "90" ]]; then 32 | echo /usr/share/t2ec/bri-full.svg 33 | elif [[ "$bri" -gt "50" ]]; then 34 | echo /usr/share/t2ec/bri-high.svg 35 | elif [[ "$bri" -gt "30" ]]; then 36 | echo /usr/share/t2ec/bri-medium.svg 37 | else 38 | echo /usr/share/t2ec/bri-low.svg 39 | fi 40 | echo ${bri}% 41 | fi 42 | -------------------------------------------------------------------------------- /scripts-void/desktop.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # _*_ coding: utf-8 _*_ 3 | 4 | """ 5 | 6 | This script uses `wmctrl` to switch desktops, or just prints path to the icon corresponding to currently active desktop, 7 | followed by the desktop number as text. 8 | 9 | Author: Piotr Miller 10 | e-mail: nwg.piotr@gmail.com 11 | Website: http://nwg.pl 12 | Project: https://github.com/nwg-piotr/tint2-executors 13 | License: GPL3 14 | 15 | Arguments [next] | [prev] | [] | [-menu] [-N] 16 | 17 | [next] - switch to next desktop 18 | [prev] - switch to previous desktop 19 | [number] - switch to desktop of number given 20 | 21 | """ 22 | 23 | import sys 24 | import subprocess 25 | import os 26 | 27 | 28 | def main(): 29 | output = subprocess.check_output("wmctrl -d", shell=True) 30 | desktops = output.splitlines() 31 | textual = False 32 | current = current_desktop(desktops) 33 | last = len(desktops) - 1 34 | 35 | if len(sys.argv) > 1: 36 | if sys.argv[1].upper() == "NEXT": 37 | next_desktop(current, last) 38 | elif sys.argv[1].upper() == "PREV" or sys.argv[1].upper() == "PREVIOUS": 39 | previous_desktop(current, last) 40 | elif sys.argv[1].upper() == "-N": 41 | textual = True 42 | elif sys.argv[1].upper() == "MENU": 43 | create_menu(last + 1) 44 | else: 45 | try: 46 | d = int(sys.argv[1]) 47 | select_desktop(d - 1, last) 48 | except ValueError: 49 | print("Argument not allowed. Should be: desktop.py [next] | [prev] | [] | [menu] [-N]") 50 | 51 | if textual: 52 | print("Desktop: " + str(current_desktop(desktops) + 1)) 53 | else: 54 | print(str("/usr/share/t2ec/desktop.svg")) 55 | print(str(current_desktop(desktops) + 1)) 56 | 57 | 58 | def current_desktop(desktops): 59 | for d in range(len(desktops)): 60 | if str(desktops[d]).find("*") > -1: 61 | return d 62 | 63 | 64 | def next_desktop(current, last): 65 | n = current + 1 if current + 1 <= last else 0 66 | subprocess.call(["wmctrl", "-s", str(n)]) 67 | 68 | 69 | def previous_desktop(current, last): 70 | n = current - 1 if current - 1 >= 0 else last 71 | subprocess.call(["wmctrl", "-s", str(n)]) 72 | 73 | 74 | def select_desktop(which, last): 75 | if 0 <= which <= last: 76 | subprocess.call(["wmctrl", "-s", str(which)]) 77 | else: 78 | print("You only have desktops 1-" + str(last + 1)) 79 | 80 | 81 | def create_menu(d_number): 82 | try: 83 | subprocess.check_output("which jgmenu", shell=True) 84 | except subprocess.CalledProcessError: 85 | print("\nInstall jgmenu package, run `jgmenu init`\n") 86 | return 87 | 88 | # Just in case user had more or less desktops than 4, let's create a relevant template at the 1st run 89 | t2ec_dir = os.getenv("HOME") + "/.t2ecol" 90 | if not os.path.isdir(t2ec_dir): 91 | os.makedirs(t2ec_dir) 92 | 93 | if not os.path.isfile(t2ec_dir + "/menu-desktop.sh"): 94 | content = ['#!/bin/sh', 95 | '', 96 | 'config_file=$(mktemp)', 97 | 'menu_file=$(mktemp)', 98 | 'trap "rm -f ${config_file} ${menu_file}" EXIT', 99 | '', 100 | 'cat <<\'EOF\' >${config_file}', 101 | 'stay_alive = 0', 102 | 'tint2_look = 1', 103 | 'menu_width = 40', 104 | 'menu_border = 0', 105 | 'item_height = 20', 106 | 'font = Sans 10', 107 | 'icon_size = 0', 108 | 'color_norm_fg = #eeeeee 100', 109 | 'color_sel_fg = #eeeeee 100', 110 | 'EOF', 111 | '', 112 | 'cat <<\'EOF\' >${menu_file}'] 113 | 114 | for i in range(1, d_number + 1): 115 | content.append("desktop " + str(i) + ", t2ec --desktop " + str(i)) 116 | 117 | content.append('EOF') 118 | content.append('') 119 | content.append('jgmenu --config-file=${config_file} --csv-file=${menu_file}') 120 | 121 | with open(t2ec_dir + '/menu-desktop.sh', 'w') as menu_file: 122 | for row in content: 123 | menu_file.write('%s\n' % row) 124 | 125 | os.system('chmod +x ' + t2ec_dir + "/menu-desktop.sh") 126 | 127 | subprocess.call([t2ec_dir + '/menu-desktop.sh'], shell=True) 128 | 129 | 130 | if __name__ == "__main__": 131 | main() 132 | -------------------------------------------------------------------------------- /scripts-void/help.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | printf "\nCOMMAND ARGUMENTS:\n" 4 | 5 | printf "\nt2ec [--desktop] | [--bbswitch] | [--volume] | [--brightness] | [--lbrightness] | [--battery] | [--wifi] | [menu]\n\n" 6 | 7 | printf "Arguments to execute actions | format display:\n\n" 8 | 9 | echo "--desktop [next] | [prev] | [] [-N]" 10 | echo "--bbswitch [-N]" 11 | echo "--volume [up] | [down] | [] [-N]" 12 | echo "--brightness [up] | [down] | [] [-N]" 13 | echo "--lbrightness [up] | [down] | [] [-N] (for 'light-git' optional package)" 14 | echo "--battery [-l] | [-N]" 15 | echo "--wifi [-N] | [-M'custom name']" 16 | echo "--update -C | -U | [-O] [-N] | [-M] | [-h] | [--help]" 17 | printf "\n[menu] argument after --command displays context menu (if jgmenu package installed). Edit templates in ~/.t2ecol folder to customize menus.\n" 18 | printf "\n[-N] - displays name instead of icon in tint2 panel. Uncheck 'Show icon' in executor!\n\n" 19 | echo "In --battery command [-l] - appends level text to the icon | [-N] displays textual name and level instead of icon" 20 | 21 | printf "\n--paswitch - displays jgmenu to switch audio output.\n\n" 22 | -------------------------------------------------------------------------------- /scripts-void/menu-template.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | config_file=$(mktemp) 4 | menu_file=$(mktemp) 5 | trap "rm -f ${config_file} ${menu_file}" EXIT 6 | 7 | cat <<'EOF' >${config_file} 8 | stay_alive = 0 9 | tint2_look = 1 10 | menu_width = 40 11 | menu_border = 1 12 | item_height = 20 13 | font = Sans 10 14 | icon_size = 0 15 | color_norm_fg = #eeeeee 100 16 | color_sel_fg = #eeeeee 100 17 | EOF 18 | 19 | cat <<'EOF' >${menu_file} 20 | Option 1,t2ec --brightness up 21 | Option 2,t2ec --brightness down 22 | EOF 23 | 24 | jgmenu --config-file=${config_file} --csv-file=${menu_file} -------------------------------------------------------------------------------- /scripts-void/menu-update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | config_file=$(mktemp) 4 | menu_file=$(mktemp) 5 | trap "rm -f ${config_file} ${menu_file}" EXIT 6 | 7 | cat <<'EOF' >${config_file} 8 | stay_alive = 0 9 | tint2_look = 1 10 | menu_width = 40 11 | menu_border = 1 12 | item_height = 20 13 | font = Sans 10 14 | icon_size = 0 15 | color_norm_fg = #eeeeee 100 16 | color_sel_fg = #eeeeee 100 17 | EOF 18 | 19 | cat <<'EOF' >${menu_file} 20 | Check updates,t2ec --update -C 21 | Show pending,t2ec --update -O 22 | Update,t2ec --update -Uxterm 23 | EOF 24 | 25 | jgmenu --config-file=${config_file} --csv-file=${menu_file} 26 | -------------------------------------------------------------------------------- /scripts-void/menus.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ ! -d ~/.t2ecol ]]; then 4 | mkdir -p ~/.t2ecol 5 | fi 6 | 7 | if [[ $1 == --bbswitch ]]; then 8 | if [[ ! -f ~/.t2ecol/menu-bbswitch.sh ]]; then 9 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-bbswitch.sh 10 | fi 11 | exec ~/.t2ecol/menu-bbswitch.sh 12 | fi 13 | 14 | if [[ $1 == --brightness ]]; then 15 | if [[ ! -f ~/.t2ecol/menu-brightness.sh ]]; then 16 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-brightness.sh 17 | fi 18 | exec ~/.t2ecol/menu-brightness.sh 19 | fi 20 | 21 | if [[ $1 == --brightness ]]; then 22 | if [[ ! -f ~/.t2ecol/menu-brightness.sh ]]; then 23 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-brightness.sh 24 | fi 25 | exec ~/.t2ecol/menu-brightness.sh 26 | fi 27 | 28 | if [[ $1 == --lbrightness ]]; then 29 | if [[ ! -f ~/.t2ecol/menu-lbrightness.sh ]]; then 30 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-lbrightness.sh 31 | fi 32 | exec ~/.t2ecol/menu-lbrightness.sh 33 | fi 34 | 35 | if [[ $1 == --volume ]]; then 36 | if [[ ! -f ~/.t2ecol/menu-volume.sh ]]; then 37 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-volume.sh 38 | fi 39 | exec ~/.t2ecol/menu-volume.sh 40 | fi 41 | 42 | if [[ $1 == --wifi ]]; then 43 | if [[ ! -f ~/.t2ecol/menu-wifi.sh ]]; then 44 | cp /usr/lib/t2ec/menu-template.sh ~/.t2ecol/menu-wifi.sh 45 | fi 46 | exec ~/.t2ecol/menu-wifi.sh 47 | fi 48 | -------------------------------------------------------------------------------- /scripts-void/pa-jgmenu.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # _*_ coding: utf-8 _*_ 3 | 4 | """ 5 | Author: Piotr Miller 6 | e-mail: nwg.piotr@gmail.com 7 | Website: http://nwg.pl 8 | Project: https://github.com/nwg-piotr/t2ec 9 | License: GPL3 10 | 11 | Credits: mreithub at https://unix.stackexchange.com/a/67398 (and comments below!) 12 | 13 | Dependencies: 'jgmenu' 'pulseaudio' 'pulseaudio-alsa' 14 | 15 | This script creates jgmenu to switch audio output with the pa-switch-output.sh helper script 16 | """ 17 | 18 | import os 19 | import subprocess 20 | 21 | 22 | def main(): 23 | # get sink numbers 24 | sinks = subprocess.check_output("pactl list short sinks", shell=True).decode("utf-8").splitlines() 25 | 26 | # get output descriptions 27 | names = subprocess.check_output("pacmd list-sinks | grep device.description | awk -F '=' '{print $2}'", 28 | shell=True).decode("utf-8").splitlines() 29 | outputs = [] 30 | 31 | # Tuples ("sink_number", "output_description") 32 | for output in range(len(sinks)): 33 | output = sinks[output].split()[0], names[output].strip()[1:-1] 34 | outputs.append(output) 35 | 36 | # Create jgmenu script 37 | jgmenu = [] 38 | jgmenu.append("#!/bin/sh\n") 39 | jgmenu.append("config_file=$(mktemp)") 40 | jgmenu.append("menu_file=$(mktemp)") 41 | jgmenu.append("trap \"rm -f ${config_file} ${menu_file}\" EXIT\n") 42 | jgmenu.append("cat << 'EOF' >${config_file}") 43 | jgmenu.append("stay_alive = 0") 44 | jgmenu.append("tint2_look = 1") 45 | jgmenu.append("menu_width = 40") 46 | jgmenu.append("menu_border = 1") 47 | jgmenu.append("item_height = 20") 48 | jgmenu.append("font = Sans 10") 49 | jgmenu.append("icon_size = 0") 50 | jgmenu.append("color_norm_fg = #eeeeee 100") 51 | jgmenu.append("color_sel_fg = #eeeeee 100") 52 | jgmenu.append("EOF\n") 53 | jgmenu.append("cat <<'EOF' >${menu_file}") 54 | 55 | # Use previously saved tuples (sink_number, output_description) to create jgmenu entries 56 | for output in outputs: 57 | jgmenu.append(output[1] + ", " + "/usr/lib/t2ec/pa-switch-output.sh " + output[0]) 58 | 59 | jgmenu.append("EOF\n") 60 | jgmenu.append("jgmenu --config-file=${config_file} --csv-file=${menu_file}") 61 | 62 | # Exit if jgmenu not installed 63 | try: 64 | subprocess.check_output("which jgmenu", shell=True) 65 | except subprocess.CalledProcessError: 66 | os.system("notify-send 'Install jgmenu package, run jgmenu init'") 67 | exit(0) 68 | 69 | # Save jgmenu script 70 | t2ec_dir = os.getenv("HOME") + "/.t2ecol" 71 | if not os.path.isdir(t2ec_dir): 72 | os.makedirs(t2ec_dir) 73 | 74 | with open(t2ec_dir + '/pulseaudio-menu.sh', 'w') as f: 75 | for item in jgmenu: 76 | f.write("%s\n" % item) 77 | 78 | # Make executable 79 | os.system("chmod u+x " + t2ec_dir + "/pulseaudio-menu.sh") 80 | 81 | # Execute jgmenu script 82 | os.system(t2ec_dir + "/pulseaudio-menu.sh &") 83 | 84 | 85 | if __name__ == "__main__": 86 | main() 87 | -------------------------------------------------------------------------------- /scripts-void/pa-switch-output.sh: -------------------------------------------------------------------------------- 1 | # Credits go to mreithub at https://unix.stackexchange.com/a/67398 (and comments below!) 2 | #!/usr/bin/env bash 3 | 4 | newSink="$1" 5 | 6 | pactl list short sink-inputs|while read stream; do 7 | streamId=$(echo $stream|cut '-d ' -f1) 8 | pacmd set-default-sink "$newSink" 9 | pactl move-sink-input "$streamId" "$newSink" 10 | done 11 | -------------------------------------------------------------------------------- /scripts-void/t2ec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ $1 == --bbswitch ]] || [[ $1 == --volume ]] || [[ $1 == --brightness ]] || [[ $1 == --lbrightness ]] || [[ $1 == --battery ]] || [[ $1 == --wifi ]]; then 4 | if [[ $2 == menu ]]; then 5 | exec /usr/lib/t2ec/menus.sh $1 6 | fi 7 | fi 8 | 9 | if [[ $1 == --desktop ]]; then 10 | exec /usr/lib/t2ec/desktop.py $2 11 | elif [[ $1 == --bbswitch ]]; then 12 | exec /usr/lib/t2ec/bbswitch-status-temp.sh $2 13 | elif [[ $1 == --paswitch ]]; then 14 | exec /usr/lib/t2ec/pa-jgmenu.py 15 | elif [[ $1 == --volume ]]; then 16 | exec /usr/lib/t2ec/volume-icon.sh $2 17 | elif [[ $1 == --brightness ]]; then 18 | exec /usr/lib/t2ec/brightness-icon.sh $2 19 | elif [[ $1 == --lbrightness ]]; then 20 | exec /usr/lib/t2ec/brightness-icon-light.sh $2 21 | elif [[ $1 == --battery ]]; then 22 | exec /usr/lib/t2ec/battery-icon.sh $2 23 | elif [[ $1 == --wifi ]]; then 24 | exec /usr/lib/t2ec/wifi-name.sh "$2" 25 | elif [[ $1 == --update ]]; then 26 | exec /usr/lib/t2ec/void-update.py "${@:2}" 27 | elif [[ $1 == --weather ]]; then 28 | exec /usr/lib/t2ec/weather.py "${@:2}" 29 | elif [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then 30 | exec /usr/lib/t2ec/help.sh 31 | else 32 | echo "Try 't2ec -h' for help" 33 | fi 34 | -------------------------------------------------------------------------------- /scripts-void/void-update.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # _*_ coding: utf-8 _*_ 3 | 4 | """ 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | Arguments [-C] | [-U ] | [menu] | -[O] [-N] | [-M] 12 | 13 | [-C] - check updates 14 | [-U] - your terminal name 15 | [-O] - display pending updates with notify-send 16 | [-N] - name instead of icon 17 | [menu] - show context jgmenu 18 | 19 | """ 20 | 21 | import sys 22 | import os 23 | import subprocess 24 | 25 | 26 | def main(): 27 | name = None 28 | terminal_name, helper_cmd, updates = "", "", "" 29 | do_check, do_update, do_notify = False, False, False 30 | 31 | tmp_file = os.getenv("HOME") + "/.void-updates" 32 | 33 | check_command = "xbps-install -Suvn | grep ' update ' | awk '{print $1}' > " + tmp_file 34 | 35 | if len(sys.argv) > 1: 36 | for i in range(1, len(sys.argv)): 37 | 38 | if sys.argv[i].upper() == '-O': 39 | do_check = False 40 | do_update = False 41 | do_notify = True 42 | break 43 | 44 | elif sys.argv[1].upper() == "MENU": 45 | show_menu() 46 | break 47 | 48 | if sys.argv[i].upper().startswith('-C'): 49 | do_check = True 50 | do_update = False 51 | do_notify = False 52 | 53 | if sys.argv[i].upper().startswith('-U'): 54 | tools = sys.argv[i][2::].split(":") 55 | terminal_name = tools[0] 56 | do_check = False 57 | do_update = True 58 | do_notify = False 59 | 60 | if sys.argv[i].upper() == '-N': 61 | name = "Upd:" 62 | 63 | if sys.argv[i].upper().startswith('-M'): 64 | name = sys.argv[i][2::] 65 | 66 | if sys.argv[i].upper() == '-H' or sys.argv[i].upper() == '-HELP': 67 | print("\nt2ec --update -C | -U | [-O] [-N] | [-M]\n") 68 | print("-C - (C)heck updates with xbps-install -Suvn") 69 | print("-U - (U)pdate in the you use") 70 | print(" example: t2ec --update -Uxfce4-terminal\n") 71 | print("-O - display saved pending updates as n(O)tification") 72 | print("-N - print (N)ame instead of icon") 73 | print("-M - print custom na(M)e instead of icon\n") 74 | 75 | if do_check: 76 | if name is not None: 77 | os.system("echo Checking...") 78 | else: 79 | os.system("echo /usr/share/t2ec/refresh.svg") 80 | os.system("echo ''") 81 | 82 | subprocess.call(check_command, shell=True) 83 | updates = open(tmp_file, 'r').read().rstrip() 84 | num_upd = len(updates.splitlines()) 85 | 86 | if name is not None: 87 | if num_upd > 0: 88 | print(name + " " + str(num_upd)) 89 | else: 90 | print("Up-to-date") 91 | else: 92 | if num_upd > 0: 93 | os.system("echo /usr/share/t2ec/void-update-notify.svg") 94 | os.system("echo " + str(num_upd)) 95 | else: 96 | os.system("echo /usr/share/t2ec/void-update.svg") 97 | os.system("echo ''") 98 | 99 | if do_update: 100 | command = terminal_name + ' -e \'sh -c \"sudo xbps-install -Suv; echo Press enter to exit; read; killall -SIGUSR1 tint2\"\'' 101 | subprocess.call(command, shell=True) 102 | 103 | if do_notify: 104 | updates = open(tmp_file, 'r').read().rstrip() 105 | notify(updates) 106 | 107 | 108 | def notify(updates): 109 | subprocess.call( 110 | ['notify-send', "Pending updates:", "--icon=/usr/share/t2ec/void-update-notify.svg", "--expire-time=5000", updates]) 111 | 112 | 113 | def show_menu(): 114 | try: 115 | subprocess.check_output("which jgmenu", shell=True) 116 | except subprocess.CalledProcessError: 117 | print("\nInstall jgmenu package, run `jgmenu init`\n") 118 | return 119 | 120 | t2ec_dir = os.getenv("HOME") + "/.t2ecol" 121 | if not os.path.isdir(t2ec_dir): 122 | os.makedirs(t2ec_dir) 123 | if not os.path.isfile(t2ec_dir + "/menu-update.sh"): 124 | subprocess.call(["cp /usr/lib/t2ec/menu-update.sh "+ t2ec_dir + "/menu-update.sh"], shell=True) 125 | subprocess.call([t2ec_dir + '/menu-update.sh'], shell=True) 126 | 127 | 128 | if __name__ == "__main__": 129 | main() 130 | -------------------------------------------------------------------------------- /scripts-void/volume-icon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script display an appropriate volume icon according to the volume level 4 | 5 | # Authors: Piotr Miller, @natemaia 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # License: GPL3 10 | 11 | # Dependencies: `alsa-utils` 12 | # arguments: [up] | [down] | [] | [-N] 13 | 14 | if [[ $1 == up ]]; then 15 | amixer set Master 5%+ -q 16 | elif [[ $1 == down ]]; then 17 | amixer set Master 5%- -q 18 | elif [[ $1 == toggle ]]; then 19 | amixer sset Master toggle -q 20 | else 21 | # If none of above, check if argument is a valid int, set volume if so 22 | if [[ $(($1)) == $1 ]] && [[ "$1" -ge 0 ]] && [[ "$1" -le 100 ]]; then 23 | amixer set Master "$1"% -q 24 | fi 25 | fi 26 | 27 | if [[ "$(amixer sget Master | grep -e 'Right:' -e 'Mono:')" == *"[on]"* ]]; then 28 | 29 | # search for the lines containing 'Right:' or 'Mono:', when more than 1 field exists 30 | # we strip the trailing '%' and round it up with printf "%0.0f" just in case 31 | vol=$(amixer sget Master | awk -F'[][]' '/Right:|Mono:/ && NF > 1 {sub(/%/, ""); printf "%0.0f\n", $2}') 32 | 33 | if [[ $1 == -N* ]]; then 34 | echo "Vol: ${vol}%" 35 | else 36 | if [[ ${vol} -ge 90 ]]; then 37 | echo /usr/share/t2ec/vol-full.svg 38 | elif [[ ${vol} -ge 40 ]]; then 39 | echo /usr/share/t2ec/vol-medium.svg 40 | elif [[ ${vol} -ge 10 ]]; then 41 | echo /usr/share/t2ec/vol-low.svg 42 | else 43 | echo /usr/share/t2ec/vol-lowest.svg 44 | fi 45 | echo ${vol}% 46 | fi 47 | else 48 | vol=$(amixer sget Master | awk -F'[][]' '/Right:|Mono:/ && NF > 1 {sub(/%/, ""); printf "%0.0f\n", $2}') 49 | echo /usr/share/t2ec/vol-muted.svg 50 | echo ${vol}% 51 | fi 52 | -------------------------------------------------------------------------------- /scripts-void/wifi-name.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # This script displays battery icon according to the charge level and charging state 4 | 5 | # Author: Piotr Miller 6 | # e-mail: nwg.piotr@gmail.com 7 | # Website: http://nwg.pl 8 | # Project: https://github.com/nwg-piotr/t2ec 9 | # Icon by @edskeye 10 | 11 | # Dependencies: `wireless_tools` 12 | # Arguments: [-N] ("Wi-Fi: " instead of icon) | [-M'custom name'] 13 | 14 | name="none" 15 | 16 | wifi=$(iwgetid | awk -F '"' '{ print $2 }') 17 | if [[ ! -z "$wifi" ]]; then 18 | name="$wifi" 19 | fi 20 | 21 | if [[ $1 == -N* ]]; then 22 | echo "Wi-Fi: $name" 23 | elif [[ $1 == -M* ]]; then 24 | echo "$(echo $1 | cut -c3-) $name" 25 | else 26 | echo /usr/share/t2ec/network.svg 27 | echo ${name} 28 | fi 29 | 30 | --------------------------------------------------------------------------------