imdb-terminal 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -0
  3. data/bin/imdb +49 -7
  4. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 44360341d112b1115c484d11fcbecc250618c6cbb20791b33d6afe9dac43d269
4
- data.tar.gz: bbfd0e1b1c8a4a2178743bf76786c763591c3ba422e275b403e826cbf1dfada1
3
+ metadata.gz: d814b0c158e9b0dc4e11670de9abd9650558ab146d47382d9b7fa4e0ca05c336
4
+ data.tar.gz: cf3b4b5fb79289936b4f284cd48ee691ccede5c86476807a3c229234d430df09
5
5
  SHA512:
6
- metadata.gz: d12e3fdc3780aed6392ea05b41f61adc4b3f942cf0dd69971c5fdc479a44581a047251a9c8d810c34fd7d3a6c67166b9031fbe7b0a0bdd0f29db55ad7930056a
7
- data.tar.gz: 15c08b8c4e6bd4b2c7433ef23b2f896366b622246aaf8bf29bb422a6ef55613a938fa562616b3db0c592e069a8ed599b1e97e54ff2988c15a43051e357a5d1f3
6
+ metadata.gz: 8d009074d8b863c6d69355c841cf68ac69283a0e13849452b0f9b861df636437b0958becac04ae1efa72b43af2dbaab329e657768e91e71450878a2cd2840525
7
+ data.tar.gz: 846addf3e87942df18ca7672ef82ebb87a1dbfd0c8919a92c276297ef68431b92f0a1f3e21288f647f008e35e41adc523fc068ca895c253291a1d8cf6f408c06
data/README.md CHANGED
@@ -44,6 +44,7 @@ gem install imdb-terminal
44
44
  ### Dependencies
45
45
  - **w3mimgdisplay** (for poster display): `sudo apt install w3m-img`
46
46
  - **ImageMagick** (for poster processing): `sudo apt install imagemagick`
47
+ - **xdotool** (for image redraw on workspace switch): `sudo apt install xdotool`
47
48
 
48
49
  ### Quick Start
49
50
  ```bash
@@ -140,6 +141,10 @@ In the Genres pane:
140
141
  - Ensure w3m-img is installed: `sudo apt install w3m-img`
141
142
  - Check terminal supports images (works best in terminals like urxvt, kitty, iTerm2)
142
143
 
144
+ **Posters disappear after workspace switch:**
145
+ - Ensure xdotool is installed: `sudo apt install xdotool`
146
+ - Version 1.3.0+ includes automatic image redraw for i3 workspace switching
147
+
143
148
  **Encoding errors:**
144
149
  - Fixed automatically with built-in encoding handling
145
150
 
@@ -182,6 +187,7 @@ This enhanced version includes:
182
187
  - **Re-fetch capability** for data correction
183
188
  - **Improved encoding** handling for international content
184
189
  - **Better UX** with compact UI and auto-refresh
190
+ - **Image redraw functionality** for i3 workspace switching (v1.3.0+)
185
191
 
186
192
  ## © License
187
193
 
data/bin/imdb CHANGED
@@ -14,7 +14,7 @@
14
14
  # for any damages resulting from its use. Further, I am under no
15
15
  # obligation to maintain or extend this software. It is provided
16
16
  # on an 'as is' basis without any expressed or implied warranty.
17
- # Version: 1.2: Added jump-to for searched&scraped items
17
+ # Version: 1.3.0: Added image redraw functionality for i3 workspace switching
18
18
 
19
19
  # REQUIRES AND CONSTANTS {{{1
20
20
  require 'io/console'
@@ -77,6 +77,8 @@ class IMDBApp
77
77
  rebuild_index
78
78
  @list.border = true
79
79
  @last_poster_id = nil
80
+ @current_image = nil
81
+ @last_active_window = nil
80
82
 
81
83
  run_loop
82
84
  ensure
@@ -1829,6 +1831,12 @@ class IMDBApp
1829
1831
  end
1830
1832
 
1831
1833
  `echo "0;1;#{px};#{py};#{iw};#{ih};;;;;\"#{file}\"\n4;\n3;" | #{w3m} 2>/dev/null`
1834
+
1835
+ # Track the current image
1836
+ @current_image = file
1837
+ else
1838
+ # Clear current image if no file exists
1839
+ @current_image = nil
1832
1840
  end
1833
1841
  end
1834
1842
  rescue Timeout::Error
@@ -1836,15 +1844,38 @@ class IMDBApp
1836
1844
  end
1837
1845
  end
1838
1846
 
1847
+ def check_image_redraw #{{{2
1848
+ # Only check if we have an image currently displayed
1849
+ return unless @current_image && File.exist?(@current_image)
1850
+
1851
+ begin
1852
+ # Check if we're in the active window - if not, image overlay might be cleared
1853
+ active_window = `xdotool getactivewindow 2>/dev/null`.chomp
1854
+ return if active_window.empty?
1855
+
1856
+ # Check if this terminal window is the active one
1857
+ current_window = `xdotool getwindowfocus 2>/dev/null`.chomp
1858
+
1859
+ # Only redraw if we detect a focus change (simple heuristic)
1860
+ if @last_active_window && @last_active_window != active_window && current_window == active_window
1861
+ # Window focus changed and we're now active - redraw image using last poster id
1862
+ show_poster(@last_poster_id) if @last_poster_id
1863
+ end
1864
+
1865
+ @last_active_window = active_window
1866
+ rescue
1867
+ # Silently fail - we don't want focus checking to break anything
1868
+ end
1869
+ end
1870
+
1839
1871
  # MAIN LOOP {{{1
1840
1872
  def run_loop #{{{2
1841
1873
  @last_poster_id = nil
1874
+ @current_image = nil
1875
+ @last_active_window = nil
1842
1876
  draw_all
1843
1877
  loop do
1844
- ready = IO.select([STDIN], nil, nil, 0.05)
1845
- if ready
1846
- handle_input
1847
- end
1878
+ handle_input
1848
1879
  if defined?(@ui_update_queue) && @ui_update_queue
1849
1880
  begin
1850
1881
  while !@ui_update_queue.empty?
@@ -1966,7 +1997,12 @@ class IMDBApp
1966
1997
 
1967
1998
  # Handle help mode input separately
1968
1999
  if @help_mode != :hidden # {{{3
1969
- case getchr
2000
+ key = getchr(1) # 1 second timeout for help mode
2001
+ unless key # If timeout occurred (no key pressed)
2002
+ check_image_redraw # Check if image needs redraw after workspace switch
2003
+ return
2004
+ end
2005
+ case key
1970
2006
  when 'UP' # {{{4
1971
2007
  if @help_mode == :search
1972
2008
  # Scroll content only, header stays fixed
@@ -2197,7 +2233,13 @@ class IMDBApp
2197
2233
  end
2198
2234
  end
2199
2235
 
2200
- case getchr
2236
+ key = getchr(1) # 1 second timeout for normal input
2237
+ unless key # If timeout occurred (no key pressed)
2238
+ check_image_redraw # Check if image needs redraw after workspace switch
2239
+ return
2240
+ end
2241
+
2242
+ case key
2201
2243
  when 'c' # {{{3
2202
2244
  @cancel_scrape.make_true if defined?(@cancel_scrape)
2203
2245
  return
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imdb-terminal
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-15 00:00:00.000000000 Z
11
+ date: 2025-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rcurses
@@ -71,7 +71,8 @@ description: 'Discover and manage movies and TV series from IMDb''s Top 250 list
71
71
  streaming information via TMDb, wish lists, and terminal poster display. Enhanced
72
72
  with jump-to-existing items, duplicate management, and robust data handling. Version
73
73
  1.1: A full rewrite using rcurses - with lots of new functionality. 1.2: Added jump-to
74
- for searched&scraped items.'
74
+ for searched&scraped items. 1.3.0: Added image redraw functionality for i3 workspace
75
+ switching.'
75
76
  email: g@isene.com
76
77
  executables:
77
78
  - imdb
@@ -99,6 +100,7 @@ post_install_message: |
99
100
  External dependencies for full functionality:
100
101
  - w3m-img (for poster display): sudo apt install w3m-img
101
102
  - imagemagick (for poster processing): sudo apt install imagemagick
103
+ - xdotool (for image redraw on workspace switch): sudo apt install xdotool
102
104
 
103
105
  Enjoy discovering your next favorite movie! :-)
104
106
  rdoc_options: []