p-e-w / GTKDarkThemeVariantSetter

Make Sublime Text use the dark GTK+ theme variant (NO LONGER MAINTAINED)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IndexError: list index out of range in get_pid_from_window_id

LeoIannacone opened this issue · comments

Hi,

In a Ubuntu Utopic (14.10) fresh installation and with sublime 3 (build 3065) you're plugin does not work.

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 303, in on_activated
    callback.on_activated(v)
  File "GTKDarkThemeVariantSetter in /home/l3on/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 40, in on_activated
  File "GTKDarkThemeVariantSetter in /home/l3on/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 29, in get_pid_from_window_id
IndexError: list index out of range

What is the name of your Sublime Text executable?

$ which subl
/usr/bin/subl
$ subl --version
Sublime Text Build 3065

Hmm... subl is definitely on the list of supported executable names. The only advice I have to offer is to run the shell commands executed by the Python scripts "by hand" and look at their output to see where the problem lies.

I had this exact issue and was able to resolve it by removing the assumption xprop would always return a pid. I do not know why this is though.

Same problem here, can you fix this please?? I'm getting:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 304, in on_activated
    callback.on_activated(v)
  File "GTKDarkThemeVariantSetter in /home/user/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 40, in on_activated
  File "GTKDarkThemeVariantSetter in /home/user/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 29, in get_pid_from_window_id
IndexError: list index out of range

@erasmo-marin: Could you please post the output of the individual commands that the script runs (explained in this section) so I can see what the issue is?

@p-e-w I can confirm that the problem is fixed in the merge request. I'll trace the code as soon as I can. Thanks.

I can confirm this error on my system (Ubuntu GNOME 15.04) and the merge does indeed fix the issue.

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 304, in on_activated
    callback.on_activated(v)
  File "GTKDarkThemeVariantSetter in /home/coderstephen/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 40, in on_activated
  File "GTKDarkThemeVariantSetter in /home/coderstephen/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 29, in get_pid_from_window_id
IndexError: list index out of range

I would really like to merge the proposed fix, but not without understanding what is actually going on (I still cannot reproduce). Could someone affected by this issue please post the output of the individual commands from the README?

Full messages in console (it fails):

DPI scale: 1
startup, version: 3083 linux x64 channel: stable
executable: /opt/sublime_text/sublime_text
working dir: /home/erasmo
packages path: /home/erasmo/.config/sublime-text-3/Packages
state path: /home/erasmo/.config/sublime-text-3/Local
zip path: /opt/sublime_text/Packages
zip path: /home/erasmo/.config/sublime-text-3/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.139846
startup time: 0.272039
first paint time: 0.276483
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.quick_panel
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin 0_package_control_loader.00-package_control
reloading plugin 0_package_control_loader.01-ssl-linux
Linux SSL: successfully loaded _ssl module for libssl.so.1.0.0
reloading plugin 0_package_control_loader.02-bz2
reloading plugin CSS3.css3_completions
reloading plugin CSS3.rgb_to_hex
reloading plugin CSS3.validator
reloading plugin Compare Side-By-Side.sbs_compare
reloading plugin GTKDarkThemeVariantSetter.GTKDarkThemeVariantSetter
reloading plugin Hide Menu.sublime-hide-menu
reloading plugin Open Folder.OpenFolder
reloading plugin Package Control.Package Control
reloading plugin Package Control.bootstrap
plugins loaded
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 304, in on_activated
    callback.on_activated(v)
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 40, in on_activated
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 29, in get_pid_from_window_id
IndexError: list index out of range
Package Control: Skipping automatic upgrade, last run at 2015-09-03 15:34:46, next run at 2015-09-03 16:34:46 or after
reloading Packages/User/Preferences.sublime-settings
reloading Packages/User/Preferences.sublime-settings
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 304, in on_activated
    callback.on_activated(v)
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 40, in on_activated
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 29, in get_pid_from_window_id
IndexError: list index out of range
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 304, in on_activated
    callback.on_activated(v)
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 40, in on_activated
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 29, in get_pid_from_window_id
IndexError: list index out of range
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 304, in on_activated
    callback.on_activated(v)
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 40, in on_activated
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 29, in get_pid_from_window_id
IndexError: list index out of range
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 304, in on_activated
    callback.on_activated(v)
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 40, in on_activated
  File "GTKDarkThemeVariantSetter in /home/erasmo/.config/sublime-text-3/Installed Packages/GTKDarkThemeVariantSetter.sublime-package", line 29, in get_pid_from_window_id
IndexError: list index out of range

and individual commands on a terminal (it works):

erasmo@erasmo-g4:~$ pidof sublime_text
8604

erasmo@erasmo-g4:~$ xprop -root _NET_CLIENT_LIST
_NET_CLIENT_LIST(WINDOW): window id # 0x1a00003, 0x1800003, 0x220000a, 0x2400002, 0x2800007, 0x2c0000a, 0x1a00168, 0x2600003, 0x2e00001

erasmo@erasmo-g4:~$ xprop -id 0x2600003 _NET_WM_PID
_NET_WM_PID(CARDINAL) = 8604

erasmo@erasmo-g4:~$ xprop -id 0x2600003 -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT dark

Thank you very much for posting those details, @erasmo-marin. However, I still do not understand what is happening here. As the output from your console commands shows, the approach works fine on your system. So what causes the Python code to fail?

For example:

0:pts/2:~% xprop -root _NET_CLIENT_LIST                                                        
_NET_CLIENT_LIST(WINDOW): window id # 0x160000a, 0x440008c, 0xc000ab, 0x3400083, 0x380000e, 0x5400001, 0x2c00019, 0x5e00664, 0x3200003, 0x5e159de, 0x1a0000a, 0x5e15c74
0:pts/2:~% xprop -id 0x3200003 WM_NAME
WM_NAME(STRING) = "untitled - Sublime Text"
0:pts/2:~% xprop -id 0x3200003 _NET_WM_PID
_NET_WM_PID(CARDINAL) = 29483
0:pts/2:~% xprop -id 0x1a0000a WM_NAME    
WM_NAME(STRING) = "xeyes"
0:pts/2:~% xprop -id 0x1a0000a _NET_WM_PID
_NET_WM_PID:  not found.
0:pts/2:~%