Guest User

plasma hack sh

a guest
Nov 12th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.26 KB | None | 0 0
  1. #! /bin/bash
  2.  
  3. # Main Plasma 5 Desktop Configuration File
  4. plasma_applets_file="${HOME}/.config/plasma-org.kde.plasma.desktop-appletsrc"
  5.  
  6. awk '
  7. function initialise_global_variables()
  8. {
  9.     # **** Add per panel settings in an ordered list here ****
  10.     # location=5 formfactor=3 [left]
  11.     # location=6 formfactor=3 [right]
  12.     # location=3 formfactor=2 [top]
  13.     # location=4 formfactor=2 [bottom]
  14.  
  15.     # Panel 1
  16.     panel_array[1,"formfactor"]=2
  17.     panel_array[1,"lastScreen"]=0
  18.     panel_array[1,"location"]=4
  19.     # Panel 2 ...
  20.     panel_array[2,"formfactor"]=2
  21.     panel_array[2,"lastScreen"]=1
  22.     panel_array[2,"location"]=4
  23.     # **** Add per panel settings in an ordered list here ****
  24.  
  25.     # List of all panel variables we want to be able to reset
  26.     panel_variables="formfactor lastScreen location"
  27.  
  28.     split(panel_variables, panel_settings_array)
  29.     blank_line_regexp="^[[:blank:]]*$"
  30. }
  31.  
  32. function check_panel_settings_valid(            i)
  33. {
  34.     for (i in panel_settings_array) {
  35.         if ((panel,panel_settings_array[i]) in panel_array)
  36.             return 1
  37.     }
  38.     return 0
  39. }
  40.  
  41. function process_panel_block(line,
  42.     i, panel_setting)
  43. {
  44.     # Go to end of panel block ...
  45.     while ((++line<=line_count) && (plasma_file_array[line] !~ blank_line_regexp)) {}
  46.  
  47.     # ... work back through panel block ...
  48.     while ((--line >= 1) && (plasma_file_array[line] !~ blank_line_regexp)) {
  49.         for (i in panel_settings_array) {
  50.             panel_setting=panel_settings_array[i]
  51.             if ((panel,panel_setting) in panel_array)
  52.                 sub((panel_setting "=[[:digit:]]+$"),
  53.                     (panel_setting "=" panel_array[panel,panel_setting]),
  54.                     plasma_file_array[line])
  55.         }
  56.     }
  57. }
  58.  
  59. BEGIN{
  60.     initialise_global_variables()
  61. }
  62.  
  63. {
  64.     plasma_file_array[++line]=$0
  65. }
  66.  
  67. END{
  68.     line_count=line
  69.     panel=1
  70.     if (! check_panel_settings_valid())
  71.             exit 1
  72.     for (line=1; line<=line_count; ++line) {
  73.         if (plasma_file_array[line] !~ /^plugin=org\.kde\.panel/)
  74.             continue
  75.            
  76.         process_panel_block(line)
  77.         ++panel
  78.         if (! check_panel_settings_valid())
  79.             break
  80.     }
  81.     for (line=1; line<=line_count; ++line)
  82.         print plasma_file_array[line]
  83. }' "${plasma_applets_file}" 1>"${plasma_applets_file}.new" 2>/dev/null
  84.  
  85. [ -f "${plasma_applets_file}.new" ] && mv "${plasma_applets_file}.new" "${plasma_applets_file}"
  86.  
  87. kquitapp5 plasmashell ; /usr/bin/plasmashell --shut-up &>/dev/null &
Add Comment
Please, Sign In to add comment